eLs
eLs

Reputation: 213

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

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.

Upvotes: 9

Views: 13855

Answers (3)

SKINDER
SKINDER

Reputation: 1020

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.

Upvotes: 2

LawMan
LawMan

Reputation: 3625

I had a similiar problem. I did the following that worked for me.

  • First, use FuseLog (Assembly Binding Viewer) to figure out where the binding is failing (Described Here

  • Once I began getting logs, I noticed this in my log was "Invalid assembly platform or ContentType in file (hr = 0x8007000b)."

  • My solution consisted of 3 projects. I went through the build properties of each project and noticed that one of them was targeted for "x86". I changed it to "Any CPU", recompiled and the problem was resolved.

Upvotes: 1

Mike Perrenoud
Mike Perrenoud

Reputation: 67898

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.

That doesn't really matter, the assembly still needs to make it to the installation directory. If you set Copy Local to false, then you still need to distribute the assembly with the installation.

Upvotes: 0

Related Questions