failed accessing COM method after successful cocreateinstance.
-
after successful cocreateinstance. When i access a method in class it returns the error: "First-chance exception in XYZ.exe (OLEAUT32.DLL): 0xC0000005: Access Violation". By step by step debugging i found it gives this error while calling // make the call SCODE sc = m_lpDispatch->Invoke(dwDispID, IID_NULL, 0, wFlags, &dispparams, pvarResult, &excepInfo, &nArgErr); in OLEDIST2.CPP file. please help
-
after successful cocreateinstance. When i access a method in class it returns the error: "First-chance exception in XYZ.exe (OLEAUT32.DLL): 0xC0000005: Access Violation". By step by step debugging i found it gives this error while calling // make the call SCODE sc = m_lpDispatch->Invoke(dwDispID, IID_NULL, 0, wFlags, &dispparams, pvarResult, &excepInfo, &nArgErr); in OLEDIST2.CPP file. please help
hi, could you please be more specific on this? 1) check you called the CoInitialize() and the component is register in the machine and the instance is created properly. 2)check the component created and being accessed are on the same thread.
^-^ @|@ - redCat
-
after successful cocreateinstance. When i access a method in class it returns the error: "First-chance exception in XYZ.exe (OLEAUT32.DLL): 0xC0000005: Access Violation". By step by step debugging i found it gives this error while calling // make the call SCODE sc = m_lpDispatch->Invoke(dwDispID, IID_NULL, 0, wFlags, &dispparams, pvarResult, &excepInfo, &nArgErr); in OLEDIST2.CPP file. please help
Did you check always HRESULT return values? Could you please post the relevant code? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Did you check always HRESULT return values? Could you please post the relevant code? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]Hi this is the code segment: CLSIDFromString(L"{AF684922-D245-11D3-8DE8-00A024ACAB85}", &CLSID_MSDiscMasterObj); CLSIDFromString(L"{AF684924-D245-11D3-8DE8-00A024ACAB85}", &IID_IDiscMaster); hr = CoInitialize(NULL); if(SUCCEEDED(hr)) { hr = CoCreateInstance(CLSID_MSDiscMasterObj, NULL, CLSCTX_LOCAL_SERVER, IID_IDiscMaster, (void**)&IV2WObj); if(SUCCEEDED(hr)) { VARIANT ReturnValue; ReturnValue = IV2WObj->MakeConnection(1,"VPCI",65536,0); } } it fails at method call. CoInitialize successful, cocreateinstance is also successful. the COM object is obtained as an executable. Which is sucessfully launched after executing cocreateinstance. please help
-
hi, could you please be more specific on this? 1) check you called the CoInitialize() and the component is register in the machine and the instance is created properly. 2)check the component created and being accessed are on the same thread.
^-^ @|@ - redCat
-
Hi this is the code segment: CLSIDFromString(L"{AF684922-D245-11D3-8DE8-00A024ACAB85}", &CLSID_MSDiscMasterObj); CLSIDFromString(L"{AF684924-D245-11D3-8DE8-00A024ACAB85}", &IID_IDiscMaster); hr = CoInitialize(NULL); if(SUCCEEDED(hr)) { hr = CoCreateInstance(CLSID_MSDiscMasterObj, NULL, CLSCTX_LOCAL_SERVER, IID_IDiscMaster, (void**)&IV2WObj); if(SUCCEEDED(hr)) { VARIANT ReturnValue; ReturnValue = IV2WObj->MakeConnection(1,"VPCI",65536,0); } } it fails at method call. CoInitialize successful, cocreateinstance is also successful. the COM object is obtained as an executable. Which is sucessfully launched after executing cocreateinstance. please help
-
try sending the second parameter as widechar L"VPCI" or as BSTR. and if the last parameter is string, do not send as 0. try sending NULL or empty string L"".
^-^ @|@ - redCat
Hi redCat, Actually there are around 10 to 20 member functions in that class. I couldn't able to call any one of the functions. even the one which doesn't have any arguments. The probable reason seems to me is like the class object pointer returned by cocreateinstance(returns successfully) is accessing a memory location which is not part of the process memory area. But iam not sure. even if this is the problem i don't know how to resolve it?. please help
-
Hi redCat, Actually there are around 10 to 20 member functions in that class. I couldn't able to call any one of the functions. even the one which doesn't have any arguments. The probable reason seems to me is like the class object pointer returned by cocreateinstance(returns successfully) is accessing a memory location which is not part of the process memory area. But iam not sure. even if this is the problem i don't know how to resolve it?. please help
Some updates which i verified. I could check the typelib registration process in REGISTRY and found it to be perfect according to the procedure shown @ link : http://blogs.msdn.com/larryosterman/archive/2006/01.aspx "Minimal COM object registration" "COM registration for cross process access" "COM registration if you need a typelib" "COM registration of PROGIDs." "What registry entries are needed to register a COM object." but still the problem persists please help
-
after successful cocreateinstance. When i access a method in class it returns the error: "First-chance exception in XYZ.exe (OLEAUT32.DLL): 0xC0000005: Access Violation". By step by step debugging i found it gives this error while calling // make the call SCODE sc = m_lpDispatch->Invoke(dwDispID, IID_NULL, 0, wFlags, &dispparams, pvarResult, &excepInfo, &nArgErr); in OLEDIST2.CPP file. please help
-
You call your function with bad parameters. Make correct bstr and so on. :doh:
Press F1 for help or google it. Greetings from Germany
Hi all, thanks for your time. the problem is solved at my end. Problem lies in importing the type library (tlb) of the COM server in to my client application. Because of which, object gets a corrupted pointer. when a member function is called it gives ACCESS VOILATION error. I actually imported the typelibrary in my Visual C++ application using "CLASS WIZARD" as mentioned @ MSDN link: http://msdn.microsoft.com/en-us/library/aa279228(VS.60).aspx Which actually caused the above problem. Later I found by importing typelibrary using simple #import "xyz.tlb" it generates two files .tlh and .tli files which also contains all the classes and member function definitions. When i used these files in my project it worked. Sorry for bothering you...... thanks and regards sandeep r.