I have a website which runs in IIS 7.0 in an Integrated v4.0 application pool. Starting from today I get the below exception in the Windows event Log. The website is online for 1 month and I never got this exception before. I get the exception at the same minutes in every hour which is a little bit strange.
Some possible reason:
I have a library that I created that I load dynamically.
_searchProvider = (ISearchProvider)Activator.CreateInstance("SolrSearchProvider", "SearchProviders.SolrSearchProvider.SolrSearchProvider").Unwrap();
That library has reference to SolrNet.
Do you have any idea what the problem may be or how to investigate more into finding a solution ???
An unhandled exception occurred and the process was terminated.
Application ID: DefaultDomain
Process ID: 7192
Exception: System.Runtime.Serialization.SerializationException
Message: Unable to find assembly 'SolrNet, Version=0.4.0.1001, Culture=neutral, PublicKeyToken=bc21753e8aa334cb'.
StackTrace: at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name)
at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.AppDomain.Deserialize(Byte[] blob)
at System.AppDomain.UnmarshalObject(Byte[] blob)
Mauricio Scheffer said: @Dorin: then the real problem is the circular dependency. I recommend posting a new question about that.
I solved the problem with circular dependency and I keep getting the same error in the Windows Event Logs.
First I get Unable to find assembly 'SolrNet, Version=0.4.0.1001, Culture=neutral, PublicKeyToken=bc21753e8aa334cb'
and then the web applicatioin is restarting.
3 to 10 seconds before I get an exception in windows logs, I identified an expcetion in my site log files thrown by entity framework because I was trying to insert an item with the same primary key as an existing one. The exception was not treated in the code but was treated by asp.net because of the CustomErrors settings
<customErrors mode="On" defaultRedirect="/Error.aspx" redirectMode="ResponseRewrite">
<error statusCode="404" redirect="/Error.aspx"/>
</customErrors>
Can this have anything to do with the error in windows log files ??
I found this statement on a blog post that besides the subject, also speaks about why an application pool might go down
"An unhandled exception in a thread not associated with a request will take down the process. This occurs even if you have a handler setup via the Application_Error method."
For some types of requests I create 8 new threads from the request threads to make simultaneous query to 8 different cores of my SOLR. In one of this cores I was getting an exception that I did not handled in that thread and that got me into the posted problem.
I hope that this helps somebody else if they encounter a similar error. Thanks a lot guys for the help. Because of your answers I improved my code and I discovered and fixed other errors not related to the question. Also I started to look more into how ASP.NET loads assembly which was for a great help.