locked
Connect to Com Object RRS feed

  • Question

  • Hi,

    I have a problem and i hope that somebody to help me!

    I have a application server (executeble written with Delphi) registered as a Com Object. Now i have a windows service written with C# and i have to call methods of Com object. I referenced a COM Object and made a reference.

    I tryed this

        ComClass comObj= new ComClass(); // here i start a com object (executeble)

        comObj.someMethod(..);

    It's working only when the Com object is not started.

    How can i get instance of running Com object, because i can't shutdown application server every time when i want to call some method

     

    Please help me!

    Thanks!

     

     

     

     

    Friday, March 31, 2006 8:04 PM

Answers

  • You need to use System.Runtime.InteropServices.Marshal.ReleaseComObject while disposing this class. syntax is going to be something like :

    public void Dispose()

    {

      System.Runtime.InteropServices.Marshal.ReleaseComObject (comObj) ;

    }

     

    If you dont do this your applicating will have hanging references to COM objects

    Wednesday, April 5, 2006 5:44 AM

All replies

  • Hi Bojo, I moved your post over to the CLR forum, where folks should be able to help you with your managed ==> native question.

    Cheers,

    JJustice [MSFT]

    Tuesday, April 4, 2006 9:42 PM
  • You need to use System.Runtime.InteropServices.Marshal.ReleaseComObject while disposing this class. syntax is going to be something like :

    public void Dispose()

    {

      System.Runtime.InteropServices.Marshal.ReleaseComObject (comObj) ;

    }

     

    If you dont do this your applicating will have hanging references to COM objects

    Wednesday, April 5, 2006 5:44 AM
  • Thanks, this's usefil for me byt my question was a bit different.

    I want to obtains a running instance of the specified  of my Com object

    My exe file is  called MonetaServer.exe

    I saw in registry that ProdID of COm is "MonetaServer.rdmMoneta"

    and CLSID is {E708B49E-88DC-480E-8BAC-F7F251D42AE4}

    When i tried this:

    Object obj = Marshal.GetActiveObject("MonetaServer.rdmMoneta");

    an exeption has thrown:

    Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))

    When i tried this:

    string prodId = Marshal.GenerateProgIdForType(Type.GetTypeFromCLSID(new Guid("D63B758A-C7F3-4919-8E80-6393CA4C6C41")));

    Object obj = Marshal.GetActiveObject(prodId);

    an exeption has thrown:

    The type must be creatable from COM.

    Parameter name: type

     

    If there is any security permittion which i have to set or what..

    I'll be grateful to help me!!!

     

    Thursday, April 6, 2006 9:05 AM