newidforu
newidforu

Reputation: 1

Help with loading a .Net DLL from c++/Cli

I have a .Net DLL which I need to call from a 3rd party application. The 3rd party application does not support loading managed DLLs and so I am using a c++/CLI DLL which exposes a native c++ function to be called by the application as shown below.

3rd party application -> c++/cli DLL -> .Net DLL

My problem is that my c++/Cli dll crashes with an "Access violation" error when it tries to call functions from the .Net dll. This problem does not occur if I call the .Net DLL directly from a VC++ console application.

Do you think I am missing some dependencies when I create a c++/cli dll with the clr option set true in visual studio?

I followed Hans Passant's suggestion and debugged it. Turns out the exception I was getting was a "file not found exception". My scenario is

3rd party app -> c++/cli dll -> .Net managed DLL

Placing the .Net managed DLL in the same folder as the 3rd party exe solved the problem. Now my question is

"Can I get the C++/CLI dll to look for the .Net dll in a specified path instead of having to place the .Net dll in the same folder as the 3rd party app?."

Thanks

Upvotes: 0

Views: 580

Answers (1)

Hans Passant
Hans Passant

Reputation: 942438

You'll need to debug it. Right-click the project in the Solution Explorer window, Properties, Debugging. Set the Command property to the path of the EXE that is going to load your DLL. Set Command Arguments and Working Directory as necessary. Set a breakpoint on the exported function. Press F5.

Upvotes: 2

Related Questions