fredag den 3. februar 2012

Visual C# Command Line Compiler has stopped working.

A few months back, after running Windows Update on all our Remote Desktop and XenApp 6.0 servers, users of 2 applications would get the below error.
image
The applications would only get the error on XenApp, but not the Remote Desktop servers. One of our XenApp servers had been taken out of production for some tests, and had not been updated, and when running the same applications on that server, we would not get the above error.
We run all applications within Application Virtualization Client. While investigating this error we also noticed that the error did not turn up, when run outside App-V. So what is happening ? notice that the application that is crashing is the .NET C# command line compiler, and not the application it self. When attaching Windows Debugger to one of the application we could see the application would still be running after that dialog had been shown, after once you click close the following exception would be thrown inside the application.
Exception type: System.IO.FileNotFoundException
Message: Could not load file or assembly 'mscorlib.XmlSerializers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
InnerException: System.IO.FileNotFoundException

I found several similar cases on Google, but none exactly like ours.
http://connect.microsoft.com/VisualStudio/feedback/details/93647/xml-serializer-throws-file-not-found-exceptions
and
http://blogs.msdn.com/b/asiatech/archive/2010/08/02/could-not-find-the-file-c-windows-temp-lt-xml-serializer-random-generated-file-name-gt-dll.aspx
We created a Support case at Citrix and the 2 3rd party company’s. They both managed to find a work around but in different ways. One found this link http://stackoverflow.com/questions/1127431/xmlserializer-giving-filenotfoundexception-at-constructor/1642941#1642941 and noticed changing this worked in our case
clip_image001
The other vendor had seen the error before and recommended following this guide http://forums.citrix.com/thread.jspa?threadID=273000 but that did not work. After some more troubleshooting they found a workaround but wouldn’t tell me what it was, and wouldn’t give us a fix to make the application work, so we had to continue the support case at Citrix.
After troubleshooting, running various debug tools and sending and endless streams of crash dumps, we finally managed to find a work around that made all applications work.
It is kind of similar to the above mentioned fix. Add the following registry key. ( you don’t need to restart the server, but you will need to logoff and back on to see if it fixed your problem). Simply add the following registry key
Key: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Citrix\CtxHook
Value Name: ExcludedImageNames
Type: REG_SZ
Value: csc.exe,cvtres.exe