Search Results

Search found 1 results on 1 pages for 'kbe'.

Page 1/1 | 1 

  • Activator.CreateInstance fails in Windows Service

    - by kbe
    I have an issue with a Windows Service which throws a NullReference exception whenever I try to use var myType = Activator.CreateInstance(typeof(MyType)) There is no problem whenever I run the exact same code in a console window - and after debugging the obvious "which user is running this code" I doubt that it is a mere fact of changing the user running the service as I've tried to run the service using the computer's Administrator account as well as LocalSystem. I'm suspecting a Windows Update fiddling with default user rights but that's a bit of a desperate guess I feel. Remember: The type and assembly exist and works fine - otherwise I wouldn't be able to run the code in a console window. It is only when running in the context of a Windows Service I get an error. The question is: Can I in any way impersonate i.e. LocalSystem in a unittest by creating a GenericPrincipal (how would that GenericPrincipal look)?

    Read the article

1