title: runtime error when calling a C++ dll from C# .NET windows application
body: <p>I had a C# .NET windows application having C# user interface and all the code behind processing is done by calling C++ dll (C++ class library project) which is added as a reference to the C# project.</p>
  
  <p>However recently when I formatted my computer and again tried to run my project which was backed up, in visual studio 2005 it gave the following exception:</p>
  
  <hr>
  
  <p><strong>An unhandled exception of type 'System.IO.FileNotFoundException' occurred in System.Windows.Forms.dll</strong></p>
  
  <p><strong>Additional information: The specified module could not be found. (Exception from HRESULT: 0x8007007E)</strong></p>
  
  <hr>
  
  <p>This exception is thrown when I put the following code (for example) in the button click event.</p>
  
  <pre><code>    private void button3_Click(object sender, EventArgs e)
      {
          CyclopiaDll.Class1 cc = new CyclopiaDll.Class1(); // calling dll 
          cc.clearData();            
      }
  </code></pre>
  
  <p>However the exception is actually shown to be thrown in this line even though the form gets loaded without a problem:</p>
  
  <pre><code>  Application.Run(new Form1());
  </code></pre>
  
  <p>I tried building the new project and adding the referenced dll again but I m still getting the exception. 
  This happened to me before also when I tried to run this project in another computer. However after my machine was formatted even I cant even run the application. </p>
  
  <p>Only way I can think of solving this is to recreate the project from the scratch as before. which is time consuming. </p>
  
  <p>Is there a way to avoid this problem so that I can run this project in my computer as well as in another computer ? </p>