-
March 17th, 2005, 05:14 PM
#1
Calling C# dll in C++ 6.0 Application
This is a little difficult to explain. I created a dll in .NET using C# and I need to call this dll from a Visual C++ 6.0 application. I am programmatically calling the regasm.exe as I am getting the installroot registry key, finding the folder, get the exe, then doing a CreateProcess and it seems to function correctly.
My problem is in the call to the C# dll, after a couple of times, it seems to GPF but the c++ 6.0 application continues to run w/o any problems. I can continue to hit the button, launch the C# dll, when it returns, it gets another GPF and the cycle goes on.
Here is a basic outline of my 6.0 c++ function:
void functionname
{
// Initialize COM.
HRESULT hr = CoInitialize(NULL);
// Create the interface pointer.
IManageInterfacePtr pIInterface(__uuidof(ManagerInterface));
// Call the Add method.
pIInterface->LaunchRSSDLL(string, string, string);
pIInterface->Dispose(); <--this is from trying something with the C# dll
pIInterface->Release();
// Uninitialize COM.
CoUninitialize();
}
I have put try/catch inside this function, around the call to this function, inside my C# DLL COM interface, and I still cannot find where the gpf is occurring. This is my first C# dll so be please be patient if I so kind of idiotic in describing this. Any ideas on what I may be missing? Any ideas on what I can look at? I have run out of ideas.
"Have you ever danced with the devil in the pale moonlight" - Jack Nicholson as Joker, Batman
-
March 18th, 2005, 05:17 AM
#2
Re: Calling C# dll in C++ 6.0 Application
Make sure pIInterface is really released before you call CoUninitialise(). Otherwise you'll get a crash from the smart pointer destructor. To verify that this is indeed your problem add pIInterface = NULL; before CoUninitialise().
Har Har
-
March 18th, 2005, 09:12 AM
#3
Re: Calling C# dll in C++ 6.0 Application
It appears as though pIInterface is being fully released. I implemented the NULL as you suggested and it performed the call, then the CoUnitialize and eventually, I will see a gpf. The exact error message is:
Unhandled Exception in Application.exe (NTDLL.DLL): 0xC015000F: (no name)
and I do see some
First-chance exception in Coyote.exe (KERNEL32.DLL): 0xE0434F4D: (no name).
in the debug viewer in studio. Any additional suggestions?
"Have you ever danced with the devil in the pale moonlight" - Jack Nicholson as Joker, Batman
-
March 18th, 2005, 10:11 AM
#4
Re: Calling C# dll in C++ 6.0 Application
First of all, those are not GPFs.
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
-
March 18th, 2005, 11:14 AM
#5
Re: Calling C# dll in C++ 6.0 Application
You are absolutely true- they are not GPFs. They are unhandled exceptions, I apologize for my mistake.
I found the answer to my problem:
http://www.dotnet247.com/247referenc...35/178790.aspx
I removed the EnableVisualStyles() call from my .NET dll and the unhandled exception has not been encountered.
"Have you ever danced with the devil in the pale moonlight" - Jack Nicholson as Joker, Batman
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|