none
Retrieving COM Class factory error from C# Local Service RRS feed

  • Question

  • I get the following message when my C# windows service which is setup to run as a LOCAL SERVICE tries to connect to a COM dll:

    XXX could not create xxx class encountered problem with xxx, msg: Retrieving the COM class factory for component with CLSID {xxx} failed due to the following error: 80070005.

    However, the windows service works fine when it is setup to run as a LOCAL SYSTEM! I am restricted to run the service as LOCAL SERVICE because of some other issues and hence switching to LOCAL SYSTEM might not be an acceptable solution for me. 

    I also see the following error in System Event Log:

    The machine-default permission settings do not grant Local Activation permission for the COM Server application with CLSID 

    {XXX}  to the user NT AUTHORITY\LOCAL SERVICE SID (S-1-5-19).  This security permission can be modified using the Component Services administrative tool.


    I tried to add security permissions to the C# windows service given below but that did not help.

     [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)]

     

    I am trying to come up with a solution without having to change the DCOM permissions of the COM binary.  Please let me know if and how I can do that.

     

    Thanks in advance.

     

    • Edited by IdleBrain23 Monday, August 16, 2010 4:36 PM More Info
    Monday, August 16, 2010 3:58 PM

Answers

  •  

    Hi,

     

    Adding security permissions to the C# windows service will only effect .NET security, so it doesn't help on this issue.

    It there any special reason that we cannot change DCOM permission? As far as I know, it is the only way to fix the issue.

    By the way, there is an exiting sample provides source code and several wrapper functions to simplify the process of manipulating the access and launch permissions for a COM server, so that we no need to modify DCOM permissions manually.


    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.
    • Marked as answer by IdleBrain23 Tuesday, August 24, 2010 2:07 AM
    Thursday, August 19, 2010 5:02 AM

All replies

  •  

    Hi,

     

    Adding security permissions to the C# windows service will only effect .NET security, so it doesn't help on this issue.

    It there any special reason that we cannot change DCOM permission? As far as I know, it is the only way to fix the issue.

    By the way, there is an exiting sample provides source code and several wrapper functions to simplify the process of manipulating the access and launch permissions for a COM server, so that we no need to modify DCOM permissions manually.


    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.
    • Marked as answer by IdleBrain23 Tuesday, August 24, 2010 2:07 AM
    Thursday, August 19, 2010 5:02 AM
  • Thanks for your explanation.

    We have implemented changing DCOM Permissions and it works fine now.

    Tuesday, August 24, 2010 2:07 AM