Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

Release COM+ object

$
0
0

I have COM+ server component written in C# that is consumed by a C# WPF client, All the COM components are registered on the Client machine, I am able to create an instance of COM component and call the methods but after i am done with i am not able to dispose it.

COM+ class:

    using System;
    using System.EnterpriseServices;
    using System.Runtime.InteropServices;
    namespace Mdrx.PM.Server.Lookup.Svr
    {
        [EventTrackingEnabled(true)]
        [Guid("999999-A351-4AF9-AAFE-931549FD6EFA")]
        [ProgId("foo.PM.Server.Lookup.Svr.LkpQueryPat")]
        [Transaction(TransactionOption.Supported)]
        public class LkpQueryPat : ServicedComponent, IQuery
        {
            public LkpQueryPat();
            public int Query(dynamic vntToken, object vntIn, ref object vntData, ref int lngErrorID);

    }

I have compile time reference to this assembly in my client project so i am able to directly instantiate an object. I try to use Marshal.ReleaseComObject but that throws exception:
The object's type must be __ComObject or derived from __ComObject  

    LkpQueryPat patientLookupQuery = new LkpQueryPat();
    patientLookupQuery = null;

On the server i can see under dcomcnfg that the object remains under In Call column and never goes away, even if i kill the client application.

I noticed one more thing Objects column is the number of references client is holding and in my case it is 0 and that is because of these 2 lines, if i remove these then that number also keep increasing.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms681593%28v=vs.85%29.aspx

(patientLookupQuery as System.EnterpriseServices.ServicedComponent).Dispose();

patientLookupQuery = null;

What i don't understand is what the In Call column and how can bring that number to 0.

    

Viewing all articles
Browse latest Browse all 1710

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>