• Not Answered

Unable to find assembly Lucene.Net

Hi,

once in a while I am getting an error in the application event logs telling the Lucene.net assembly could not be found which makes IIS process to crash! I first looked to ensure the DLL was in the bin folder with proper version, culture and PublicKeyToken and it does. I then turned on FusionLogs to see why it is not finding that assembly. The FusionLogs creates log files in separate folders for each process detailing assembly binding path lookup flow. I can see that in one specific folder (e.g. c7b5fa2f) that my assembly is found and loaded from the bin folder as expected. I imagine this is the folder created for my w3wp process for my web site. However, it appears that it fails to do so as reported in another folder named w3wp.exe (rather than the griberish name). Looking at the fusion logs it appears that it is looking for that assembly directly under c:\windows\system32\inetsrv!! Here is an excerpt of the fusion logs:

LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///c:/windows/system32/inetsrv/Lucene.Net.DLL.
LOG: Attempting download of new URL file:///c:/windows/system32/inetsrv/Lucene.Net/Lucene.Net.DLL.
LOG: Attempting download of new URL file:///c:/windows/system32/inetsrv/Lucene.Net.EXE.
LOG: Attempting download of new URL file:///c:/windows/system32/inetsrv/Lucene.Net/Lucene.Net.EXE.
LOG: All probing URLs attempted and failed.

Below is the actual event log which is causing the IIS process to crash:

An unhandled exception occurred and the process was terminated.

Application ID: DefaultDomain

Process ID: 3504

Exception: System.Runtime.Serialization.SerializationException

Message: Unable to find assembly 'Lucene.Net, Version=3.0.3.0, Culture=neutral, PublicKeyToken=85089178b9ac3181'.

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)

 

Thanks for helping out,

Pascal

8 Replies

  • Hi Pascal,

    Any chance you're using impersonation in your code to change a user security context? That would explain why it works originally, but crashes at some point later, when u impersonate a different user, which doesn't have access to the assembly in your website folder.

    Cheers,
    Martin
  • In reply to Martin Ivan:

    Not using impersonation. Still, how would it be possible for the w3wp process to look for that assembly under inetsrv without ever probing the bin folder? I have copied the Lucene.net.dll in my inetsrv and did not see the error so far but it is non-sense for me to apply such a fix.
  • In reply to Pascal Houde:

    I now have a new error manifesting which is also causing the w3wp to crash:
    Exception: System.Runtime.Serialization.SerializationException

    Message: The constructor to deserialize an object of type 'Lucene.Net.Index.MergePolicy+MergeException' was not found.

    StackTrace: at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)
    at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)
    at System.Runtime.Serialization.ObjectManager.DoFixups()
    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)
  • In reply to Pascal Houde:

    Your process is probing the default locations (inetsrv) instead of starting in your bin folder - this could indicate that the process doesn't have access to the bin folder? Can u also log the successful bindings just to verify where it gets originally loaded from?

    The reason why I suggested impersonation is that I've seen this personally in the past + there are many references online documenting the same issue - e.g. https://stackoverflow.com/questions/11096225/could-not-load-file-or-assembly-or-one-of-its-dependencies-access-is-denied-th. This one provides other options how to go about your issue.

    BTW: The output from FusionLog - is it a complete trace or just an excerpt?

     

    Any chance you can also provide your IIS logs at the time your app pool crashes?

     

    /Martin

  • In reply to Pascal Houde:

    Hmm...any chance you're using custom modules/DLLs, which were compiled against different version of Lucene? Or different versions of .NET framework vs the one your app pool is running under?
    Alternatively, I saw people fixing it by cleaning up their indexes and rebuilding them.

    /Martin
  • In reply to Martin Ivan:

    Martin,
    I initially went with the path of rebuilding my indexes but I was still receiving the error. This is when I decided to put the Lucene.Net.dll in the inetsrv folder until I find a better solution. It occurred to me that when I rebuilt the index I did not delete physically the files it stores in the data folder. I deleted all of them then rebuild again. I took the Lucene.net.dll out of the inetsrv and iisreset. I have been monitoring the event log and fusion logs since and I have not seen the error again. I will continue spot checking today and tomorrow and assume the error is fixed if I don't see anymore occurrences.

    The only custom module we are using is WeBlog and I don't see Lucene being referenced. The target framework for that assembly is 4.5.2 which is fine.

    Pascal
  • In reply to Pascal Houde:

    Just for sake of anyone else, who runs into this - is it working for you now, Pascal?
  • In reply to Martin Ivan:

    Yes it does. Thanks