On my ASP.NET web API , I have a method that parses some data from email messages using MsgReader . It works fine, but after a while it starts throwing the following exception:
System.IO.FileNotFoundException: Could not load file or assembly 'MsgReader.resources, Version=2.1.3.0, Culture=en-US, PublicKeyToken=47f99f3a9a2648df' or one of its dependencies. The system cannot find the file specified. File name: 'MsgReader.resources, Version=2.1.3.0, Culture=en-US, PublicKeyToken=47f99f3a9a2648df' ---> System.IO.FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002) at System.Reflection.RuntimeAssembly.nLoadFile(String path, Evidence evidence) at System.Reflection.Assembly.LoadFile(String path) at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName) at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark& stackMark) at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark& stackMark) at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark) at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark) at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents) at System.Resources.ResourceManager.GetString(String name, CultureInfo culture) at MsgReader.Mime.MessagePart..ctor(Byte[] rawBody, MessageHeader headers) in C:\Users\Kees\Documents\GitHub\MsgReader\MsgReader\Mime\MessagePart.cs:line 242 at MsgReader.Mime.Message..ctor(Byte[] rawMessageContent, Boolean parseBody) in C:\Users\Kees\Documents\GitHub\MsgReader\MsgReader\Mime\Message.cs:line 139 at MsgReader.Mime.Message.Load(Stream messageStream) in C:\Users\Kees\Documents\GitHub\MsgReader\MsgReader\Mime\Message.cs:line 301 at MsgReader.Outlook.Storage.Message.LoadClearSignedMessage(IStorage storage) in C:\Users\Kees\Documents\GitHub\MsgReader\MsgReader\Outlook\Message.cs:line 1558 at MsgReader.Outlook.Storage.Message.LoadStorage(IStorage storage) in C:\Users\Kees\Documents\GitHub\MsgReader\MsgReader\Outlook\Message.cs:line 1384 at MsgReader.Outlook.Storage..ctor(Stream storageStream, FileAccess fileAccess) in C:\Users\Kees\Documents\GitHub\MsgReader\MsgReader\Outlook\Storage.cs:line 196 ...
After I reuse the application pool, it works again (for a while), and then the error is repeated for a while ...
I tried with assemblyBinding
<dependentAssembly> <assemblyIdentity name="MsgReader" publicKeyToken="47f99f3a9a2648df" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-2.1.3.0" newVersion="2.1.3.0" /> </dependentAssembly>
but without success ...
I think the problem is related to culture? Since, as I see by mistake, the culture is en-US, but only these cultures exist in the MsgReader package :

This is the part of the code where the exception is thrown:
var fileType = Path.GetExtension(fileName)?.Replace(".", "").ToLower(); if (fileType == "msg") { using (var stream = new MemoryStream(file)) using (var msg = new Storage.Message(stream))