teodron
teodron

Reputation: 1428

Loading managed DLL in C++ CLI, depending on native dlls

Following the solution proposed in a similar SO question, I want to load a fairly complex dll file in a C++ CLI app (or C# for that matter of fact). The target architecture is consistently set to 64 bits.

The .dll to be consumed in this app is generated in another project and it is written in C++ CLI using native C++ libraries (e.g. Ogre, Boost, etc.) and depends on its own dlls (all of them have been compiled for 64 bit platforms). These dependency dlls are copied in the output folder of my application, together with the pesky .dll that uses them.

However, when reaching this line:

Assembly^ SampleAssembly;
SampleAssembly = Assembly::LoadFrom( "E:\\x64\\Debug\\OgreWrapper.dll" );

the output console reads:

'DumbTestCLR.exe': Loaded 'E:\x64\Debug\OgreWrapper.dll', Symbols loaded.
'DumbTestCLR.exe': Unloaded 'E:\x64\Debug\OgreWrapper.dll'

and some fatal uncaught exceptions are thrown:

First-chance exception at 0x000007fefe32cacd (KernelBase.dll) in DumbTestCLR.exe: Microsoft C++ exception: EEFileLoadException * __ptr64 at memory location 0x0016d588..
First-chance exception at 0x77cace3b (ntdll.dll) in DumbTestCLR.exe: 0xC0000005: Access violation reading location 0xffffffffffffffff.
First-chance exception at 0x77cace3b (ntdll.dll) in DumbTestCLR.exe: 0xC0000005: Access violation reading location 0xffffffffffffffff.
First-chance exception at 0x77cace3b (ntdll.dll) in DumbTestCLR.exe: 0xC0000005: Access violation reading location 0xffffffffffffffff.

Since none of the suggestions given here apply (i.e. it's not because of bitness conflicts between the app and the dll), what could be the source of the problem? I suspect the dll cannot load other (native) dlls and hence the crash, but how to check which dlls cause the problem, if this might be the case?

sorry for the long question and for the, perhaps, dumb question..

Upvotes: 2

Views: 2577

Answers (1)

Yochai Timmer
Yochai Timmer

Reputation: 49221

Use Dependency Walker to see if the dll's dependencies are all there.

Upvotes: 2

Related Questions