Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. Can't connect to or get interfaces of my COM server

Can't connect to or get interfaces of my COM server

Scheduled Pinned Locked Moved COM
questionc++visual-studiocomsysadmin
19 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RFickling
    wrote on last edited by
    #1

    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

    M J M 3 Replies Last reply
    0
    • R RFickling

      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

      M Offline
      M Offline
      Mayur Mahajan
      wrote on last edited by
      #2

      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 ::--

      R J 3 Replies Last reply
      0
      • M Mayur Mahajan

        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 ::--

        R Offline
        R Offline
        RFickling
        wrote on last edited by
        #3

        Vande, Thanks - I'll try your suggestion. Royce

        1 Reply Last reply
        0
        • R RFickling

          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

          J Offline
          J Offline
          Jorgen Sigvardsson
          wrote on last edited by
          #4

          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...

          R 1 Reply Last reply
          0
          • J Jorgen Sigvardsson

            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...

            R Offline
            R Offline
            RFickling
            wrote on last edited by
            #5

            No, but it indirectly invokes CreateInstance() which throws.

            1 Reply Last reply
            0
            • M Mayur Mahajan

              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 ::--

              R Offline
              R Offline
              RFickling
              wrote on last edited by
              #6

              Mayur, Yes, please post your code. I have never tried what you are talking about. Thanks, Royce

              1 Reply Last reply
              0
              • R RFickling

                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

                M Offline
                M Offline
                Milton Karimbekallil
                wrote on last edited by
                #7

                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

                R 1 Reply Last reply
                0
                • M Milton Karimbekallil

                  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

                  R Offline
                  R Offline
                  RoyceF
                  wrote on last edited by
                  #8

                  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

                  M 1 Reply Last reply
                  0
                  • R RoyceF

                    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

                    M Offline
                    M Offline
                    Milton Karimbekallil
                    wrote on last edited by
                    #9

                    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?

                    R 1 Reply Last reply
                    0
                    • M Milton Karimbekallil

                      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?

                      R Offline
                      R Offline
                      RoyceF
                      wrote on last edited by
                      #10

                      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}

                      J M 2 Replies Last reply
                      0
                      • R RoyceF

                        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}

                        J Offline
                        J Offline
                        Jorgen Sigvardsson
                        wrote on last edited by
                        #11

                        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...

                        M 1 Reply Last reply
                        0
                        • M Mayur Mahajan

                          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 ::--

                          J Offline
                          J Offline
                          Jorgen Sigvardsson
                          wrote on last edited by
                          #12

                          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...

                          M 1 Reply Last reply
                          0
                          • J Jorgen Sigvardsson

                            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...

                            M Offline
                            M Offline
                            Mayur Mahajan
                            wrote on last edited by
                            #13

                            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

                            J 1 Reply Last reply
                            0
                            • J Jorgen Sigvardsson

                              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...

                              M Offline
                              M Offline
                              Mayur Mahajan
                              wrote on last edited by
                              #14

                              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

                              J M 2 Replies Last reply
                              0
                              • M Mayur Mahajan

                                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

                                J Offline
                                J Offline
                                Jorgen Sigvardsson
                                wrote on last edited by
                                #15

                                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...

                                1 Reply Last reply
                                0
                                • R RoyceF

                                  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}

                                  M Offline
                                  M Offline
                                  Milton Karimbekallil
                                  wrote on last edited by
                                  #16

                                  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

                                  1 Reply Last reply
                                  0
                                  • M Mayur Mahajan

                                    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

                                    M Offline
                                    M Offline
                                    Milton Karimbekallil
                                    wrote on last edited by
                                    #17

                                    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.

                                    1 Reply Last reply
                                    0
                                    • M Mayur Mahajan

                                      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

                                      J Offline
                                      J Offline
                                      Jorgen Sigvardsson
                                      wrote on last edited by
                                      #18

                                      Are you an error handling fetishist? ;) -- ...Coca Cola, sometimes war...

                                      M 1 Reply Last reply
                                      0
                                      • J Jorgen Sigvardsson

                                        Are you an error handling fetishist? ;) -- ...Coca Cola, sometimes war...

                                        M Offline
                                        M Offline
                                        Mayur Mahajan
                                        wrote on last edited by
                                        #19

                                        Maybe because I create a lot of errors in code and spend twice the time hunting for it ;)

                                        1 Reply Last reply
                                        0
                                        Reply
                                        • Reply as topic
                                        Log in to reply
                                        • Oldest to Newest
                                        • Newest to Oldest
                                        • Most Votes


                                        • Login

                                        • Don't have an account? Register

                                        • Login or register to search.
                                        • First post
                                          Last post
                                        0
                                        • Categories
                                        • Recent
                                        • Tags
                                        • Popular
                                        • World
                                        • Users
                                        • Groups