1
votes

I have a C# application which is built with platform target as ANY CPU. It references a managed C++ application which is built with the platform target as Win32. However the loading of the C++ dll fails at runtime with the following error. "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)"

Can anyone give me some pointers as to what could be wrong?

2
How are you loading the c++ dll, can you paste the code of loading the dll part?programmer
It's a very low-level error, something goes wrong when the DLL initializes itself through DllMain(). Enable unmanaged code debugging and cross your fingers that you'll see a first-chance exception in the Output window.Hans Passant
Well its a managed C++ dll. So I reference it in my C# application directly..Loading if that is failing at runtime..any thoughts?Sapna

2 Answers

1
votes

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. You cannot build an application as AnyCpu if you don't have all the dependences available for AnyCpu, otherwise set x86 as the target.

0
votes

in general for any loading problem of managed dlls, it's better to use fuslogvw it can gives you more details.