Can't connect to or get interfaces of my COM server
-
Hi, How do I connect to my COM server, written with VS C++ 7.1 (2003). I have been writing COM servers and clients for about 5 years now. For the past 3 or 4 years, I have used the #import statement and the __uuidof operator with smart pointers to connect to my servers with no problem. Now when I try to use __uuidof() in a VS 7.1 client, it throws an exception "Class not registered" when it clearly is registered. Anyone know what's going on? Thanks, Royce
-
Hi, How do I connect to my COM server, written with VS C++ 7.1 (2003). I have been writing COM servers and clients for about 5 years now. For the past 3 or 4 years, I have used the #import statement and the __uuidof operator with smart pointers to connect to my servers with no problem. Now when I try to use __uuidof() in a VS 7.1 client, it throws an exception "Class not registered" when it clearly is registered. Anyone know what's going on? Thanks, Royce
A better and safe way other than smart pointers is invoking the COM runtime and obtaining interface explicitly. Compile the IDL file to get a '.h' and '.c' file. Using CoCreateInstance and QueryInterface methods you can get interface without breaking the code in VC++ 6.0 as well as 7.0. If you are hardcore C++ programmer I suggest you use this method rather than smart pointers. If the same problem persists with this method then it really is a problem I can get with. You can get lotsa tuts on codeproject to using COM without smart pointers. If u need the code lemme know, I hav efunctional client-server code running. May ur problem be solved with this!!! --:: VANDE MATARAM ::--
-
A better and safe way other than smart pointers is invoking the COM runtime and obtaining interface explicitly. Compile the IDL file to get a '.h' and '.c' file. Using CoCreateInstance and QueryInterface methods you can get interface without breaking the code in VC++ 6.0 as well as 7.0. If you are hardcore C++ programmer I suggest you use this method rather than smart pointers. If the same problem persists with this method then it really is a problem I can get with. You can get lotsa tuts on codeproject to using COM without smart pointers. If u need the code lemme know, I hav efunctional client-server code running. May ur problem be solved with this!!! --:: VANDE MATARAM ::--
-
Hi, How do I connect to my COM server, written with VS C++ 7.1 (2003). I have been writing COM servers and clients for about 5 years now. For the past 3 or 4 years, I have used the #import statement and the __uuidof operator with smart pointers to connect to my servers with no problem. Now when I try to use __uuidof() in a VS 7.1 client, it throws an exception "Class not registered" when it clearly is registered. Anyone know what's going on? Thanks, Royce
RFickling wrote: Now when I try to use __uuidof() in a VS 7.1 client, it throws an exception "Class not registered" when it clearly is registered. Uh.. __uuidof doesn't throw anything. :confused: -- ...Coca Cola, sometimes war...
-
RFickling wrote: Now when I try to use __uuidof() in a VS 7.1 client, it throws an exception "Class not registered" when it clearly is registered. Uh.. __uuidof doesn't throw anything. :confused: -- ...Coca Cola, sometimes war...
-
A better and safe way other than smart pointers is invoking the COM runtime and obtaining interface explicitly. Compile the IDL file to get a '.h' and '.c' file. Using CoCreateInstance and QueryInterface methods you can get interface without breaking the code in VC++ 6.0 as well as 7.0. If you are hardcore C++ programmer I suggest you use this method rather than smart pointers. If the same problem persists with this method then it really is a problem I can get with. You can get lotsa tuts on codeproject to using COM without smart pointers. If u need the code lemme know, I hav efunctional client-server code running. May ur problem be solved with this!!! --:: VANDE MATARAM ::--
-
Hi, How do I connect to my COM server, written with VS C++ 7.1 (2003). I have been writing COM servers and clients for about 5 years now. For the past 3 or 4 years, I have used the #import statement and the __uuidof operator with smart pointers to connect to my servers with no problem. Now when I try to use __uuidof() in a VS 7.1 client, it throws an exception "Class not registered" when it clearly is registered. Anyone know what's going on? Thanks, Royce
There is nothing wrong in using smart pointers and
__uuidof
for accessing com object in vc7. it shud work fine. there shud be something else is wrong. u created the com as a vc7 atl project and what type of .net project was ur client app? rgds..mil10 -
There is nothing wrong in using smart pointers and
__uuidof
for accessing com object in vc7. it shud work fine. there shud be something else is wrong. u created the com as a vc7 atl project and what type of .net project was ur client app? rgds..mil10Yes, this project was created using VS 7.1. Using the project wizard, I created an ATL project, Attributed = false, Support MFC = true, Support COM+ = true, and Support Component Registrar = true. Using the Add Class wizard, I then added a ATL Simple Object with defaults. I don't see anything wrong with what I did. Royce
-
Yes, this project was created using VS 7.1. Using the project wizard, I created an ATL project, Attributed = false, Support MFC = true, Support COM+ = true, and Support Component Registrar = true. Using the Add Class wizard, I then added a ATL Simple Object with defaults. I don't see anything wrong with what I did. Royce
thats fine.. what type of project was ur client app? whether it is a Console App(.net), win32 console app or an MFC appwizard exe?
-
thats fine.. what type of project was ur client app? whether it is a Console App(.net), win32 console app or an MFC appwizard exe?
The client is a MFC App wizard dialog-type application. My code is below. I use the #import statement: #import "ComServer.dll" I define a member variable to hold a pointer to the interface in my dialog's header: ComServerLib::IMakeKeyPtr m_ptrMakeKey; This statement fails with a 80040154 error code: "Class not registered" m_ptrMakeKey = ComServerLib::IMakeKeyPtr(__uuidof(ComServerLib::IMakeKey)); I have used this method of connecting to COM objects for years. I have no clue as to why it is failing. My registry shows the following keys: The following registry keys show that the required registration has been done. These keys were copied from the registry immediately after a successful build of the COM server. The 'MakeKey Class' is registered: HKEY_CLASSES_ROOT\CLSID\{1BB2A094-1C9E-4B3B-99CF-A92CD5E762A3} The ComServer 1.0 Type Library is registered: HKEY_CLASSES_ROOT\TypeLib\{2748E284-3101-4CB7-AF16-C52E02E2A71A} The IMakeKey Interface is registered: HKEY_CLASSES_ROOT\Interface\{1B68E9F2-D8F6-42C0-9D12-90255695E6DE}
-
The client is a MFC App wizard dialog-type application. My code is below. I use the #import statement: #import "ComServer.dll" I define a member variable to hold a pointer to the interface in my dialog's header: ComServerLib::IMakeKeyPtr m_ptrMakeKey; This statement fails with a 80040154 error code: "Class not registered" m_ptrMakeKey = ComServerLib::IMakeKeyPtr(__uuidof(ComServerLib::IMakeKey)); I have used this method of connecting to COM objects for years. I have no clue as to why it is failing. My registry shows the following keys: The following registry keys show that the required registration has been done. These keys were copied from the registry immediately after a successful build of the COM server. The 'MakeKey Class' is registered: HKEY_CLASSES_ROOT\CLSID\{1BB2A094-1C9E-4B3B-99CF-A92CD5E762A3} The ComServer 1.0 Type Library is registered: HKEY_CLASSES_ROOT\TypeLib\{2748E284-3101-4CB7-AF16-C52E02E2A71A} The IMakeKey Interface is registered: HKEY_CLASSES_ROOT\Interface\{1B68E9F2-D8F6-42C0-9D12-90255695E6DE}
Royce Fickling wrote: uuidof(ComServerLib::IMakeKey); Dude, you should be using
__uuidof(<class name here>)
. You are using the interface name, and hence you are trying to create a COM object using an IID. It's the CLSID you want... ;) -- ...Coca Cola, sometimes war... -
A better and safe way other than smart pointers is invoking the COM runtime and obtaining interface explicitly. Compile the IDL file to get a '.h' and '.c' file. Using CoCreateInstance and QueryInterface methods you can get interface without breaking the code in VC++ 6.0 as well as 7.0. If you are hardcore C++ programmer I suggest you use this method rather than smart pointers. If the same problem persists with this method then it really is a problem I can get with. You can get lotsa tuts on codeproject to using COM without smart pointers. If u need the code lemme know, I hav efunctional client-server code running. May ur problem be solved with this!!! --:: VANDE MATARAM ::--
Mayur Mahajan wrote: A better and safe way other than smart pointers is invoking the COM runtime and obtaining interface explicitly. How is that safer? :confused: Raw interface pointers are almost always the source of memory leaks when dealing with COM. Raw interface pointers are for C programmers only, IMO. Heck, COM is hard even with smart pointers. Why make it harder by using raw pointers? :) -- ...Coca Cola, sometimes war...
-
Mayur Mahajan wrote: A better and safe way other than smart pointers is invoking the COM runtime and obtaining interface explicitly. How is that safer? :confused: Raw interface pointers are almost always the source of memory leaks when dealing with COM. Raw interface pointers are for C programmers only, IMO. Heck, COM is hard even with smart pointers. Why make it harder by using raw pointers? :) -- ...Coca Cola, sometimes war...
I know COM is hard. And pointers in C++ is something people like to stay away :(. But I'm a c++ fan and like to get things done the hard way! Also using smart pointers is something like setting references in VB and too 'unornamented' ;P method to understand the workings of COM. /* And memory is sure to leak out of most progs unless u code with a cool head be it COM or C++ objects */ coding n debugging; two sides of same coin
-
Royce Fickling wrote: uuidof(ComServerLib::IMakeKey); Dude, you should be using
__uuidof(<class name here>)
. You are using the interface name, and hence you are trying to create a COM object using an IID. It's the CLSID you want... ;) -- ...Coca Cola, sometimes war...Royce Fickling wrote: uuidof(ComServerLib::IMakeKey); U asked Royce to use __uuidof() instead of IID; Does this return the default interface? By this technique how can I query other interfaces of my COM object? Fortune favours the naive
-
Royce Fickling wrote: uuidof(ComServerLib::IMakeKey); U asked Royce to use __uuidof() instead of IID; Does this return the default interface? By this technique how can I query other interfaces of my COM object? Fortune favours the naive
Mayur Mahajan wrote: Does this return the default interface? No. In the microsoft compilers, structs and classes can be given compile time attributes. One of these compile time attributes is GUIDs. To interfaces, the IID is set as attribute. So __uuidof(IInterface) is equivalent to IID_IInterface. Mayur Mahajan wrote: By this technique how can I query other interfaces of my COM object?
pUnk->QueryInterface(__uuidof(IInterface), (void**)&pInterface);
It's not portable, but hey, who cares? I don't do COM development for anything but windows, and my compiler of choice for the windows platform is the one that comes from Redmond. :) -- ...Coca Cola, sometimes war... -
The client is a MFC App wizard dialog-type application. My code is below. I use the #import statement: #import "ComServer.dll" I define a member variable to hold a pointer to the interface in my dialog's header: ComServerLib::IMakeKeyPtr m_ptrMakeKey; This statement fails with a 80040154 error code: "Class not registered" m_ptrMakeKey = ComServerLib::IMakeKeyPtr(__uuidof(ComServerLib::IMakeKey)); I have used this method of connecting to COM objects for years. I have no clue as to why it is failing. My registry shows the following keys: The following registry keys show that the required registration has been done. These keys were copied from the registry immediately after a successful build of the COM server. The 'MakeKey Class' is registered: HKEY_CLASSES_ROOT\CLSID\{1BB2A094-1C9E-4B3B-99CF-A92CD5E762A3} The ComServer 1.0 Type Library is registered: HKEY_CLASSES_ROOT\TypeLib\{2748E284-3101-4CB7-AF16-C52E02E2A71A} The IMakeKey Interface is registered: HKEY_CLASSES_ROOT\Interface\{1B68E9F2-D8F6-42C0-9D12-90255695E6DE}
Hi Royce.. as Jörgen Sigvardsson already posted u shud have used the CoClass name instead of an Interface name in
ComServerLib::IMakeKeyPtr(__uuidof(ComServerLib::IMakeKey));
. Here replace IMakeKey with ur coclass name. chk idl for the coclass name. rgds...mil10 -
Royce Fickling wrote: uuidof(ComServerLib::IMakeKey); U asked Royce to use __uuidof() instead of IID; Does this return the default interface? By this technique how can I query other interfaces of my COM object? Fortune favours the naive
An addition to Jörgen Sigvardsson's reply: chk the .tlh and and the implimentation file .tli for any detailed info. these files will be there in ur debug folder.
-
I know COM is hard. And pointers in C++ is something people like to stay away :(. But I'm a c++ fan and like to get things done the hard way! Also using smart pointers is something like setting references in VB and too 'unornamented' ;P method to understand the workings of COM. /* And memory is sure to leak out of most progs unless u code with a cool head be it COM or C++ objects */ coding n debugging; two sides of same coin
Are you an error handling fetishist? ;) -- ...Coca Cola, sometimes war...
-
Are you an error handling fetishist? ;) -- ...Coca Cola, sometimes war...
Maybe because I create a lot of errors in code and spend twice the time hunting for it ;)