CanDeserialize does not work with generated assemblies using sgen.exe


hi


i have following example code demonstrate problem.

using system.xml;  using system.xml.serialization;    namespace consoleapplication1  {  	public class program  	{  		public static void main(string[] args)  		{  			xmlserializer serializer = new xmlserializer(typeof(example));  			xmlwriter writer = xmlwriter.create("test.xml");  			example input = new example { text = "test" };    			serializer.serialize(writer, input);  			writer.close();    			xmlreader reader = xmlreader.create("test.xml");    			bool candeserialize = serializer.candeserialize(reader);  			example result = (example)serializer.deserialize(reader);  		}    		[xmlroot("example", namespace = "http://tempuri.org/example")]  		public class example  		{  			[xmlattribute("text")]  			public string text { get; set; }  		}  	}  }
if run code, value of candeserialize true (like should be).

if add a post build step speeds xmlserializer constructor (and generates serialization assemblies on compile time) candeserialize method not working anymore. return false, example object still deserialized correctly.

my post build step looks this:
"[path sgen.exe]\sgen.exe" "$(targetpath)" /force

i tried sgen.exe windows 6.0a sdk (version: 2.0.50727.3038) , 1 windows 6.1 sdk (version: 2.0.50727.1432).
i'm using vs2008 , .net framework 3.5 sp1.

did wrong or bug?


thanks help.

ddpommes




hi,

known bug. not sure if s fixed in .net 4.0 though

https://connect.microsoft.com/visualstudio/feedback/viewfeedback.aspx?feedbackid=365862

workaround given there :

var factory = new xmlserializerfactory();
var serializer = factory.createserializer(typeof(t));

able reproduce issue , workaround suggested above seems working.
please mark response answers if solves question or vote helpful if find helpful. http://thoughtorientedarchitecture.blogspot.com/


Archived Forums A-B  >  ASMX Web Services and XML Serialization



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'