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

CoCreateInstance failing

Scheduled Pinned Locked Moved COM
c++announcementcsharpcomdebugging
9 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.
  • K Offline
    K Offline
    KellyR
    wrote on last edited by
    #1

    Hi, My dev environment is VC++ .NET 2005 with MFC. So here's the deal: From my main application, I load up a number of dlls as COM objects with CreateInstance. - These dlls are all registered. - Everything works perfectly when the dlls are compiled in debug mode. - When the dlls are compiled in release mode, CreateInstance fails to load one of the dlls from my main application, returning error -2147221164, CLASS_NOT_REGISTERED. This only happens with one dll - if I replace that dll with a debug version of the same dll, everything works fine. I don't have any #ifdef _DEBUG sections in the dll code. Has anyone seen this before or know what might be wrong?

    KR

    R C J Q 4 Replies Last reply
    0
    • K KellyR

      Hi, My dev environment is VC++ .NET 2005 with MFC. So here's the deal: From my main application, I load up a number of dlls as COM objects with CreateInstance. - These dlls are all registered. - Everything works perfectly when the dlls are compiled in debug mode. - When the dlls are compiled in release mode, CreateInstance fails to load one of the dlls from my main application, returning error -2147221164, CLASS_NOT_REGISTERED. This only happens with one dll - if I replace that dll with a debug version of the same dll, everything works fine. I don't have any #ifdef _DEBUG sections in the dll code. Has anyone seen this before or know what might be wrong?

      KR

      R Offline
      R Offline
      Royaltvk
      wrote on last edited by
      #2

      Hi Kelly, iam also facing same problem. My CoCreateinstance is failed to return correct pointer. It is just retuned the error code -2147221164. I dont know what to do.... Please advice us to resolve this problem.

      1 Reply Last reply
      0
      • K KellyR

        Hi, My dev environment is VC++ .NET 2005 with MFC. So here's the deal: From my main application, I load up a number of dlls as COM objects with CreateInstance. - These dlls are all registered. - Everything works perfectly when the dlls are compiled in debug mode. - When the dlls are compiled in release mode, CreateInstance fails to load one of the dlls from my main application, returning error -2147221164, CLASS_NOT_REGISTERED. This only happens with one dll - if I replace that dll with a debug version of the same dll, everything works fine. I don't have any #ifdef _DEBUG sections in the dll code. Has anyone seen this before or know what might be wrong?

        KR

        C Offline
        C Offline
        CPallini
        wrote on last edited by
        #3

        KellyR wrote:

        I don't have any #ifdef _DEBUG sections in the dll code.

        And haven't you ASSERT at all (or have you only harmless ASSERT, i.e. without meaningful code inside)? :)

        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

        K 1 Reply Last reply
        0
        • K KellyR

          Hi, My dev environment is VC++ .NET 2005 with MFC. So here's the deal: From my main application, I load up a number of dlls as COM objects with CreateInstance. - These dlls are all registered. - Everything works perfectly when the dlls are compiled in debug mode. - When the dlls are compiled in release mode, CreateInstance fails to load one of the dlls from my main application, returning error -2147221164, CLASS_NOT_REGISTERED. This only happens with one dll - if I replace that dll with a debug version of the same dll, everything works fine. I don't have any #ifdef _DEBUG sections in the dll code. Has anyone seen this before or know what might be wrong?

          KR

          J Offline
          J Offline
          john5632
          wrote on last edited by
          #4

          Could you show me your code?

          K 1 Reply Last reply
          0
          • C CPallini

            KellyR wrote:

            I don't have any #ifdef _DEBUG sections in the dll code.

            And haven't you ASSERT at all (or have you only harmless ASSERT, i.e. without meaningful code inside)? :)

            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

            K Offline
            K Offline
            KellyR
            wrote on last edited by
            #5

            The only asserts I have are ASSERT(0).

            KR

            C 1 Reply Last reply
            0
            • J john5632

              Could you show me your code?

              K Offline
              K Offline
              KellyR
              wrote on last edited by
              #6

              Well it's just a CreateInstance call with a CLSID. It's like this: m_Server.CreateInstance(SERVERLib::CLSID_Server); And the CLSID passed into the function is correct in both debug and release versions. The dll is registered, I just don't understand why it won't load in release mode.

              KR

              1 Reply Last reply
              0
              • K KellyR

                The only asserts I have are ASSERT(0).

                KR

                C Offline
                C Offline
                CPallini
                wrote on last edited by
                #7

                Have a look at http://www.flounder.com/debug_release.htm[^]. :)

                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

                K 1 Reply Last reply
                0
                • K KellyR

                  Hi, My dev environment is VC++ .NET 2005 with MFC. So here's the deal: From my main application, I load up a number of dlls as COM objects with CreateInstance. - These dlls are all registered. - Everything works perfectly when the dlls are compiled in debug mode. - When the dlls are compiled in release mode, CreateInstance fails to load one of the dlls from my main application, returning error -2147221164, CLASS_NOT_REGISTERED. This only happens with one dll - if I replace that dll with a debug version of the same dll, everything works fine. I don't have any #ifdef _DEBUG sections in the dll code. Has anyone seen this before or know what might be wrong?

                  KR

                  Q Offline
                  Q Offline
                  QuickDeveloper
                  wrote on last edited by
                  #8

                  I think you need to have the MFC Dlls for VS2005 in the system where you are testing the app. However if you are testing it in the same system where VS 2005 is installed there is some other problem

                  "Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"

                  1 Reply Last reply
                  0
                  • C CPallini

                    Have a look at http://www.flounder.com/debug_release.htm[^]. :)

                    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

                    K Offline
                    K Offline
                    KellyR
                    wrote on last edited by
                    #9

                    Can I pass the registry key directly into CreateInstance instead of using a CLSID? How would I do that? I have the registry key as a string but I can't find a way to convert that string to a CLSID or pass it to CreateInstance. Thanks!

                    KR

                    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