Reputation: 21
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
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
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:
Assuming the DLL is compatible with your project everything should work just fine.
Upvotes: 0
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