.NET Framework Bookmark and Share   
 index > ASMX Web Services and XML Serialization > sgen - Error: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
 

sgen - Error: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

I get this error message when running sgen from the cmd prompt on my dll file. (ie c:\c: file.dll) I've searched high and low, but haven't found out

  • what this message means;
  • how to retrieve the loaderexceptions properrty;
  • or how to fix the problem.

The xmlserializer and deserializer code works ok in the dll, I just can't get a file.serializers.dll generated with sgen.

Are there sgen switches I need, or am I doing something else wrong?

ralph_y

Ralph,

Are the dependencies for file.dll colocated with it? In other words, are DepA.dll and DepB.dll also in c:\ with file.dll? If not, please make sure they are colocated and try again.

I'm not certain, but you might be able to find more information in the event logs also - Start / Run / eventvwr.msc

What version of Visual Studio and which operating system are you on?

JVE

Jason Van Eaton - MSFT

Ralph,

Are the dependencies for file.dll colocated with it? In other words, are DepA.dll and DepB.dll also in c:\ with file.dll? If not, please make sure they are colocated and try again.

I'm not certain, but you might be able to find more information in the event logs also - Start / Run / eventvwr.msc

What version of Visual Studio and which operating system are you on?

JVE

Jason Van Eaton - MSFT

Thanks Jason, The dependencies were the problem and colocation solved theoriginal error message.

Now I just have to contend with :

(Error: There was an error reflecting type .......... both use the XML type name, "...", from namespace ''. Use
XML attributes to specify a unique XML name and/or namespace for the type.

But at least this message is not as cryptic so I think I am now in good shape.

BTW, I use VS C# Express, and Sharp Develop on both XP Home and XP Pro

ralph_y

That's great! If you get stuck on the next error message, please post more information, like the actual namespace, type names, etc.

JVE

Jason Van Eaton - MSFT
How does one view the loader exceptions property, though? In a large system, it is difficult to know which file is causing the failure. Adding to this, I am on a x64 machine, and some of the assemblies are built with the AnyCPU target. The simple existence of the file is not enough in this case. At some point, there is a failure to load a dependent assembly. I'd like to be told which assembly is failing. To further complicate, it is also possible to have indirect dependencies, via DLL import, so it is not as simple as looking at the project references heirarchy, since those indirect dependencies are not listed there.

In summary, life would be simpler if the tool that encounters an error loading a file would tell us which file is is unable to load.

Thanks,

Troy
th30519
I have a similar problem and get "Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information" when running a post build event with sgen. I have defined teh post build event as ""$(FrameworkSDKDir)Bin\sgen.exe" "$(TargetPath)" /force" the error says this command exited with code 1

Is there anyway to find out what type was not able to be loaded, I tried with /verbose option but it only gives the loaderexception error.

Any help will be appreciated..

Thanks
Vinod
Vinod Rodrigo
I get the same error when I compile a project in "Release" mode but not in "Debug" mode. I use VSTS 2008 and .NEt 2.0. Can somebody explain this and the solution for this problem

Regards,
Karthik
Karthik_Seshu
I found the error goes off when I set the "Generate Serialization assembly" to "Off" in "Release" mode. I dont get the error in debug mode when the "Generate Serialization assembly" to "Auto".
What exactly this means?
Is this the right way to fix this?
Also in other machine I dont get this error When I have "Generate Serialization assembly" to "Auto" in both "debug" and "release" modes

Please explain
Karthik_Seshu

You can use google to search for other answers

Custom Search

More Threads

• how to authenticate to a webserivce
• derived class fields get serialized though base class is returned in asp.net WebService
• xmlwebservices
• Problem in Using JavaScript Calendar Control
• halt a databind in progress?
• where is the stocks.xls example file?
• Webmethod that return url caller
• Master page:dynamic loading of aspx pages in multiple conten place holders
• XML Web Services.
• Web service Linking issue: The specified module could not be found