简体   繁体   English

无法将托管的C ++ dll加载到C#Dll中

[英]Unable to load the Managed C++ dll into C# Dll

I have a C# application which is built with platform target as ANY CPU. 我有一个C#应用程序,该应用程序的平台目标是任何CPU。 It references a managed C++ application which is built with the platform target as Win32. 它引用了以平台目标为Win32构建的托管C ++应用程序。 However the loading of the C++ dll fails at runtime with the following error. 但是,C ++ dll的加载在运行时失败,并出现以下错误。 "Could not load file or assembly 'abc_Debug, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Attempt to access invalid address. (Exception from HRESULT: 0x800701E7)" “无法加载文件或程序集'abc_Debug,版本= 0.0.0.0,文化=中性,PublicKeyToken =空”或其依赖项之一。尝试访问无效的地址。(来自HRESULT的异常:0x800701E7)

Can anyone give me some pointers as to what could be wrong? 谁能给我一些关于什么地方可能出问题的指示?

If you are running the application at a x64 architecture then your app is starting as x64 and then it can't load the c++ reference. 如果您在x64体系结构上运行该应用程序,则您的应用程序将以x64开头,那么它将无法加载c ++参考。 You cannot build an application as AnyCpu if you don't have all the dependences available for AnyCpu, otherwise set x86 as the target. 如果您没有可用于AnyCpu的所有依赖项,则不能将应用程序构建为AnyCpu,否则将x86设置为目标。

通常,对于托管dll的任何加载问题,最好使用fuslogvw,它可以为您提供更多详细信息。

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

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