I wrote a C# .NET COM component which is then called from a C# front end. However, it also needs to work from an old Visual C++ 6 client app too. This works fine when it is all installed on the same machine but I need to call it remotely. This fails with a class not registered error. The server where the component is installed is a Windows 7 64bit machine and the client is 32bit XP if that makes any difference. Because my code was quite complex, I found a simple example on the internet. It's basically the same code as mine but fails in exactly the same way. The example is here :
http://www.codeproject.com/Articles/12673/Calling-Managed-NET-C-COM-Objects-from-Unmanaged-C
That example client works fine on the same machine. I changed the client code to this (to run it remotely):
CoInitialize(NULL);
COSERVERINFO si;
MULTI_QI qi;
COAUTHINFO cai = { RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, 0, RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE,0, EOAC_NONE };
si.dwReserved1 = 0;
si.pwszName =L"{machine name}";
si.pAuthInfo = &cai;
si.dwReserved2 = 0;
qi.pIID = &MyInterop::IID_IMyDotNetInterface;
qi.pItf = NULL;
qi.hr = 1;
HRESULT hr = CoCreateInstanceEx(MyInterop::CLSID_MyDotNetClass,NULL,CLSCTX_REMOTE_SERVER ,&si,1,&qi);//CLSCTX_SERVER
if (SUCCEEDED(hr))
{
MyInterop::IMyDotNetInterfacePtr* pCom = new MyInterop::IMyDotNetInterfacePtr;
pCom->Attach((MyInterop::IMyDotNetInterface*)qi.pItf);
HRESULT hRes = (*pCom)->ShowCOMDialog();
delete pCom;
}
CoUninitialize();
However, it fails on the CoCreateInstanceEx with a HRESULT of 0x80040154 (Class not registered). The same client code above works fine when remotely calling a COM component written in Visual C++ 6.
Any ideas why this fails?