cyssima
cyssima

Reputation: 41

Using cpp dll in c# project

I have a win32 cpp dll, and a c# project (PROJ_1), that use dllimport to call win32 dll functions. This dll included into project PROJ_1 and has build action as copy to output dir.

Another c# project (PROJ_2) references PROJ_1 and PROJ_3 references PROJ_2.

So, now we have something like this PROJ_3->PROJ_2->PROJ_1(dll)

So, when i make build in VS 2010: 1. In bin of PROJ_1 i have win32 dll. 2. In bin of PROJ_2 too 3. But in PROJ_3 - no win32 dll exists

What is the problem a how to resolve it?

Upvotes: 0

Views: 623

Answers (3)

Matěj Zábský
Matěj Zábský

Reputation: 17272

If the projects are in one VS solution, do you have dependencies between projects correctly defined (right click project -> Project dependencies)? Are all the projects built for the same target architecture (64/86)?

As side question - Did you consider writing C++/CLI wrapper?

Upvotes: 1

John xyz
John xyz

Reputation: 186

You could check the 'Copy Local' property of the reference to PROJ_2. In PROJ_1, add the win32 dll to your solution (no reference, just add it as a file just like a class in your solution) and set the properties Build Action = Content, Copy to Output Directory = Copy always.

Upvotes: 0

Daniel Hilgarth
Daniel Hilgarth

Reputation: 174309

I suggest, you add that unmanaged DLL to the PROJ3 solution and in the properties set "Copy to Output Directory" to "Copy always"

Upvotes: 0

Related Questions