none
How to host same ServicedComponent in multiple COM+ server applications? RRS feed

  • Question

  • Hi, everyone.

    I have a .NET serviced component that needs to be hosted in several dllHost.exe/COM+ server applications. The reason why I need same component to live in different applications is that each COM+ host server application will be configured to have different identity of dllhost.exe, different recycling properties, etc - essentially just like IIS needs multiple application pools, my software needs multiple host processes for the same piece of functionality.

    I have no trouble programmatically installing a serviced component into the COM+ catalog using a combination of a RegistrationHelper class and COMAdminCatalogObject. The trouble of course is that the same CLSID of my serviced component cannot be registered multiple times in multiple COM+ applications.

    Is there a way to maybe change CLSID (and ProgID) of a serviced component at any point during or after installing it into COM+ catalog, so that the client could user different CLSID or ProgID to pick which COM+ application to use as a host?

    Thank you,
    Vlad Hrybok.

    Sunday, May 23, 2010 9:43 PM

Answers

  • Thank you, Eric.

    Your suggestion could be a good work-around, but I have solved the problem by creating an alias of the component using COMAdminCatalogClass.AliasComponent() method. That allowed me to achieve exactly what I needed: to be able to instantiate my component in a different COM+ application using new unique CLSID or ProgId.

    All the best,
    Vlad Hrybok.

    • Marked as answer by Vlad Hrybok Monday, May 24, 2010 9:39 PM
    Monday, May 24, 2010 9:39 PM

All replies

  •  

    We cannot registry same .NET Serviced Component in different COM+ Applications at the same time.

     

    You may use ComRegisterFunctionAttribute Class to specify different CLSID or progID when registry the assembly, something like this:

            [ComRegisterFunction()]

            public static void Register(Type t)

            {

                using (RegistryKey keyCLSID = Registry.ClassesRoot.OpenSubKey(@"CLSID" + t.GUID.ToString("B"), true))

                {

                    RegistryKey subkey = null;

                    using (subkey = keyCLSID.CreateSubKey(Guid.NewGuid().ToString("B")))

                    {

                        // Clone key contents from source key to destination key, implement it yourself.

                        CloneRegKey(keyCLSID, subkey);

                    }

                }

                // Delete source reg key, implement it yourself.

                DeleteRegKey(keyCLSID);

            }

     


    Sincerely,
    Eric
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, May 24, 2010 10:25 AM
  • Thank you, Eric.

    Your suggestion could be a good work-around, but I have solved the problem by creating an alias of the component using COMAdminCatalogClass.AliasComponent() method. That allowed me to achieve exactly what I needed: to be able to instantiate my component in a different COM+ application using new unique CLSID or ProgId.

    All the best,
    Vlad Hrybok.

    • Marked as answer by Vlad Hrybok Monday, May 24, 2010 9:39 PM
    Monday, May 24, 2010 9:39 PM