locked
ReflectionTypeLoadException Error (System.Web.Http) on InstallUtil RRS feed

  • Question

  • User1747065912 posted

    I'm trying to install a windows service thro "InstalUtil" and it's refusing to register it with the ReflectionTypeLoadException Error (.Net Framework v4.5.50709).

    Same service is getting registered fine when I install System.Web.Http in GAC using gacutil.exe but one of my other application is getting registered successfully without installing in GAC.

    Here's the full quote:

    System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

    What I have tried: 

    1. I have inserted my .dll in the same folder as my .exe (the debug). Copy Local is set to "True"
    2. I rebuilt the project
    3. I have tried copying/running the InstallUtil.exe into the same folder from the .Net Framework, no luck.

    What steps am I missing here? Is there any way I can dig into the project and find out what is causing this?

    Friday, June 17, 2016 4:37 AM

Answers

  • User-2057865890 posted

    Hi Sreeram R,

    System.Web.Http assembly is part of Microsoft.AspNet.WebApi.Core package. This package contains the core runtime assemblies for ASP.NET Web API.

    Best Regards,

    Chris

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 22, 2016 7:28 AM

All replies

  • User-2057865890 posted

    Hi Sreeram R,

    Based on the error message, one of the assemblies in the solution cannot be loaded or there is some missing reference. In the Solution Explorer, click the References tab, check your references, remove old dll and update to the latest one.

    Best Regards,

    Chris

    Friday, June 17, 2016 9:56 AM
  • User1747065912 posted

    Yes Chris, I verified all projects in my solution referring "System.Web.Http", ensured that reference is pointing to my local path ~"D:\...\Lib\WebApi\System.Web.Http.dll" & copy local = true but still InstallUtil install fails if dll is not installed in GAC.

    I also tried, catching exception thro ReflectionTypeLoadException, I inserted Try Catch ReflectionTypeLoadException block in Service's Main() method & in ProjectInstaller.cs's constructor but No error is caught.

    I've also called System.Diagnostics.Debugger.Launch() in Try() block but error message throw first by which I assume Error thrown by InstallUtil even before executing above code lines.

    Between,

    I'm wondering why I've to explicitly install "System.Web.Http.dll" in my GAC ?! (I've .Net Framework 4.5 installed in my machine.)

    Isn't "System.Web.Http.dll" part Microsoft's framework package? 

    Is it advisable to GAC install Microsoft's "System.Web.Http.dll" by me? 

    Thanks & Regards,

    Sreeram

    Tuesday, June 21, 2016 5:15 AM
  • User-2057865890 posted

    Hi Sreeram R,

    System.Web.Http assembly is part of Microsoft.AspNet.WebApi.Core package. This package contains the core runtime assemblies for ASP.NET Web API.

    Best Regards,

    Chris

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 22, 2016 7:28 AM