Out of nowhere today I rebooted my Exchange server (that has been up and running for several years without problems) then users could no longer delete their messages – they would just receive an unfriendly message stating that “An unexpected error occurred and your request could not be handled”. The event log showed the following error every couple of seconds:
Event 3, System.ServiceModel 3.0.0.0
WebHost failed to process a request. Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/20974680 Exception: System.ServiceModel.ServiceActivationException: The service '/EWS/Exchange.asmx' cannot be activated due to an exception during compilation. The exception message is: The type initializer for 'Microsoft.Exchange.Services.Wcf.MessageInspectorManager' threw an exception.. ---> System.TypeInitializationException: The type initializer for 'Microsoft.Exchange.Services.Wcf.MessageInspectorManager' threw an exception. ---> System.InvalidOperationException: Unable to generate a temporary class (result=1). error CS0016: Could not write to output file 'c:\Windows\Temp\fngfonmg.dll' -- 'The process cannot access the file because it is being used by another process. ' at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence) at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly assembly, Hashtable assemblies) at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location, Evidence evidence) at System.Xml.Serialization.XmlSerializer.GenerateTempAssembly(XmlMapping xmlMapping, Type type, String defaultNamespace) at System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace) at Microsoft.Exchange.Services.Wcf.MessageInspectorManager..cctor() --- End of inner exception stack trace --- at Microsoft.Exchange.Services.Wcf.MessageInspectorManager..ctor() at Microsoft.Exchange.Services.Wcf.MessageInspectorBehavior.ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) at System.ServiceModel.ServiceHostBase.InitializeRuntime() at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath) at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) --- End of inner exception stack trace --- at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath) Process Name: w3wp Process ID: 5564
For my particular error, in order to fix this I had to:
1. Grant modify permissions for the IIS_IUSRS group to the C:\Windows\Temp folder. 2. Restart Exchange 3. Restart IIS