简体   繁体   English

在C#中使用C ++ / CLI库

[英]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 父项目:C ++ / CLI,其中混入了一些本机C ++
  • Child project: C#, reference to the parent 子项目:C#,引用父项目

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”:

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. 我做了一些谷歌搜索,很多人说,如果您在x86中构建一个DLL,而在任何CPU或x64中构建另一个DLL,则可能会发生这种情况。

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: 我承认我发现Visual Studio的构建配置GUI令人难以置信地令人困惑,所以下面是屏幕截图:

构建配置

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. 否则,请查看fuslogvw.exe来诊断绑定失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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