简体   繁体   中英

Using cpp dll in c# project

I have a win32 cpp dll, and ac# 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?

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?

我建议您将非托管DLL添加到PROJ3解决方案中,并在属性中将“复制到输出目录”设置为“始终复制”

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM