none
Retrieving the COM class factory for component with CLSID {xxx} failed due to the following error: 80080005 RRS feed

  • Question

  • Hi all

    I have a C# windows service application which refrencing a DCOM dll.
    When I run this application as a Console application, it work perfect.
    When I run it as a service, I got :
    Retrieving the COM class factory for component with CLSID {xxx} failed due to the following error: 80080005

    then I get a solution to this problem by changing some values using Component Services then DCOM properties.
    When I set all values back again, I got the same error. Then, from registry I get these values which make my service running without such problem.

    Registry entry which solve the problem:
    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\AppID\{xxx}]
    @="yyyyy"
    "ActivateAtStorage"="Y"
    "LaunchPermission"=hex:01,00,04,80,80,00,00,00,90,00,00,00,00,00,00,00,14,00,\
      00,00,02,00,6c,00,04,00,00,00,00,00,18,00,1f,00,00,00,01,02,00,00,00,00,00,\
      05,20,00,00,00,20,02,00,00,00,00,14,00,1f,00,00,00,01,01,00,00,00,00,00,05,\
      04,00,00,00,00,00,24,00,1f,00,00,00,01,05,00,00,00,00,00,05,15,00,00,00,45,\
      06,6e,63,f8,f8,95,f2,da,cf,9c,83,aa,1d,00,00,00,00,14,00,1f,00,00,00,01,01,\
      00,00,00,00,00,05,12,00,00,00,01,02,00,00,00,00,00,05,20,00,00,00,20,02,00,\
      00,01,02,00,00,00,00,00,05,20,00,00,00,20,02,00,00
    "RunAs"="Interactive User"
    "AccessPermission"=hex:01,00,04,80,44,00,00,00,54,00,00,00,00,00,00,00,14,00,\
      00,00,02,00,30,00,02,00,00,00,00,00,14,00,07,00,00,00,01,01,00,00,00,00,00,\
      05,0a,00,00,00,00,00,14,00,07,00,00,00,01,01,00,00,00,00,00,05,12,00,00,00,\
      01,02,00,00,00,00,00,05,20,00,00,00,20,02,00,00,01,02,00,00,00,00,00,05,20,\
      00,00,00,20,02,00,00


    and this is the entry which make trubles for me:
    Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AppID\{xxx}]
    @="yyyyy"
    "ActivateAtStorage"="N"
    "LaunchPermission"=hex:01,00,04,80,48,00,00,00,58,00,00,00,00,00,00,00,14,00,\
      00,00,02,00,34,00,02,00,00,00,00,00,18,00,1f,00,00,00,01,02,00,00,00,00,00,\
      05,20,00,00,00,20,02,00,00,00,00,14,00,0b,00,00,00,01,01,00,00,00,00,00,05,\
      12,00,00,00,01,02,00,00,00,00,00,05,20,00,00,00,20,02,00,00,01,02,00,00,00,\
      00,00,05,20,00,00,00,20,02,00,00

    Question: How can I fix this error on all Customer  machines programmatically in C#?
    I already added
    ActivateAtStorage="Y"
    RunAs="Interactive User"
    to the customer registry, but did not solve the problem.

    Khayralla

    Monday, November 16, 2009 2:58 PM

All replies

  • 0x80080005 is "Server execution failed".

    Your original issue seems to be caused by wrong permissions. Did you try to debug that and check that you run the service with the right permissions?
    The AppID\{xxx} you mention is for your application or for some other component?

    Any registry changes should be done at installation time and only to the components you install. I don't see much reason to change it from C# programatically. Anyway it is possible to change registry from C# (Microsoft.Win32.Registry), however I do not believe that it is the best way to fix your problem.

    -Karel
    Friday, November 20, 2009 12:11 AM
    Moderator
  • Hi Karel
    AppID{xxx} is for another unmannaged exe application.
    How can I know the right permissions ?
    I added some permissions request like:

    [assembly: EnvironmentPermission(SecurityAction.RequestMinimum, 
        Unrestricted = true)]
    [assembly: FileIOPermission(SecurityAction.RequestMinimum, 
        Unrestricted = true)]
    [assembly: ReflectionPermission(SecurityAction.RequestMinimum, 
        Unrestricted = true)]
    [assembly: RegistryPermission(SecurityAction.RequestMinimum, 
        Unrestricted = true)]
    [assembly: SecurityPermission(SecurityAction.RequestMinimum, 
        UnmanagedCode = true, ControlEvidence = true)]
    [assembly: EventLogPermission(SecurityAction.RequestMinimum, 
        Unrestricted = true)]
    [assembly: ServiceControllerPermission(SecurityAction.RequestMinimum, 
        Unrestricted = true)]
    [assembly: SecurityPermissionAttribute(SecurityAction.RequestMinimum, 
        Flags = SecurityPermissionFlag.RemotingConfiguration)]
    
    [assembly: NeutralResourcesLanguageAttribute("en", 
        UltimateResourceFallbackLocation.MainAssembly)]
    [assembly: CLSCompliant(true)]
    


    What is  missing here ?
    thanks
    Friday, November 20, 2009 3:48 PM
  • I am not expert on permissions, but I would look at native security permissions, not managed security permissions.
    Your issue seems to be DCOM related, not CLR. Are you sure that the user account under which the service runs has full access to the DCOM library? Can you try a small native service that will do the same call into DCOM?

    -Karel
    Friday, November 20, 2009 4:58 PM
    Moderator
  • I agree my issue is with DCOM, user account where the service run is log on as Local System account.
    I can configure DCOM to avoid this issue, but I am looking for doing this in the code and deply it.

    thanks
    Friday, November 20, 2009 6:26 PM
  • Then my previous answer should be sufficient, right?
    Any registry changes should be done at installation time and only to the components you install. I don't see much reason to change it from C# programatically. Anyway it is possible to change registry from C# (Microsoft.Win32.Registry), however I do not believe that it is the best way to fix your problem.

    Changing managed permissions IMO doesn't have impact on how your application will behave as a service (vs. from command line).
    Friday, November 20, 2009 7:27 PM
    Moderator
  • Actually I don't want to change the registry from my C# code, I would like to solve this issue programmatically.

    I mean maybe I have to add a native security permissions as you said or whatever, but this should be done in the code.

    The AppID\{xxx}  is a 3rd party application and is installed by my setup project, after installation is done, there is a nother application which is launch only one time to configure all components.

    I think I describe better now (sorry for the confusing).

    thanks
    Friday, November 20, 2009 7:55 PM
  • If you want to solve your problem, you should follow these steps:

    1. Find out what the problem is ... in this case find out why your code gets the COM exception when running as service?
    2. Find out how to fix the problem from step #1 ... do you have to change registry to fix it? Do you have to change application permissions?
    3. Implement the solution from step #2 where it originated. If it is problem in the application, fix the application. If you cannot do it, work around it.

    From your description so far it is not clear what #1 is in your case. Your original post suggests that you found a way how to 'temporarily fix' your problem (step #2) by modifying some "random" registry keys, but that doesn't explain what the problem really is (step #1). That just shows that there is at least one magic way how to make your problem disapear, but it doesn't neccesserily mean that it is a fix of your problem.

    For example if my application X doesn't run on Vista, I might find out that when I disable UAC, it works fine. However that doesn't mean that I should disable UAC on every computer where I install that application X. It just means, that I have some problems with permissions in my application X and I should find out what the underlying problem is and fix it.

    I hope this helps,
    -Karel
    Monday, November 23, 2009 2:46 AM
    Moderator
  • Karel

    your last post is a good help but does not solve my problem.

    so let me change the question in my first post:

    1) I got this error when I try (in a managed windows service)  to connect/use (a 3rd party) unmannaged application :
    Retrieving the COM class factory for component with CLSID {xxx} failed due to the following error: 80080005

    2) Now I am waiting to get some (if any) help to solve this problem.

    thanks Karel
    I appreciate your help.
    Monday, November 23, 2009 3:06 PM
  • Just waiting for a solution from someone else mostly doesn't help ... you are the one who has most information about the problem, you are the only one who can try various solutions and debug the problem as no one else has your code.

    Try to dig deeper into #1 and narrow down the problem, e.g.:
      - Try to do the same call from native code.
      - Replace the DCOM server with your test DCOM server (maybe there's a bug in the server).
      - Check if the DCOM server is even loaded into process.

    -Karel

    Wednesday, December 23, 2009 7:16 PM
    Moderator