9

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.

eLs
  • 213
  • 2
  • 3
  • 8

3 Answers3

2

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.

SKINDER
  • 950
  • 3
  • 17
  • 39
  • 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 ? – Deepak Pathak Apr 19 '18 at 06:06
0

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.

Mike Perrenoud
  • 66,820
  • 29
  • 157
  • 232
  • That's what I am missing here, do you know how can I do it without making it copy local=true – eLs Oct 14 '13 at 12:47
  • @eLs, that really all depends on how you distribute the application. – Mike Perrenoud Oct 14 '13 at 12:49
  • 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. – eLs Oct 14 '13 at 12:52
0

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.
LawMan
  • 3,469
  • 1
  • 29
  • 32