Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XmlSerializer.Deserialize() uses the temp directory?

31 views
Skip to first unread message

Mark

unread,
May 15, 2009, 11:32:14 AM5/15/09
to
Hi...

I was looking at Red Gate's ANTS profiler and tripped across a puzzling
thing. For some reason, when ANTS attaches to the ASP.Net worker process,
it's changing how the permissions work with the shadow cache and the temp
directory.

The puzzling thing I found for this group is that one of the calls blowing
up was a call to XmlSerializer.Deserialize(), taking a dom already in memory
and converting it to objects. It blew up saying that the process didn't have
access to the temp directory. What's it trying to do in the temp directory?

Thanks
Mark

Martin Honnen

unread,
May 15, 2009, 12:58:50 PM5/15/09
to
Mark wrote:

> The puzzling thing I found for this group is that one of the calls blowing
> up was a call to XmlSerializer.Deserialize(), taking a dom already in memory
> and converting it to objects. It blew up saying that the process didn't have
> access to the temp directory. What's it trying to do in the temp directory?

I think XmlSerializer generates assemblies to perform
serialization/deserialization. From the documentation: "the XML
serialization infrastructure dynamically generates assemblies to
serialize and deserialize specified types".

--

Martin Honnen --- MVP XML
http://msmvps.com/blogs/martin_honnen/

Jie Wang [MSFT]

unread,
May 18, 2009, 5:41:08 AM5/18/09
to
Hi Mark,

Martin was right (thank you Martin).

As the document states:

To increase performance, the XML serialization infrastructure dynamically
generates assemblies to serialize and deserialize specified types. The
infrastructure finds and reuses those assemblies. This behavior occurs only
when using the following constructors:

XmlSerializer.XmlSerializer(Type)

XmlSerializer.XmlSerializer(Type, String)

* End quote *

The XmlSerializer actually calls an internal class
System.Xml.Serialization.TempAssembly to generate temp assembly, and the
TempAssembly class will call another internal class
System.Xml.Serialization.Compiler to do the compilation (using C# compiler).

From the code of System.Xml.Serialization.Compiler class, we can see it
will use the temp directory for its job (calls Path.GetTempPath).

If you use the Process Monitor tool
(http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx) to observe
the ASP.NET worker process, you'll see .cs / .dll / .pdb and some other
file operations in the temp directory.

So if the profiler changed the worker process's permissions in the temp
directory, an exception is expected.

Hope together with Martin, we have clarified your question.

If you have any further questions regarding this issue, please feel free to
post here.

Regards,

Jie Wang (jie...@online.microsoft.com, remove 'online.')

Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msd...@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business days is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jie Wang [MSFT]

unread,
May 20, 2009, 11:49:41 PM5/20/09
to
Hi Mark,

Haven't heard from you for some days. How's going on this issue?

Do you still need further information or assistance? Please kindly let me
know.

Thanks,

samwids

unread,
Jun 15, 2009, 8:27:02 AM6/15/09
to
Hi Jie,

Thanks for clearification. How can I define the temporary folder to be used
by XmlSerializer as it would not be feasible (security concern) to share same
folder for creating and compiling these temporary files.


Regards,

0 new messages