开发者

Creating XMLSerializer in .NET throws exception

We have an old asp application that instantiates a .NET com visible class. In this class, we do some serialization to store our object in the session.

When I call the following line of code in my test class, it works fine.

var cereal = new XmlSerializer(couponApplicator.GetType());

However, when it gets called in the website and I am debugging, it throws the following error:

{"Cannot execute a program. The comma开发者_JS百科nd being executed was \"C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\csc.exe\" /noconfig /fullpaths @\"C:\\WINDOWS\\TEMP\\rwot-yx9.cmdline\"."}  System.SystemException {System.Runtime.InteropServices.ExternalException}

I thought maybe it was permissions related so I tried giving 'EVERYONE' full control to the windows/microsoft.net folder as well as the windows/temp folder. For reference, I am running this on a Windows XP machine. Any ideas?


Figured it out.

The IIS Lockdown tool had set deny permissions to all *.exe executables in the windir directory. I therefore had to remove the deny access privileges on these two files in the windows/microsoft.net/framework/v2.0/ folder

cvtres.exe

csc.exe

Then, I gave the IUSR and IWAM accounts read and execute permissions on both those files as well as the windows temp directory.

Here is a great post explaining more details: http://www.evilrob.org/journal/archives/2005/05/16/iusriwam-accoun.html


I have found that I have problems with the serialization assemblies as I use XML serialization quite a bit to persist application settings, etc when I work on Windows apps. What I have found is that I have been much more successful deploying in a LUA environment by creating the Serializer types ahead of time using sgen instead of creating them on the fly at runtime.

If you really don't need to create them dynamically at runtime it may be worth looking into. It's pretty straight foward to do. Just make a post build event in your .NET project that calls sgen on the assembly that contains the types you want to serialize (make sure they are marked [Serializable()]), the just include the *.XmlSerializers assembly that is created when you deploy and you shouldn't have to worry about any special permissions when you use the XmlSerializer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜