Search code examples
c#mongodbhangfire

Unable to load file or assembly mongocrypt


System.BadImageFormatException: 'Could not load file or assembly 'mongocrypt' or one of its dependencies. The module was expected to contain an assembly manifest.'

I have a project that runs Hangfire 1.7.5 with MongoDB 2.9.1.0. This project is used as a backend engine to perform various types of work.

In order to create endpoints for outside systems to call this engine, we have another project that uses the same versions of Hangfire and MongoDB to connect and pass in the jobs for processing.

I upgraded Hangfire and Mongo to the latest versions, 1.7.9 and 2.10.1.0 respectively in all the projects that were using these dlls. Using Visual Studio, when I run the web projects, I keep getting the above mentioned error. I get these like 4 to 5 times before the ASP.Net site loads up and allows me to access anything I need, including the data that is accessed via MongoDB. Just an inconvenience but still an exception when loading project.

I know that architecture of the CPUs might cause the System.BadImageFormatException but nothing in that sense has been changed. I am running everything on .net 4.6.1 and everything continues to run on AnyCPU configuration. If I change all these projects to x64 or x86, one or the other thing stops working. mongocrypt error continues to occur regardless of the CPU architecture.

I cant find anything on google or SO regarding mongocrypt. Any ideas?


Solution

  • Same thing happened to us. It appears that in v2.10.0 a new dependency library was introduced libmongocrypt that causes this error.

    Try to go back to v2.9.3 to workaround this issue until it is fixed by mongodb programmers.