Sgen.exe build error "Unable to load one or more of the requested types"

I am creating a solution that contains several solutions. All but one are built without problems. The problematic issues the following message:

Error 2 Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more info. J: \ MyPlugins \ MyPlugin1 \ SGEN MyPlugin1

I included detailed output in Visual Studio, and I got the following: C: \ Program Files (x86) \ Microsoft SDK \ Windows \ v8.0A \ bin \ NETFX 4.0 Tools \ sgen.exe / assembly:

I checked the output with FusionLog and everything loaded correctly. It turned out to be a red herring. I decided to start the assembly again when verbosity unfolded. I got the following:

Microsoft (R) Xml Serialization Support Program [Microsoft (R) .NET Framework, version 4.0.30319.17929] Copyright (C) Microsoft Corporation. All rights reserved. If you need more help, enter "sgen /?". SGEN: error: cannot load one or more of the requested types. Get the LoaderExceptions property for more information. The command is completed with code 1. Completed task "SGen" - FAILED.

C: \ Program Files (x86) \ Microsoft SDK \ Windows \ v8.0A \ bin \ NETFX 4.0 Tools \ sgen.exe / assembly: ": \ MyPlugins \ MyPlugin1.dll" / proxy types / reference: "J: \ MyPlugins \ MyPlugin1 \ packages \ FluentValidation.3.4.6.0 \ lib \ Net40 \ FluentValidation.dll "/ reference:" C: \ Program Files (x86) \ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.0 \ mscorlib.dll "/ reference : "J: \ MyPlugins \ MyPlugin1 \ Libraries \ Core \ bin \ Release \ Core.dll" / reference: "J: \ MyPlugins \ MyPlugin1 \ Libraries \ Services \ bin \ Release \ Services.dll" / reference: "J: \ MyPlugins \ MyPlugin1 \ Presentation \ Web.Framework \ bin \ Release \ Web.Framework.dll "/ reference:" C: \ Program Files (x86) \ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.0 \ System.Core .dll "/ reference:" C: \ Program Files (x86) \ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.0 \ System.Data.dll "/ reference:" C: \ Program Files (x86) \ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.0 \ System.dll "/ reference:" C: \ Program Files (x86) \ Refe rence Assemblies \ Microsoft \ Framework.NETFramework \ v4.0 \ System.EnterpriseServices.dll "/ reference:" C: \ Program Files (x86) \ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.0 \ System.Web.dll "/ reference:" C: \ Program Files (x86) \ Microsoft ASP.NET \ ASP.NET MVC 4 \ Assemblies \ System.Web.Mvc.dll "/ link:" C: \ Program Files (X86) \ Assembly Link \ Microsoft \ Framework.NETFramework \ v4.0 \ System.Web.Services.dll "/ reference:" C: \ Program Files (x86) \ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.0 \ system.Xml.dll "

What causes this error and how can I fix it without disabling SGEN? FYI, I did not write the code.

+6
source share
3 answers

The solution is simple but hard to find. You must delete the precompiled asp.net folder. Because plugins are dynamically referenced, .NET cannot update DLL files like other components.

0
source

Great advice that worked for me, taken from here: http://hashtagfail.com/post/5255977780/sgen-loaderexceptions-error

The reason this happens is because in Release Visual Studio versions, attempts are made to create a serialization assembly containing the types in your solution to improve the performance of XmlSerializer serialization if you decide to serialize your types. This can be disabled by going to the "Assembly" tab of the project properties and set "Create Serialization" to "Off."

+12
source

I had the same problem and this was a bad link in the project. After removing the DLL from the GAC, it worked fine. You may find DLL problems with Fusion Log. More here

0
source

All Articles