IClassFactory::CreateInstance return E_INVALIDARG (0x80070057) but the server's method return S_OK

0

I have 2 processes to use com rpc in a web browser application.The com server register the class defined by myself,and the com client get the IClassFactory use CoGetClassObject,and then call the method CreateInstance,which returns E_INVALIDARG.but in the server process, i can see it returns S_OK.

There are many win7 and win10 system, and only few win7 system have this problem. and on this problem system I have write a small mock com client program to communicate with the real com server,and it works ok.

the client code like this

while (FAILED(hr) || !class_factory) {
Sleep(500);
hr = CoGetClassObject(CLSID_BrowserContainer, CLSCTX_LOCAL_SERVER, NULL,
                      IID_IClassFactory, (LPVOID*)&class_factory);
}

if (class_factory) {
HRESULT result = class_factory->CreateInstance(NULL, IID_IDispatch,
                                               (PVOID*)&browser_container_);

the result is E_INVALIDARG.and when i use IID_IUnknown replace the IID_IDispatch, it returns S_OK.but when use QueryInterface to get the IDispatch, it returns error too.

anyone who can help me will be very grateful.

c++
com
rpc
atl
asked on Stack Overflow Aug 2, 2019 by llint • edited Aug 2, 2019 by llint

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0