Sign in to follow this  

[.net] Calling Managed C++ DLL from Native C++

This topic is 3486 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there, I'm experimenting with pushing some of my UI functionality out of my native C++ app and into a C# DLL. I've got the COM route working (based on this), but for various reasons I would like to at least try a different method for comparison: creating a Managed C++ wrapper DLL and then calling that from my unmanaged C++ code. I'm basing this approach on this article: http://blogs.msdn.com/borisj/archive/2007/02/09/interop-101-part-5.aspx It all compiles and everything, but when I come to run it, I get an exception. The output looks like this:
'GRACE.exe': Loaded 'C:\VCProjects\GRACE\debug (with profiler)\SPIRITViewer_MCPP.dll', Symbols loaded.
'GRACE.exe': Loaded 'C:\Windows\System32\mscoree.dll', No symbols loaded.
'GRACE.exe': Loaded 'C:\Windows\System32\d3dx9_31.dll', No symbols loaded.
'GRACE.exe': Loaded 'C:\Windows\System32\msvcrt.dll', No symbols loaded.
...snip...
First-chance exception at 0x777d3387 in GRACE.exe: 0xC0000005: Access violation writing location 0x00000014.
Unhandled exception at 0x777d7dfe in GRACE.exe: User breakpoint.
The first dll is my Managed C++ wrapper, so it seems to be loading okay. But then I just get that exception before the WinMain function gets called. Any thoughts? I'm using Microsoft Visual Studio .NET 2003 under Windows Vista SP1

Share this post


Link to post
Share on other sites
All I can tell you from that is that it looks like you tried to access an offset from a null pointer, possibly by trying to access a member on a null instance. I imagine that's not helpful.

Share this post


Link to post
Share on other sites
Quote:
Original post by Promit
All I can tell you from that is that it looks like you tried to access an offset from a null pointer, possibly by trying to access a member on a null instance. I imagine that's not helpful.


No, not really - my problem is that the error occurs *before* any of my code runs, so I have no idea how to go about debugging this...

Share this post


Link to post
Share on other sites

This topic is 3486 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this