CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2004
    Posts
    8

    Question COM out of process server (EXE) instantiated 2 times

    Hello.

    I've just written a relatively simple COM application : an ATL COM Server (EXE) providing one COM object. I choosed EXE because I want an existing application (a Win32 server) to have a COM entry point.

    First test :

    I make a .VBS file that simply instantiate the component and call a method. It works very well. I can even add debug points on the running EXE server to trace the request.

    Second test :

    In fact, the client is more complicated, it's a DLL (it's an ISAPI extension, built with ATL Server Web Service wizard).

    When the client make the SOAP request, the DLL correctly process it, forward it to the EXE COM Server. It looks like it's working correctly but I can't add debug points in my EXE server. After some investigation, it showed that the DLL was not forwarding the request to the running EXE server, it was instantiating another server process ! (as if it was an in process server).

    I've got the idea it could be because the ISAPI DLL was running on an account (the IIS one) and the server on another (the current user, me). But after configuring the Web application so it uses my account I still have the same problem : in task manager I can see 2 server process with the same user name.

    I'm not a COM Guru, so going short on ideas, anyone know what is happening?
    Last edited by sebdejonghe; March 31st, 2004 at 07:39 AM.

  2. #2
    Join Date
    Mar 2002
    Location
    Philadelphia
    Posts
    150
    You can make your COM Object a singleton by using DECLARE_CLASSFACTORY_SINGLETON
    within your EXE server.

    However, this will only create a singleton per Winstation, so you were on the right track with the logons.
    Use Winstation Monitor to determine how many Winstations are running on your computer at the moment.

    If your EXE keeps running in multiple Winstations you may be able to limit this behavior by using dcomcnfg. Find your server, right click on it, and go to the Identity tab. From there you can specify the user, and therefore Winstation, from which your server runs.
    Sincerely,
    - Ron

  3. #3
    Join Date
    Mar 2004
    Posts
    8
    Thank you for you response.

    I have declared my ATL project free threaded with _ATL_FREE_THREADED in StdAfx.h

    My object is declared singleton with DECLARE_CLASSFACTORY_SINGLETON and supporting multi threads with CComObjectRootEx<CComMultiThreadModel>.

    It works perfectly with VB scripts, C++ exe clients, C# exe clients, it works remotely, etc... But not within an IIS extension (it does not use the existing running instance of the server, always create a new process).

    The IIS application is running with the same user name than the COM server.

    I don't know a lot about Winstation. Can 2 winstations be running on the same account?

    With winsta.exe I can only see one station. With task manager I can see 2 instances of the same process, running on the same account.

  4. #4
    Join Date
    Mar 2004
    Posts
    8
    I forgot something :

    The IIS DLL create another instance of the COM server, but once it is created, all request from this DLL use this newly created instance (there is never more than 2 running instances).

  5. #5
    Join Date
    Mar 2002
    Location
    Philadelphia
    Posts
    150
    Did you try using dcomcnfg to specify the runtime logon of your server exe?
    Sincerely,
    - Ron

  6. #6
    Join Date
    Mar 2004
    Posts
    8
    Yes it works thank you!

    Now I have to understand why.

    My COM server is running on account X, my IIS DLL was running on account X and it was not working : ISS DLL use another instance of my COM server, but still running on account X.

    I configure DCOM so my COM server run on account X and now it works.

  7. #7
    Join Date
    Mar 2002
    Location
    Philadelphia
    Posts
    150
    Great. I am glad that worked for you.

    Just because you had given each account the same username and password doesn't mean each login is the same.

    By specifying the domain, username, and password via dcomcnfg you limited your com server to run only under one winstation.
    Sincerely,
    - Ron

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured