I am trying to write a work around to try to get a pointer to an
CLSID_HttpProtocol, declaring a COM wrapper or doing a late binding causes
SystemOutOfMemory errors in mscorlib.dll, so I am trying a work around.
I have a COM server that has a class ComProtocol that declares a method as
follows:
STDMETHODIMP CComCar::GetProtocol(int t, IInternetProtocol** aHandler )
{
HRESULT hr = 0;
if( FAILED(CoCreateInstance(CLSID_HttpProtocol, NULL,
CLSCTX_SERVER, IID_IInternetProtocol, (void**)&aHandler)) )
{
MessageBox(NULL,"FAILED !!!!", "ATL ComCar", MB_OK);
}
else
{
MessageBox(NULL,"Got Protocol", "ATL ComCar", MB_OK);
}
return S_OK;
}
I just want this method to return a pointer to an IIntenetProtocol object
that I can then use in C#.
The idl for this method looks as follows:
[
object,
uuid(B836F694-809C-4F12-A423-BBE031B1BB2A),
dual,
helpstring("IComCar Interface"),
pointer_default(unique)
]
interface IComCar : IUnknown
{
[helpstring("method GetProtocol")] HRESULT GetProtocol([in] int
test, [out, retval] IInternetProtocol** aProtocol );
};
I import this dll using the Visual Studio Add Reference tool. Then I can
call this method from C# as follows:
ComCarClass c = new ComCarClass();
IInternetProtocol test = c.GetProtocol( 20 );
GetProtocol gets called fine and the CoCreateInstance() gets called
successfully. Unfortunately GetProtocol always returns null. Can someone
educate me as to what I am doing wrong? Is the declaration of my return
type incorrect? How can I resolve this problem?
Thank you in advance
You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.