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. problem access com methods - unhandled exception [modified]

problem access com methods - unhandled exception [modified]

Scheduled Pinned Locked Moved COM
helpcomtutorial
3 Posts 3 Posters 2 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.
  • V Offline
    V Offline
    Vijjuuu
    wrote on last edited by
    #1

    i am stuck with one kind of problem when using COM . below are the details , i have written a class which has a com object as a member variable. i have different member function one will create the com object other members will access the functions of the com object. the problem comes when i am trying to access function of the com . here is sample example of my code class CMyclass { com variable; public: void createcomobject(); void accessfunctionofcomobject(); }; CMyclass::void createcomobject() { ::CoInitialize() CoCreateInstance(......); // Every this is fine and i was able to create the com object successuflly .. // every thing is fine and successfull. // successfull creates com object using cocreateinstance.. and we can call the memebers function of interface variable->method(); // successfully calls the members } CMYclass::accessfunctionofcomobject() { // application crashes when try to access com object functions variable->method(); // UNHANDLED EXPECTION } CMYclass *ptr; // This is gobal pointer variable.. // fun1 is a gobal function void fun1() { ptr->createcomobject(); } // fun2 is a gobal function void fun2() { ptr->obj.accessfunctionofcomobject(); //calling this funciton makes crash. } void main() { ptr = new CMYclass(); fun1(); // This function calls creates successful com object inside a class object. fun2(); // This function calls makes crash... } i want to know why the unhandled exception is raising

    modified on Thursday, November 19, 2009 11:53 PM

    J C 2 Replies Last reply
    0
    • V Vijjuuu

      i am stuck with one kind of problem when using COM . below are the details , i have written a class which has a com object as a member variable. i have different member function one will create the com object other members will access the functions of the com object. the problem comes when i am trying to access function of the com . here is sample example of my code class CMyclass { com variable; public: void createcomobject(); void accessfunctionofcomobject(); }; CMyclass::void createcomobject() { ::CoInitialize() CoCreateInstance(......); // Every this is fine and i was able to create the com object successuflly .. // every thing is fine and successfull. // successfull creates com object using cocreateinstance.. and we can call the memebers function of interface variable->method(); // successfully calls the members } CMYclass::accessfunctionofcomobject() { // application crashes when try to access com object functions variable->method(); // UNHANDLED EXPECTION } CMYclass *ptr; // This is gobal pointer variable.. // fun1 is a gobal function void fun1() { ptr->createcomobject(); } // fun2 is a gobal function void fun2() { ptr->obj.accessfunctionofcomobject(); //calling this funciton makes crash. } void main() { ptr = new CMYclass(); fun1(); // This function calls creates successful com object inside a class object. fun2(); // This function calls makes crash... } i want to know why the unhandled exception is raising

      modified on Thursday, November 19, 2009 11:53 PM

      J Offline
      J Offline
      Jonathan Davies
      wrote on last edited by
      #2

      Perhaps you are creating the COM object using one interface e.g. IUnknown or IMyInterface1 then, in your method, calling using another interface, say, IMyMethods interface which is not yet initialised? It's a bit hard to say any more without seeing more detail from yourself.

      1 Reply Last reply
      0
      • V Vijjuuu

        i am stuck with one kind of problem when using COM . below are the details , i have written a class which has a com object as a member variable. i have different member function one will create the com object other members will access the functions of the com object. the problem comes when i am trying to access function of the com . here is sample example of my code class CMyclass { com variable; public: void createcomobject(); void accessfunctionofcomobject(); }; CMyclass::void createcomobject() { ::CoInitialize() CoCreateInstance(......); // Every this is fine and i was able to create the com object successuflly .. // every thing is fine and successfull. // successfull creates com object using cocreateinstance.. and we can call the memebers function of interface variable->method(); // successfully calls the members } CMYclass::accessfunctionofcomobject() { // application crashes when try to access com object functions variable->method(); // UNHANDLED EXPECTION } CMYclass *ptr; // This is gobal pointer variable.. // fun1 is a gobal function void fun1() { ptr->createcomobject(); } // fun2 is a gobal function void fun2() { ptr->obj.accessfunctionofcomobject(); //calling this funciton makes crash. } void main() { ptr = new CMYclass(); fun1(); // This function calls creates successful com object inside a class object. fun2(); // This function calls makes crash... } i want to know why the unhandled exception is raising

        modified on Thursday, November 19, 2009 11:53 PM

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

        Please, specify what exception has occurred and how was initialized com variable

        modified on Friday, November 27, 2009 4:23 PM

        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