# Calling .NET dll from C++ 6.0



## AlPennyworth (Jan 23, 2005)

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.


----------



## AlPennyworth (Jan 23, 2005)

I may have found my own answer. I found the article

http://www.dotnet247.com/247reference/msgs/35/178790.aspx

which suggests removing the

System.Windows.Forms.Application.EnableVisualStyles()

and after I did, no Unhandled Exception error.


----------

