sgen

Why won't Visual Studio 2005 generate an Xml Serialization assembly?

Why isn't Visual Studio 2005 generating a serialization setting when I set the project setting "Generate Serialization Assembly" to "On"? ...

XmlSerializer, sgen.exe and generics

I have a generic type: public class Packet<T> where T : IContent { private int id; public int Id { get { return this.id; } } private T content; public T Content { get { return this.content; } } } I want to deserialize/serialize instances of this type from/to XML. IContent is defined like that: public interface IConte...

What is the most efficient way to Deserialze an XML file

Aloha, I have a 8MB XML file that I wish to deserialize. I'm using this code: public static T Deserialize<T>(string xml) { TextReader reader = new StringReader(xml); Type type = typeof(T); XmlSerializer serializer = new XmlSerializer(type); T obj = (T)serializer.Deserialize(reader); return obj; } This code runs...

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 instances to use them later without generating them dynamically. Unfortunately this is not...

Why is my application using CSC during execution

I've been experimenting with the Remotesoft Linker and Mini Deployment tools to create a single native executable (that doesn't need the framework installed) from my managed code. One of the configurable features it has is if csc.exe is available for the final executable. The documentation for it says that it's typically only needed if...

SGEN, InternalsVisibleTo and assembly signing

Hi, I'm trying to do something a bit unusual... I have this class Foo : public class Foo { public Foo(string name) { this.Name = name; } internal Foo() { } public string Name { get; internal set; } public int Age { get; set; } } Notice the internal setter for Name, and the internal default c...

Bug in Sgen.exe

It seems that sgen.exe could not generate generic type XmlSerializer, right? My genereic type: [Serializable] [XmlRoot(ElementName = "Masterx")] public class Masterx<T> where T : class, new() {....} Serializer code: protected virtual List<T> ParseXMLToObject<T>(string resultXML) where T : class, new() { //return ParseXM...

VS2008 - SGen error on Build

I get the following error when attempting to build my assembly in Release configuration in Visual Studio 2008: SGEN : error : Cannot load dynamically generated serialization assembly. In some hosting environments assembly load functionality is restricted, consider using pre-generated serializer. Please see inner exception for more infor...

sgen deserialization different from JIT deserialization

I have some web services that are returning data as an ArrayList of varying data types. One of those data types is MyType, which is a serializable type defined in another dll. We've recently moved from .NET 1.1 to .NET 3.5, but can't change the API of the web services, so we need to stick to ArrayLists for now. We have a Web Service P...

SGEN throwing an AccessViolation error

I have a build process using the sgen.exe tool to build Xmlserializer assemblies to optimize their use in a WinForms application. This application was originally written on the .NET 2.0 framework and after updating our server to have the 3.5sp1 framework the calls to Sgen error out with an AccessViolation exception. See the call belo...

Pre-generating XmlSerializers using Sgen and ILMerge. Trouble with arrays.

I use XmlSerializer extensively and rather than allowing .NET to generate the necessary serialization assemblies at runtime, I'd like to generate these assemblies ahead of time and bundle them with my application. I am able to use Sgen to generate these assemblies at build time. Additionally, I must run Sgen separately for each array typ...

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 SDKs\Windows\v6.0A\bin\ and I think that it should take it from C:\Program Files\Microsoft SDKs\Windows...

How to make sgen.exe keep the version of the assembly?

I want to create a serialization assembly for my assembly. sgen does it fine, but I can't figure out how to get it to assign the serialization assembly the same version as the source assembly. Any ideas? ...

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

Hi, 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) Should I use SGEN syntax like this: SGen.exe /assembly:MyAssembly /type:MyRootXmlType...

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 is the only place this is a problem. Once suggestion is to put SGen.exe into the C:\Windows...

What type of things can cause sgen msbuild task to fail intermittantly with Access Violation?

In our MSBuild file for our project we sgen an assembly containing classes used during xml serialization. The classes are generated via xsd.exe. We use the following SGen task configuration. <SGen ToolPath="$(SdkPath)" ShouldGenerateSerializer="true" UseProxyTypes="false" BuildAssemblyName="AssemblyName.dll" ...

SGEN doesn't work after upgrading from VS2008 to VS2010

I just recently upgraded a VS2008/.NET 3.5 SP1 project to VS2010 and .NET 4. I have a post-build event which calls SGEN to generate the XmlSerializers assembly. Whenever I try to run it I get the following error. "C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\sgen.exe" /debug /force /verbose /c:"platform:x86" "C:\path\to\SomeAssemb...

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 a result, when I run my application I get the error message: "Could not load file or as...

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

Hi ! 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 worked perfectly. Today, I converted a webapp to vs2010 and when I compile it in Rel...

How can I eliminate error CS0433 when using sgen.exe with a Silverlight Assembly

Hi, I'm attempting to run sgen.exe against a silverlight 4 assembly that I have created. The command line is: sgen.exe /a:"c:\MyPath\bin\Debug\myAsm.dll" This command returns the following error: Error: Unable to generate a temporary class (result=1). error CS0433: The type 'System.Net.CookieContainer' exists in both 'c:\Windows\Mi...