简体   繁体   中英

Using a C++/CLI library in C#

I have a solution that looks like this:

Solution

  • Parent project: C++/CLI with some native C++ mixed in
  • Child project: C#, reference to the parent

The child project can reference a static class and method from the parent project and both projects compile fine.

However, when I try to run the child project, as soon as it tries to access that static method, the runtime crashes with a "FileNotFoundException":

FileNotFoundException异常

I did some Googling and a lot of people say that this can happen if you're building one DLL in x86 and the other in ANY CPU or x64.

But I adjusted my build configuration and I'm still getting this problem. I'll admit that I find visual studio's build configuration GUI unbelievably confusing, so here's a screenshot:

构建配置

So... Any clues as to what I need to do to get this working?

Might be that the output directory of your projects are not configured correctly.

Otherwise have a look at fuslogvw.exe to diagnose the failed binding.

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