<$BlogRSDURL$>

A splat of all my blathering.

Monday, April 12, 2004

The XmlSerializer Generates Code At Runtime 

The XmlSerializer inspects your serialized type and generates code on the fly using the Code Document Object Model (CodeDom) to serialize and deserialize instances of it. Normally this code is deleted as soon as it is compiled into an assembly. To see the code generated by the compiler, you must add a switch to the machine.config (or web.config) file to keep compiler-generated files around. To do this, follow these steps:
Open the machine.config file in a text editor, such as Notepad.
Add an XmlSerialization.Compilation switch to the system.diagnostics section of the code, as follows:


<configuration>
 <system.diagnostics>
  <switches>
   <add name="XmlSerialization.Compilation" value="4"/>
  </switches>
 </system.diagnostics>
</configuration>

Run the client application that does XML Serialization.

Look in the %temp% directory for a recently created .cs file. There will be several others as well. Note: if this is a web app (i.e. web service) then look under %windir%\temp. The .cs file is the generated source. The .out file should have any compiler errors.

You should also be aware of the permissions needed to do this: http://support.microsoft.com/default.aspx?scid=kb;EN-US;823196

Posted at 4/12/2004 05:13:00 PM |
Comments: Post a Comment

This page is powered by Blogger. Isn't yours?