2

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.

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:


An unhandled exception of type 'System.IO.FileNotFoundException' occurred in System.Windows.Forms.dll

Additional information: The specified module could not be found. (Exception from HRESULT: 0x8007007E)


This exception is thrown when I put the following code (for example) in the button click event.

    private void button3_Click(object sender, EventArgs e)
    {
        CyclopiaDll.Class1 cc = new CyclopiaDll.Class1(); // calling dll 
        cc.clearData();            
    }

However the exception is actually shown to be thrown in this line even though the form gets loaded without a problem:

  Application.Run(new Form1());

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.

Only way I can think of solving this is to recreate the project from the scratch as before. which is time consuming.

Is there a way to avoid this problem so that I can run this project in my computer as well as in another computer ?

2 Answers 2

3

It sounds like you have a missing dependency i.e. another dll that your C++ dll depends on, that is not present on your machine.

You can use a utility like "Dependency Walker" to load your C++ dll on a machine where you have a problem, and it will point out any any missing dependencies. It is then a case of working out what this dependency is (e.g. missing C++ runtime version) and then ensuring this is packaged with your application either directly or via a merge module if suitable, for instance.

Dependency Walker: http://www.dependencywalker.com/

Sign up to request clarification or add additional context in comments.

1 Comment

thanks. I managed to find some missing dlls paths shown by dependency walker. After fixing those it seems to be working :)
1

It looks like the compiler is not putting the referenced dll in the output folder. I would just put it in there manually.

2 Comments

Well it is not the issue. I checked and the the dll is created and referenced properly.
The output folder of the project that is failing, {Project}\bin\Debug. Visual Studio should copy the dll in there from wherever you are referencing it, but sometimes doesn't.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.