I am using Visual Studio 2008 Professional and I need to create a solution with two projects. One project is managed by the WinForms C # project, the second by an unmanaged C ++ DLL project.
I created them in VS2008, and in an unmanaged DLL project, I exported a simple function that returns some int. In a managed WinForms project, I imported the DLL in the usual way and tried to print the return value in the label:
[DllImport("DllProj.dll", EntryPoint = "GetSomeInt", SetLastError = true)] private static extern int GetSomeInt();
But when I create the solution and run, I get a DllNotFoundException . I also tried to add the existing element ( DllProj.dll ) to the WinForms project, but only copied this DLL from the Debug folder to the WinForms project folder, but not to the Debug subfolder where the compiled project is located. Therefore, I still get a DllNotFoundException .
I also tried adding it as a reference, but VS2008 complains that my DLL is not a COM or a managed entity. Is there any way to configure the solution in such a way that I do not need to manually copy the compiled DLL to the Debug subfolder of the WinForms project after each build?
source share