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. failed accessing COM method after successful cocreateinstance.

failed accessing COM method after successful cocreateinstance.

Scheduled Pinned Locked Moved COM
helpc++comtutorial
10 Posts 4 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
    rsandeepu
    wrote on last edited by
    #1

    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

    G C K 3 Replies Last reply
    0
    • R rsandeepu

      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

      G Offline
      G Offline
      guestcat
      wrote on last edited by
      #2

      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

      R 1 Reply Last reply
      0
      • R rsandeepu

        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

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

        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]

        R 1 Reply Last reply
        0
        • C CPallini

          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]

          R Offline
          R Offline
          rsandeepu
          wrote on last edited by
          #4

          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

          G 1 Reply Last reply
          0
          • G guestcat

            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

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

            Hi, i checked coInitialize and cocreateinstance they return successfull... How could i check wheter the component created and being accessed are on same thread? please help.

            1 Reply Last reply
            0
            • R rsandeepu

              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

              G Offline
              G Offline
              guestcat
              wrote on last edited by
              #6

              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

              R 1 Reply Last reply
              0
              • G guestcat

                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

                R Offline
                R Offline
                rsandeepu
                wrote on last edited by
                #7

                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

                R 1 Reply Last reply
                0
                • R rsandeepu

                  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

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

                  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

                  1 Reply Last reply
                  0
                  • R rsandeepu

                    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

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

                    You call your function with bad parameters. Make correct bstr and so on. :doh:

                    Press F1 for help or google it. Greetings from Germany

                    R 1 Reply Last reply
                    0
                    • K KarstenK

                      You call your function with bad parameters. Make correct bstr and so on. :doh:

                      Press F1 for help or google it. Greetings from Germany

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

                      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.

                      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