|
-
May 22nd, 2003, 05:43 PM
#1
CoCreateInstance returns E_NOINTERFACE
I have been trying to solve this for quite a while now and still has no clue. I am hoping some COM expert would be able to help me out here.
Basically, I have a COM server, which is an MFC app. The COM server implements a COM component. Below is what the code looks like.
In myapp.cpp, I have:
BOOL CHllwatchApp::InitInstance()
{
// Initialize OLE libraries
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
SCODE sc = ::CoRegisterClassObject( CLSID_HLLWATCH,
&m_xMyClassFactory,
CLSCTX_LOCAL_SERVER,
REGCLS_MULTI_SEPARATE,
&m_dwRegister );
-
May 23rd, 2003, 07:28 AM
#2
You need to provide more detail. Is the code you posted for the server or for the client? Where is the call to CoCreateInstance()?
Gort...Klaatu, Barada Nikto!
-
May 23rd, 2003, 07:10 PM
#3
I hit the submit button accidently and I posted the entire code in the next post. For some reason, I dont see that post anymore.
Rather than posting the code again, let me try to keep things brief this time.
I have an out of proc COM server, which is an MFC app, which implements a single COM component. I am using MFC COM support (BEGIN_INTERFACE_PART/END_INTERFACE_PART macros in header file and BEGIN_INTERFACE_MAP/END_INTERFACE_MAP macros in CPP file). The COM server implements class factory, in addition to the single COM component. My component does not implement IDispatch interface, only a custom interface. The class that implements my component is derived from CCmdTarget.
I have a C++ client which calls:
HRESULT hr = ::CoCreateInstance(
CLSID_MYCOMSERVER,
NULL,
CLSCTX_LOCAL_SERVER,
IID_IMyInterface,
(LPVOID FAR *) &pComponent );
I traced the call to CoCreateInstance via debugger.
The debugger shows that my class factory's CreateInstance method is called, which successfully creates my component.
Then, QueryInterface method of my component is called 5 times by the COM library: once each for IID_IMarshal, IID_IStdMarshalInfo, IID_IExternalConnection, IID_IUnknown and IID_IMyInterface. The methods return E_NOINTERFACE for the first three interfaces, but return success code (S_OK) for the last two.
The CoCreateInstance eventually return E_NOINTERFACE to the client.
Is it because my COM component does not implement IMarshal, IStdMarshalInfo and IExternalConnection interfaces? How do add their implementation then?
-
May 23rd, 2003, 08:00 PM
#4
Found the cause of the problem. My proxy/stub DLL was not registered properly!
-
July 30th, 2007, 08:53 AM
#5
Re: CoCreateInstance returns E_NOINTERFACE
I know this is an old post, but I am running into the exact same problem. How do you go about registering an exe properly? I have tried regsvr /r, but it doesn't seem to correct the problem. Is there an easy way to register an MFC COM executable?
-
July 30th, 2007, 11:03 PM
#6
RegServer / UnregServer
"If the server is packaged in an EXE module, the application wishing to register the server launches the EXE server with the command-line argument /RegServer or -RegServer (case-insensitive). If the application wishes to unregister the server, it launches the EXE with the command-line argument /UnregServer or -UnregServer." (c) MSDN
If you have also a proxy DLL, you should register it with REGSVR32 as in-proc server.
With best wishes,
Vita
-----------------------
Russian Software Development Network -- http://www.rsdn.ru
-
August 2nd, 2007, 03:55 PM
#7
Re: CoCreateInstance returns E_NOINTERFACE
Thanks for responding - I tried this, but it doesn't seem to correct my problem. I will keep trying. I probably should start over in ATL!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|