Nick Drobec
Nick Drobec

Reputation: 21

Visual studio C#, DLL not found after installing the application

I have created a DLL in C++ which I would like to import to my C# project. The application works when I run it in the Visual basic 2019. Later I have created a setup project, when I install the application it still works flawlessly on my computer.

The problem occurs when I install it on another computer, in that case I get the following error: error

The C# code:

[DllImport(@".\\shared_lib2.dll", CallingConvention = CallingConvention.Cdecl)]
        static extern void Connect(string str,string str1);

Upvotes: 0

Views: 3594

Answers (3)

Nick Drobec
Nick Drobec

Reputation: 21

Ok, it seems I have found the issue. The DLL I was trying to init had dependencies. I then searched for them with dumpbin.exe and copied them to the install folder. Now it's working on a freshly installed VM flawlessly.

Upvotes: 2

dogyear
dogyear

Reputation: 328

What @Broteamson suggested would technically work, but that would require to you manually add in the DLL after every build. I recommend adding the DLL to your project in Visual Studio as a dependency. I've numbered the picture to match the instructions. You'll need to:

  1. Right click on Dependencies in your project and select "Add Project References"
  2. Select "Browse" and find the DLL you want to include in your project.

Assuming the DLL is compatible with your project everything should work just fine.

enter image description here

Upvotes: 0

aaa
aaa

Reputation: 1

I have met this error and i have fixed it by put .dll file needed to import to the DEBUG folder in my project.

Upvotes: 0

Related Questions