Release COM+ object

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.
    

My class is very simple, It has all the typical COM realted attributes applied to the class and it has one public method:
public interface IGetFeatureToggles
List<Data.FeatureToggle> GetAllFeatureToggles(object[] token);
// List<Data.FeatureToggle> GetAllFeatureToggles(Token token);
/// <summary>
/// Class for retrieving Feature Toggles
/// </summary>
[ProgId("Mdrx.PM.Server.FeatureToggle.Svr.GetFeatureToggles")]
[Transaction(TransactionOption.Supported)]
[EventTrackingEnabled(true)]
[Guid("960D39FE-2792-44D7-AC2B-14CD7A1CB50F")]
public class GetFeatureToggles : ServicedComponent, IGetFeatureToggles
#region private members
#endregion
#region constructors
#endregion
#region public properties
#endregion
#region public methods
/// <summary>
/// Retrieves all Feature Toggles
/// </summary>
/// <param name="token">Object Array representing a Token</param>
/// <returns>List of FeatureToggle</returns>
[AutoComplete]
public List<Data.FeatureToggle> GetAllFeatureToggles(object[] token)
IGetDbFeatureToggleAll getData = new GetFeatureToggleAll();
var properToken = new Token(token);
var featureToggles = getData.GetFeatureToggleDataAll(properToken);
if (featureToggles != null && featureToggles.Count > 0)
var getUserAccess = new GetFeatureToggleUserAccessByFeatureToggleId();
foreach (var featureToggle in featureToggles)
featureToggle.UsersWithAccess = getUserAccess.GetUserAccessDataByFeatureToggleId(properToken, featureToggle.FeatureToggleID);
return featureToggles;
#endregion
#region private methods
#endregion
This class is registered on the client machine, I am adding a reference to the DLL, I need to the add the reference to my project because when i try to create an instance of the class using Activator.CreateInstance and the DLL is not there it gives in File
not found exception.
I am using this to get the type and create an instance;
var iGetFeatureToggles = _comServerFactory.GetComServer<IGetFeatureToggles>(typeof(GetFeatureToggles));
public T GetComServer<T>(string progId)
Type comType;
if (ComClientAssembliesManager.IsClientType(progId))
comType = Type.GetTypeFromProgID(progId, null);
else
string remoteServer = ConfigurationManager.AppSettings[RemoteComputerNameConfigKey];
//TODO: Analyze how to call DCOM object with "localhost" remote server name.
comType = Type.GetTypeFromProgID(
progId,
string.IsNullOrWhiteSpace(remoteServer) || remoteServer == "localhost" ? null : remoteServer);
return (T)Activator.CreateInstance(comType);

Similar Messages

  • Instantiating COM objects from within the java code in WLS

    is there a way to use COM objects from servlets or ejb's,
    with JVM, not with JView.
    thanks,
    ali.

    Sun has released a beta product - its a COM bridge that you can use
    to connect a Java2 JVM to a COM object with. I havent tried it yet
    but I probably will soon.
    Brad
    "Michael Girdley" <[email protected]> wrote in message news:39b86deb$[email protected]..
    >
    >
    No, at the current time we only support COM integration when using the
    Microsoft JVM. The Jintegra product from Linar is good.
    Thanks,
    Michael
    Michael Girdley
    BEA Systems Inc
    "Ali Ozgun" <[email protected]> wrote in message
    news:[email protected]..
    is there a way to use COM objects from servlets or ejb's,
    with JVM, not with JView.
    thanks,
    ali.

  • How to release a object that is set to obselete?

    Hi All,
    In my development system i need to develop a workflow using BUS1007/BUS1008.
    But it is set to obselete.
    Can anyone tell me How to release a object that is set to obselete?
    Thanks and regards,
    Raj

    Hello,
    As per the documentation on Business object builder on help.sap.com,
    Obsolete object types/object type components show that the functions are being discontinued and replaced with other functions that are incompatible.
    Object types or object type components being discontinued and designated by SAP as obsolete are still supported in the change release and the next release. The old functions and the new functions are available in parallel for this period.
    Incompatible changes are included by SAP in a central release note.
    So, it is better that you look out for other business objects. I am not sure, but I think you can use the BO KNA1 in place of 'BUS1007' and LFA1 for BUS1008 as the key fields are same for both the business objects.
    Hope this will help.
    Regards,
    Samson

  • On cleanuing up COM object when using Microsoft.Office.Interop.Excel

    When using Microsoft.Office.Interop.Excel the COM objects that are created by the code must be released using System.Runtime.InteropServices.Marshal.ReleaseComObject().
    Most of the time it's pretty clear when a new COM object is created such as:
    Excel._Application excelApp = null;
    Excel._Workbook wb = null;
    Excel._Worksheet ws = null;
    Excel.Range newRange = null;
    try
    // four COM objects are created below
    excelApp = new Excel.Application();
    wb = excelApp.Workbooks.Add();
    ws = (Excel.Worksheet)wb.Worksheets.Add();
    newRange = (Excel.Range)ws.Range["A1","A30"];
    // do these line of cod create new COM object?
    newRange.Font.Bold = true;
    newRange.Borders.Color = borderColor;
    finally
    if (excelApp != null) Marshal.ReleaseComObject(excelApp)
    if (wb != null) Marshal.ReleaseComObject(wb)
    if (ws != null) Marshal.ReleaseComObject(ws)
    if (newRange != null) Marshal.ReleaseComObject(newRange)
    In the above code I create four COM objects in the first part that need to be released when I'm finished with them. But it's not clear if the other two lines of code create a new COM object or not.  If they do then my code needs to look more
    like this:
    Excel._Application excelApp = null;
    Excel._Workbook wb = null;
    Excel._Worksheet ws = null;
    Excel.Range newRange = null;
    Excel.Font fnt = null;
    Excel.Borders bds = null;
    try
    // four COM objects are created below
    excelApp = new Excel.Application();
    wb = excelApp.Workbooks.Add();
    ws = (Excel.Worksheet)wb.Worksheets.Add();
    newRange = (Excel.Range)ws.Range["A1","A30"];
    // do these line of cod create new COM object?
    fnt = newRange.Font
    fnt.Bold = true;
    bds = new newRange.Borders;
    bds.Color = borderColor;
    finally
    if (excelApp != null) Marshal.ReleaseComObject(excelApp)
    if (wb != null) Marshal.ReleaseComObject(wb)
    if (ws != null) Marshal.ReleaseComObject(ws)
    if (newRange != null) Marshal.ReleaseComObject(newRange)
    if (fnt != null) Marshal.ReleaseComObject(fnt)
    if (bds != null) Marshal.ReleaseComObject(bds)
    How can I tell if getting a property creates a new COM object or not?

    Thank you for your replay but I do understand that the font object is a COM object.  What I'm trying to figure out is if a NEW object is created each time I access the font member of a Range object and if I need to call
    Marshal.ReleaseComObject on the font object after using it.
    Most member object of an object are a single instance and each time you access the member you simply get the pointer to that instance. For example:
    using(DataTable dt = new DataTable("Some Table Name"))
    PropertyCollection ep1 = dt.ExtendedProperties;
    PropertyCollection ep2 = dt.ExtendedProperties;
    if (Object.ReferenceEquals(ep1,ep2)) Console.WriteLine("They are the same object");
    else Console.WriteLine("They are different objects");
    The output will be: They are the same object
    On the other hand this:
    Excel._Application excelApp = new Excel.Application();
    Excel._Workbook wb = excelApp.Workbooks.Add();
    Excel._Worksheet ws = (Excel.Worksheet)wb.Worksheets.Add();
    Excel.Range newRange = (Excel.Range)ws.Range["A1","A30"];
    // do these lines of code create new COM object?
    Excel.Font ef1 = newRange.Font;
    Excel.Font ef2 = newRange.Font;
    if (Object.ReferenceEquals(ef1,ef2)) Consloe.WriteLine("They are the same object");
    else Consloe.WriteLine("They are different objects");
    The output will be: They are different objects
    It looks like each time I access the font member I get a new object.  I suspect that is not the case and what I am getting is two pointers to the same object and the reference counter is incremented by one.
    So really the question is what happens to the font member object of the Range object when the range object is released.  I assume the font member will be released along with the Range object ever if the font object has a reference count greater then
    0.
    If I am correct in my assumption then I can access the font member object as much as I need to without worrying about releasing it.
    I have been reading a lot about working with COM and the need to use Marshal.ReleaseComObject and there does seem to be a lot of disagreement and even confusion on the
    mater about when and if COM objects need to be explicitly released.

  • Jview : COM objects must reside on the weblogic machine ?

    Acessing COM objects through weblogic com classes, i did not see any mention of
    host settings. Does this mean that COM objects must be registered on the same
    machine as the one Weblogic is running on ? I would like to use COM objects on
    another machine (registered via DCOM protocol).

    That is the only way it is currently supported. Later this fall we will
    release a stronger COM integration package that will fix this limitation.
    Michael Girdley
    BEA Systems
    Learning WebLogic? http://learnweblogic.com
    "Abass Ndiaye" <[email protected]> wrote in message
    news:[email protected]..
    >
    Acessing COM objects through weblogic com classes, i did not see anymention of
    host settings. Does this mean that COM objects must be registered on thesame
    machine as the one Weblogic is running on ? I would like to use COMobjects on
    another machine (registered via DCOM protocol).

  • How can I use a COM object that does not have a type library?

    Hello,
    I've created a com server in python for which I do not have a type library. I am able to call functions for this application in Python, TCL, I'm sure VB, etc. without the type library.
    Must I have a type library registered to use this COM object with Labview? I was hoping I could simply supply the name to the refnum (or the GUID) then call functions by passings strings to the invoke node. This does not seem to be possible - am I missing something?
    In the event that I cannot use a com server without a type library. Any recommendataions on how to create one? I'm wondering if I can use the same GUID and create a shell in LabWindows which generates the IDL/TBD file I need for Labview to see my
    com server.
    Any help is greatly appreciated.
    73,
    Timothy

    Timothy Toroni wrote:
    > Thanks for the info, however their example is labview server and
    > python client. I'm going the other way. It's good to know about
    > LabPython though...
    >
    > As of now, it seems to be there is no way to use a COM object without
    > a type library from inside LabView.
    Yes that is true. LabVIEW needs that to configure the Property and
    Methode Nodes correctly. Otherwise it would need to have a special
    Property and Method Node with a configuration dialog similar to the Call
    Library Node, but a LOT more complicated. Not sure many people could
    make use of that, and it would be a very tiring experience trying to get
    things setup in that way, by going through the edit, test, and crash
    cycle over and over again.
    Rolf Kalberm
    atter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How can I call a COM object from a PL/SQL CODE

    Hi everyone,
    Does anyone know how to call a COM object from a stored procedure in oracle.
    a sample of code
    please help,
    Hilaire

    Are you familiar with external procedures? Basically, you can expose functions exported by a shared library (i.e. a DLL on Windows) to the Oracle database. My assumption is that you'd probably need to write a wrapper DLL around the COM object, since I believe you can only pass fundamental data types back and forth (i.e. no object references). You'd expose the method(s) of that wrapper DLL to the database via external procedures.
    Justin
    Distributed Database Consulting, Inc.
    www.ddbcinc.com/askDDBC

  • How can I call COM object in a servlet?

    Hi,
    Does oracle provide a bridge to call COM objects in a servlet? Is there any sample for doing this?
    Thanks,
    Archie

    Archi,
    Take a look at the following link:
    http://technet.oracle.com/products/ids/daily/jul12.html
    You can use J-Integra, one of JDeveloper's Extensions, in your Servlet to call any MS COM objects.

  • How to call a COM object from an Oracle Form?

    Hi All,
    Pls advice. How to call a COM object from an Oracle Form?
    Thanks.

    try asking the "Form" forum

  • Creating a COM object with CF9 32-bit on Windows Server 2008 R2 64-bit machine

    I'm using a 32-bit version of CF9 and it's installed on a Windows Server 2008 R2 machine (64-bit).  The problem I'm running into is that it won't allow me to create a COM object - it gives me the error, "no ntvinv in java.library.path null" when I try to run,
    <cftry>
    <cfobject type="COM" action="CONNECT" name="Engine" class="JRO.JetEngine">
    <cfcatch type="Any">
        <cfobject type="COM" action="CREATE" name="Engine" class="JRO.JetEngine">
    </cfcatch>
    </cftry>
    Then when I run it a 2nd time, I get "An exception occurred when instantiating a COM object. The cause of this exception was that: java.lang.RuntimeException: Can not use native code: Initialisation failed."
    Can you help me?

    Replying for your patchset installation pre-req error:
    Use below command:
    ./runInstaller -ignoreSysPrereqs
    Review MOS note 763143.1 for more info.

  • Error while reading indesign(.indd) file through COM object in c#

    I want to read InDesign(.indd) file in c#. I have installed adobe InDesignCS6.
    I have added COM reference of 'Adobe InDesign CS6 Type Library' in my c# application.
    Code snippet is as follows.
            [STAThread]
            static void Main(string[] args)
                InDesign.Application app = (InDesign.Application)COMCreateObject("InDesign.Application");
                Document doc = app.ActiveDocument;
                Page page = doc.Pages[1];
                TextFrame frame = page.TextFrames[1];
                Console.WriteLine(frame.Contents.ToString());
            public static object COMCreateObject(string sProgID)
                // We get the type using just the ProgID
                Type oType = Type.GetTypeFromProgID(sProgID);
                if (oType != null)
                    return Activator.CreateInstance(oType);
                return null;
    But the first line itself throwing an following error while type casting output of COMCreateObject method into InDesign.Application type.
    Error :
    Unable to cast COM object of type 'System.__ComObject' to interface type 'InDesign.Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{ABD4CBB2-0CFE-11D1-801D-0060B03C02E4}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
    Kindly help me. Its urgent.

    try this,
    InDesign.Application app = (InDesign.Application)COMCreateObject("InDesign.Application.CS6");

  • Control release of objects till Budget Release in CJ32

    Hi Experts,
    Actually, I have done as suggested in this forum for one of the query by creating a user status and blocking the release of objects till the time the budget is assigned. it is working fine till I allocate budget through CJ30 but the requirement is that the Release of the objects should be allowed only after the Budget Release through CJ32.
    1) How to create a user status which disappers on its own when the Budget is released through CJ32 ?
    2) Also, I want this to get only assigned to the topmost WBS whereas this gets assigned to all the WBS as I had assigned this Status profile in the Proj. profile. ... how to overcome this problem ?
    thanks in advance,
    Vinodh.

    Hi Vinvidh,
    1.If you want at budget release then you need change the status manually,it will not set automatically like when we are doing budgeting in CJ30.
    2.When you are creating a status for WBS  it will apply for all so i dont know how to control at top level only.But may be using substitution u can try at level1 wbs element.
    Regards,
    Muzamil

  • Error Msg "Invalid Com Object Exception is output"

    Hi,
    The following error message was output when I tried to perform an
    optimization on the Finance Application.
    "An unhandled exception has occurred in your application....COM object
    that has been separated from its underlying RCW cannot be used".
    However, when my colleague perform the same optimization using her PC, it was ok. Please advise if there are any specific settings that are I need to set at the client or desktop level in order to avoid the error.
    Cheers
    Hon Leong

    Hi,
    My notebook is on Windows XP and Office 2007. As per your suggestion, I have run the client diagnostic program and found the following error:
    [Internet Explorer Option setting]
      Proxy server
        No proxy setting
      Use HTTP 1.1
        Required: True
        Currently: True
        Status: OK
      Enable Integrated Windows Authentication
        Required: False
        Currently: True
        Status: Error
    Would you be able to advise how I can disable the Integrated Windows Authentication so that I can see the problem is due to the above error.
    Cheers
    Hon Leong

  • How to release Anchored objects in an .indd file

    I need to programaticaly release anchored objects in a opened indd file so that images's coordinates could get. does any one have an idea about how to do that.
    Thanks

    I need to programaticaly release anchored objects in a opened indd file so that images's coordinates could get. does any one have an idea about how to do that.
    Thanks

  • [JS CS3] Releasing Anchored Objects

    Hello,
    The following script places a libray item as an anchored object...
    var myDoc = app.documents[0];
    var myFrame = app.documents[0].textFrames.item("myTarget");
    var myInsertPoint=myFrame.parentStory.paragraphs.item(0).insertionPoints.item(0)
    var myLibraryItem=app.libraries[0].assets[0]; myFrame=myLibraryItem.placeAsset(myInsertPoint);
    with(myFrame[0].anchoredObjectSettings){
    anchoredPosition = AnchorPosition.anchored;
    anchorPoint = AnchorPoint.topLeftAnchor;
    horizontalReferencePoint = AnchoredRelativeTo.anchorLocation;
    horizontalAlignment = HorizontalAlignment.leftAlign;
    anchorXoffset = 0;
    anchorYoffset = 0;
    How do I now release my anchored library item and then send it behind the text in the text frame "myTarget" ?
    Thanks
    Simon Kemp

    Thanks Harbs, this has made things simpler.
    I have heard your name mentioned several times today in the InDesign Secrets podcast (and Dave's too).
    I am almost there with the script (my scripting is clumsy but I can usually get things to work mainly with help from this forum.
    My last problem is that I am re-applying geometric bounds to the released anchored object as it is still being referenced as myAnchoredFrame.
    Is it possible to release ALL the anchored objects in one go? Or how do I dump the reference to myAnchoredFrame once it has been released?
    var myTextFrame = app.documents[0].textFrames.item("myTarget");
    var myParagraphs = myTextFrame.paragraphs
    for (var i = 0; i <= myParagraphs.length-1; i++) {
    var nLines = myParagraphs.item(i).lines.length;
    var myAnchoredFrame = myTextFrame.paragraphs.item(i).insertionPoints.item(0).textFrames.add();
    var myHeight = nLines*myParagraphs[i].leading*.353
    myAnchoredFrame.geometricBounds = [0, 0, myHeight, (myTextFrame.geometricBounds[3]-myTextFrame.geometricBounds[1])];
    myAnchoredFrame.fillColor = "Gradient";
    myAnchoredFrame.gradientFillAngle = 90;
    myTextFrame.texts.item(0).recompose;
    with(myAnchoredFrame.anchoredObjectSettings){
    anchoredPosition = AnchorPosition.anchored;
    anchorPoint = AnchorPoint.topLeftAnchor;
    horizontalReferencePoint = AnchoredRelativeTo.anchorLocation;
    horizontalAlignment = HorizontalAlignment.leftAlign;
    verticalReferencePoint = VerticallyRelativeTo.capheight;
    verticalAlignment = VerticalAlignment.topAlign;
    anchorXoffset = 0;
    anchorYoffset = -1;
    pinPosition = false
    myAnchoredFrame.anchoredObjectSettings.releaseAnchoredObject ()
    myAnchoredFrame.sendToBack();
    Thanks again
    Simon Kemp

Maybe you are looking for