Crazy .net / Sharepoint error involving random temp files not found
Logged into a customer environment today to check logs and just generally do an inspection, only to notice some tasks had failed in one application.
Application is written in c# .net v4 running inside of IIS and exports to Sharepoint 2007.
I can't be 100% sure if .net or SharePoint is the culprit. These are the errors I got:
Task Failed: Server was unable to process request. ---> Could not find file 'C:\Windows\TEMP\qbckfur开发者_如何学运维1.dll'.
Export 26.05.2011 15:00:21 Failure Task Failed: Server was unable to process request. ---> Could not find file 'C:\Windows\TEMP\2shjg2xb.dll'. Export 26.05.2011 15:30:13 Failure Task Failed: Server was unable to process request. ---> Could not find file 'C:\Windows\TEMP\b7utp199.dll'. Export 26.05.2011 16:00:15 Failure Task Failed: Server was unable to process request. ---> Could not find file 'C:\Windows\TEMP\ozr2umkm.dll'.
Does this look familiar to anyone?
This is a problem with XmlSerialization
(beleive it or not). I ran into this with a custom ASP.NET MVC app. Apparently, when you call Serialize
or Deserialize
on types marked as "Serializable", .NET will generate an assembly on-the-fly to support the serialization and it attempts to write that assembly into 'c:\windows\temp'.
Even if Everyone
has full control access to that directory I have still seen this occur when running an app from within an IIS App Pool. Especially in applications that has a lot of serialization activity.
If this sounds like your problem, the solution is to "pre-compile" the Serialization assembly and include it in your application with sgen
, part of the Windows SDK.
This post highlights a similar issue: Serialization issue on MSDN Social
Here is the MSDN article on the tool: sgen reference
Final Note: There is a separate version of the Tool for .NET 4.0 so make sure you are using the correct version when generating your assembly.
精彩评论