Watch keynotes and sessions from, our virtual developer conference.

C Sharp Driver - Cannot find mongocrypt.dll

I have setup CSFLE using the C Sharp driver and was able to encrypt a field in a document. I am now trying to read that document using the same driver.

When I execute
var clientEncryption = new ClientEncryption(clientEncryptionSettings);
it fails with the following error
System.IO.FileNotFoundException: ‘Could not find: mongocrypt.dll –
Tried: C:\Users\brian.bernholtz\AppData\Local\Temp\Temporary ASP.NET Files\vs\a629dec2\a52e73f9\assembly\dl3\451c2076\009d89cc_8b9ad501…\x64\native\windows\mongocrypt.dll,C:\Users\brian.bernholtz\AppData\Local\Temp\Temporary ASP.NET Files\vs\a629dec2\a52e73f9\assembly\dl3\451c2076\009d89cc_8b9ad501\mongocrypt.dll’

The mongocrypt.dll file is clearly in my BIN directories. I even tried physically copying the file from my local BIN dir to the temp location specified and it still bombs out with same error.

Any thoughts on why I cannot find this DLL?

I should note, I have tried it with version 2.10 and 2.10.4 with the same result. 2.9 does not have the mongocrypt.dll dependency and doesnt seem to support CSFLE

Hi @Brian_Bernholtz, welcome!

It’s been a while since you posted this question, have you found a solution yet ?

Could you provide the .csproj file for the application? Are you importing MongoDB.Libmongocrypt ?

Also, would you be able to try to disable shadow copying ? For example in your Web.config:

    <hostingEnvironment shadowCopyBinAssemblies="false" />


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.