Windows Service: System.Reflection.ReflectionTypeLoadException was thrown with the following error message: Unable to load one or more of the re

11,296

Maybe you need to use another version of InstallUtil.exe:

  • c:\Windows\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe
  • c:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe
  • c:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe
  • c:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe

Try to use x64 version from Framework64 subfolder.

Share:
11,296
Admin
Author by

Admin

Updated on June 15, 2022

Comments

  • Admin
    Admin almost 2 years

    I am using a windows service, In which I am having a reference of an assembly which is copy local= false. But I am trying to load it at runtime, which is though working fine when I am running it from visual studio, But when I try to install it, cmd gives this error:

    An exception occurred while trying to find the installers in the D:\Official\Pro
    jects\20131007_ImproveDN\build\debug\application
    s\SubscriptionService\SubscriptionService.exe assembly.
    System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the
     requested types. Retrieve the LoaderExceptions property for more information.
    Aborting installation for D:\Official\Projects\2
    0131007_ImproveDN\build\debug\applications\SubscriptionService\SubscriptionServi
    ce.exe.
    An exception occurred during the Rollback phase of the System.Configuration.Inst
    all.AssemblyInstaller installer.
    System.InvalidOperationException: Unable to get installer types in the D:\Offici
    al\Projects\\20131007_ImproveDN\build\debug\appli
    cations\SubscriptionService\SubscriptionService.exe assembly.
    The inner exception System.Reflection.ReflectionTypeLoadException was thrown wit
    h the following error message: Unable to load one or more of the requested types
    . Retrieve the LoaderExceptions property for more information..
    An exception occurred during the Rollback phase of the installation. This except
    ion will be ignored and the rollback will continue. However, the machine might n
    ot fully revert to its initial state after the rollback is complete.
    

    Also one thing to note here is that If I make copy local true of that .dll it makes installation fine. BUt I dont want to load it before installation so I want to do it at runtime.

    Thanks in Advance.

  • Admin
    Admin over 10 years
    That's what I am missing here, do you know how can I do it without making it copy local=true
  • Mike Perrenoud
    Mike Perrenoud over 10 years
    @eLs, that really all depends on how you distribute the application.
  • Admin
    Admin over 10 years
    Ok, but I have a program.cs and In the main function I am using Assembly resolver for other dlls which are not referenced but loaded at runtime. But the assembly which is creating issue is referenced and used in the code.
  • Deepak Pathak
    Deepak Pathak about 6 years
    This helped me, thanks! I was using Developer command prompt for VS 2017 and it was eventually failing, complaining the reported error above. I still don't understand why that happended and running installutil.exe from Framework64 version did the trick. Perhaps, DEV 2017 command prompt doesn't point to the latest installutil.exe ?