简体   繁体   English

.NET程序集DLL缺少依赖项

[英].NET assembly DLL missing dependencies

I'm making a C++/CLI wrapper for a C++ class, but the DLL created by building my C++/CLI project fails to load in C#, Assembly.Load throws a fileNotFound exception with the message "Could not load file or assembly 'CLIExport.dll' or one of its dependencies. The system cannot find the file specified." 我正在为C ++类制作C ++ / CLI包装程序,但是通过构建C ++ / CLI项目创建的DLL无法在C#中加载,Assembly.Load引发fileNotFound异常,并显示消息“无法加载文件或程序集'CLIExport .dll”或其依赖项之一。系统找不到指定的文件。”

The C++/CLI project includes only the wrapper class, the C++ class, and one header file that the C++ class depends on, for which the source and header files has been added to the solution, no references have been added. C ++ / CLI项目仅包含包装器类,C ++类和C ++类所依赖的一个头文件,为此已将源文件和头文件添加到解决方案中,而未添加引用。 Do I need to add references to the C++ class in the C++/CLI project? 我是否需要在C ++ / CLI项目中添加对C ++类的引用? I don't know what the C# app thinks the assembly is missing, and I don't know what I need to add references to, does the C++/CLI project need to have a reference to every .net type it uses like classes in the System namespace? 我不知道C#应用程序认为缺少什么程序集,也不知道需要添加引用,C ++ / CLI项目是否需要引用它所使用的每个.net类型,例如系统名称空间?

Thanks. 谢谢。

I believe the problem is that you are trying to use unmanaged x86 dlls in a 64bit solution. 我相信问题是您正在尝试在64位解决方案中使用不受管理的x86 dll。

Try doing : Right click on your solution, then Configuration manager , and set all your projects to x86 , then try building again. 尝试做:右键单击您的解决方案,然后单击“ Configuration manager ,并将所有项目设置为x86 ,然后再次尝试构建。

Im pretty sure that your build configuration is inconsistent, therefore the error message (I ran into the same problem a few times ...) 我非常确定您的构建配置不一致,因此出现错误消息(我几次遇到相同的问题...)

You can read up here : What does the Visual Studio "Any CPU" target mean? 您可以在这里阅读: Visual Studio“任何CPU”目标是什么意思?

And a quick overview of the different targets in VS : http://visualstudiohacks.com/articles/visual-studio-net-platform-target-explained/ 以及VS中不同目标的快速概述: http : //visualstudiohacks.com/articles/visual-studio-net-platform-target-explained/

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

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