The Artima Developer Community
Sponsored Link

.NET Buzz Forum
XmlSerializer Madness: The Guts and the Conclusion

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Scott Hanselman

Posts: 1031
Nickname: glucopilot
Registered: Aug, 2003

Scott Hanselman is the Chief Architect at Corillian Corporation and the Microsoft RD for Oregon.
XmlSerializer Madness: The Guts and the Conclusion Posted: Dec 5, 2003 11:01 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Scott Hanselman.
Original Post: XmlSerializer Madness: The Guts and the Conclusion
Feed Title: Scott Hanselman's ComputerZen.com
Feed URL: http://radio-weblogs.com/0106747/rss.xml
Feed Description: Scott Hanselman's ComputerZen.com is a .NET/WebServices/XML Weblog. I offer details of obscurities (internals of ASP.NET, WebServices, XML, etc) and best practices from real world scenarios.
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Scott Hanselman
Latest Posts From Scott Hanselman's ComputerZen.com

Advertisement

Looks like a little bit of wisdom from Kevin Dente has solved the mystery.

He sez:

A little Reflectoring into the XMLSerializer source shows that in .NET 1.1 it caches the temp assembly using both the type and default namespace as the key. However, 1.0 cached only on the type, and if you specified a namespace it ignored the cache. And it looks like even in 1.1 the other constructor overloads ignore the cache. Good to know.

And the reflectoring shows just that: (Note the Monitor.Enter [lock()] around their cache)

public XmlSerializer(Type type, string defaultNamespace){ 
  XmlReflectionImporter importer1;
  TempAssemblyCache cache1;
  this.events = 0;
  base..ctor();
  this.events.sender = this;
  this.tempAssembly = XmlSerializer.cache[defaultNamespace, type];
  if (this.tempAssembly == null){
    cache1 = XmlSerializer.cache;
    Monitor.Enter(XmlSerializer.cache);
    try{
       this.tempAssembly = XmlSerializer.cache[defaultNamespace, type];
       if (this.tempAssembly == null){
          importer1 = new XmlReflectionImporter(defaultNamespace);
          this.tempAssembly = XmlSerializer.GenerateTempAssembly(importer1.ImportTypeMapping(type));
          XmlSerializer.cache.Add(defaultNamespace, type, this.tempAssembly);
     }
}
finally{  Monitor.Exit(cache1); } } }

Read: XmlSerializer Madness: The Guts and the Conclusion

Topic: Is your son a hacker [satire]? Previous Topic   Next Topic Topic: Limiting Callers to a .NET Assembly

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use