Questions tagged [sgen]

The Microsoft XML Serializer Generator Tool - creates xml serialiser assembly from an existing assembly.

The Microsoft XML Serializer Generator Tool - creates xml serialiser assembly from an existing assembly.

https://learn.microsoft.com/en-us/dotnet/standard/serialization/xml-serializer-generator-tool-sgen-exe

92 questions
107
votes
13 answers

VSTS 2010 SGEN : error : Could not load file or assembly (Exception from HRESULT: 0x80131515)

I am experiencing a strange issue with VS2010. We use TFS to build our API dlls and we used to reference them in our projects usign a mapped network drive that was fully trusted. We have been working like that for at least two years and everything…
Developer IT
  • 1,203
  • 2
  • 11
  • 17
18
votes
5 answers

How to set SGEN toolpath in Msbuild to target 3.5 framework

I've just upgraded a project from VS2008 to VS2010 but I'm still targeting the 3.5 framework. In my project file I have a custom task to run SGEN to generate my XmlSerializers.dll. However the version of sgen being run targets the 4.0 framework. As…
Craig Shearer
  • 14,222
  • 19
  • 64
  • 95
14
votes
4 answers

SGEN failure: An attempt was made to load an assembly with an incorrect format in VS2008

I was able to find several similar questions asked and answered, but none of the answers or exact conditions applied to my situation. I have a .NET 3.5 project being built for x64. I also have an x64 mixed mode reference (also targeting .NET…
Anthony
  • 245
  • 1
  • 2
  • 10
12
votes
3 answers

Can VS.NET 2010/MSBUILD produce XmlSerializers for .NET 3.5 SP1?

I just upgraded a VS 2008 solution containing WinForms, general use libraries, and a web app to VS 2010, but all projects still target .NET 3.5 SP 1. I use this technique to generate XmlSerializers for my general use libraries. The WinForms app runs…
flipdoubt
  • 13,897
  • 15
  • 64
  • 96
12
votes
4 answers

sgen.exe x64 .net c# fails with "assembly with an incorrect format"

I have ws2008 x64 with vs2008. When I set my vs to x64 (because I have 64bit dlls) and run compilation sgen says that An attempt was made to load an assembly with an incorrect format VS takse sgen from C:\Program Files\Microsoft…
Darqer
  • 2,847
  • 9
  • 45
  • 65
12
votes
4 answers

How to exclude specific types from serialization?

I run sgen against my assembly with a metric ton of types. I want to exclude 2 types from serialization. I don't seem to be able to find a way to do it. I see that sgen has a /type switch to specify a specific type, but nothing to exclude a…
AngryHacker
  • 59,598
  • 102
  • 325
  • 594
10
votes
0 answers

"sgen.exe" could not be run in VSBuild on Azure Pipelines

Running the build locally is good, no problems whatsoever.. When I did run this on an Azure Pipeline it errors out. The detailed error message is The command-line for the "SGen" task is too long. Command-lines longer than 32000 characters are…
99823
  • 2,407
  • 7
  • 38
  • 60
9
votes
1 answer

Precompile XmlSerializers with XmlAttributeOverrides

When constructing XmlSerializer instances in .NET, assemblies for serializing and deserializing the specified type are generated dynamically. This is a time-consuming process. The sgen.exe tool from Microsoft can be used to precompile XmlSerializer…
9
votes
4 answers

MSBuild cannot find SGen when compiling a solution

I've looked at several other SGen-related questions on here and either their answers don't apply or their answers don't fix this for me. I have installed several SDKs to fix this issue with no luck. Reference types should not be changed since this…
Jaxidian
  • 13,081
  • 8
  • 83
  • 125
8
votes
1 answer

SGEN XMLSerializer - should be .XMLSerializers.dll added as a reference to the current project or to the GAC?

I do some stuff with XMLSerializer class. Like a most of beginners I face with performance issue on app start. I read a lot of blogs, articles and finally use SGEN tool. Now performance looks to be ok but few things are still not clear for me. 1)…
binball
  • 2,255
  • 4
  • 30
  • 34
7
votes
2 answers

XmlSerializer - the first deserialization is very slow

I have a solution with two projects; an asp.net MVC application, and a class library. Let's call them project MVC and project CLS. In the project CLS, there are two different versions (V1 and V2) of an XSD file that I have used to create two…
ataravati
  • 8,891
  • 9
  • 57
  • 89
7
votes
5 answers

WPF error CS0433

I'm getting this error in my WPF application. I get this error not always. If I make Clean and then Rebuild everything is ok. SGEN (0,0): error: Unable to generate a temporary class (result=1). SGEN…
Pashec
  • 23,199
  • 3
  • 26
  • 26
7
votes
3 answers

XmlSerializer not using XmlSerializers.dll created by sgen

In my Visual Studio 2010 project, I use following Post-Build event command line to use sgen to create XmlSerializers.dll. Post build event: "$(ProgramFiles)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\sgen.exe" /a:"$(TargetPath)"…
Din
  • 323
  • 3
  • 12
6
votes
1 answer

Mixed mode assembly is built against version X and cannot be loaded in version Y of the runtime without additional configuration information

After doing some code refactoring, my VS2010 VB.Net Web Application project has stopped compiling with the following error: "Mixed mode assembly is built against version 'v1.1.4322' of the runtime and cannot be loaded in the 4.0 runtime without…
pabrams
  • 1,157
  • 10
  • 34
6
votes
1 answer

Forcing VS2022 to use 32 bit version of msbuild

I'm currently investigating migrating our toolset from VS2013, 15, and 17 to just VS2022 in order to streamline and reduce the amount of software needed to build our solution. VS2022 has all the parts we need however I'm struggling to get the actual…
Adam Short
  • 75
  • 1
  • 6
1
2 3 4 5 6 7