I have a C++ program that's calling a .Net DLL that's been set up as a
COM server. From C++ I call:
INoteTaker *cpi = NULL;
CoInitialize(NULL);
HRESULT hr = CoCreateInstance(CLSID_NoteTaker,
NULL, CLSCTX_INPROC_SERVER,
IID_INoteTaker, reinterpret_cast<void**>(&cpi));
And in the C# I've got a simple constructor:
namespace SpecialistNoteTaker
{
[Guid("C6AC0ADE-2616-48cf-B57F-354A566E8D02")]
public class NoteTaker : INoteTaker
{
public NoteTaker()
{
Console.WriteLine("Constructor called.");
}
}
}
The problem is that it takes a long, long time (8 seconds) for the
constructor to get called and the CoCreateInstance to return. The
hangup seems to be when loading DLL's for the Framework:
'SNTTest.exe': Loaded
'C:\projects\pr1\COMInterop\SpecialistNoteTaker\bin\Debug\SpecialistNoteTaker.dll',
No native symbols in symbol file. 'SNTTest.exe': Loaded
'C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\mscorjit.dll', No symbols
loaded.
[Up to here, loads quickly then a loooong pause]
'SNTTest.exe': Loaded
'C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\diasymreader.dll', No
symbols loaded.
[And then everthing else loads quickly]
I need a way to start this COM application very quickly and avoid this
long pause. It's not so important that the COM be started fast, but I
can't have the C++ waiting around for the framework to get itself
bootstrapped.
Starting the application directly from the debugger (not through COM)
is very fast.
The C++ is most definately not thread-safe. There's a mix of C++ and C
in the body of the code and I don't want to go that route.
Suggestions?
|