sgen

MSBuild cannot find SGen when compiling a solution

可紊 提交于 2019-12-05 04:53:35
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\Microsoft.NET\Framework\v3.5 folder, but that's not been done on the box where this is not a problem. In this scenario, SGen.exe actually exists and is right where it's supposed to be, but MSBuild still is having issues with finding it for some reason!

How to exclude specific types from serialization?

我只是一个虾纸丫 提交于 2019-12-05 03:29:17
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 specific type. Is there a way to exclude specific types from serialization? Apart from putting the types you wish to exclude in a different assembly, you cannot exclude types from the serializer generation. Update Other posters have come up with additional possibilities to exclude specific types, with varying applicability based on your use case. You can

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

天涯浪子 提交于 2019-12-05 02:03:58
问题 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 type that I will serialize (using sgen /t:Foo[]). Finally, I use ILMerge to merge the array type serialization classes into the Foo.XmlSerializers.dll assembly.

How to force Sgen to create .net 3.5 serializers assembly

╄→尐↘猪︶ㄣ 提交于 2019-12-04 17:56:22
I have a sgen build step in my .NET 3.5 library. In VS2010 this generates .NET 4 MyLib.XmlSerializers.dll, which cannot be loaded from .NET 3.5 apps. Does anyone know how to change build step to get correct version of the assembly? Is it possible to IL merge serializers assembly and library into single dll? This is my sgen build step: <Target Name="AfterBuild" DependsOnTargets="AssignTargetPaths;Compile;ResolveKeySource" Inputs="$(MSBuildAllProjects);@(IntermediateAssembly)" Outputs="$(OutputPath)$(_SGenDllName)"> <!-- Delete the file because I can't figure out how to force the SGen task. -->

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

雨燕双飞 提交于 2019-12-03 06:12:43
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 3.5). In Visual Studio 2008, I created a Web Reference which causes SGEN to execute during a Release build to create the helper DLL. If I don't reference the mixed-mode DLL , this works fine. If I do reference the mixed mode DLL, I get this error (xxx is just a placeholder): SGEN : error : An attempt was made to load an assembly with an incorrect format: C

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

旧巷老猫 提交于 2019-12-01 16:44:16
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 or it's enough to just (I use this syntax currently, I have only one Serializable class in my assembly): SGen.exe /assembly:MyAssembly When /type parameter can be useful in practice? 2) I read on MSDN ( http://msdn.microsoft.com/en-us/library/ee704594.aspx ) This

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

孤街浪徒 提交于 2019-12-01 16:33:12
问题 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 or it's enough to just (I use this syntax currently, I have only one Serializable class in my assembly): SGen.exe /assembly:MyAssembly When /type parameter can be

XmlSerializer not using XmlSerializers.dll created by sgen

别等时光非礼了梦想. 提交于 2019-12-01 15:44:46
问题 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)" /c:/keyfile:"c:\myproject\mykey.snk" /f My project is strong named, so use the same key to strong name the "XmlSerializers.dll". VS creates the XmlSerializers.dll in output folder. However, I have noticed using ProcessMonitor, .NET still invoke CSC.exe at

SGEN, InternalsVisibleTo and assembly signing

天大地大妈咪最大 提交于 2019-12-01 00:38:22
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 constructor. This would normally prevent the XML serialization, but I also marked the XML serialization assembly as "friend" with InternalsVisibleTo : [assembly: InternalsVisibleTo("TestXML2008.XmlSerializers")] And I added a MSBuild task to pre-generate the serialization assembly : <Target Name="AfterBuild"

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

℡╲_俬逩灬. 提交于 2019-11-29 10:56:37
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 additional configuration information." In the 'File' column of the Visual Studio's error list is the word 'SGEN', but when I double-click, the file does not exist ("The document cannot be opened. It has been renamed, deleted or moved.") I gather it has something to do with serialization, but what is the required additional configuration information? I