In Xamarin ios build i am getting the error loading assemblies mongocrypt.dll

I am using MongoDB Driver nuget package version 2.19.1 in Xamarin iOS project and when i try to build i am getting the error error loading assemblies mongocrypt.dll. The last version that was working was 2.10.4.
How do i fix this error with version 2.19.1?

Thanks in advance

Hi, @Balasubramanian_Ramanathan,

Welcome to the MongoDB Community Forums. mongocrypt.dll is an unmanaged DLL implementing features for Client-side Field-Level Encryption (CSFLE) and Queryable Encryption (QE). If you are not using these features, you can exclude the MongoDB.Libmongocrypt NuGet package (which references mongocrypt.dll) from your build process.

Sincerely,
James

Could you please tell me, How can i exclude the dll from the build process. It is implicitly referenced package.

Thanks

As you have said i excluded the MongoDB.Libmongocrypt from the .nuspec file and it is building. Will there be an official fix for this?

Thanks

I’m glad that you were able to get your project building by excluding MongoDB.Libmongocrypt. We are considering making changes to how we package the driver. This wouldn’t happen until the next major release because it would involve breaking changes. Follow CSHARP-4442 and CSHARP-4531 for updates.

I am not able to get it to work with 2.19.2. It does not work for arm64 devices even though i exclude the mongocrypt.dll. After excluding this it works in iPhone simulato(which is x86 but it fails to build for ios devices. they are trying to link windows registry which is not available for ios devices(arm 64). i fall back to 2.10.4. Please fix this.

I managed to upgrade to version 2.17 by adding

<PropertyGroup>
    <RuntimeIdentifiers>osx;osx-x86;osx-x64</RuntimeIdentifiers>
    <NuGetRuntimeIdentifier>osx</NuGetRuntimeIdentifier>
</PropertyGroup>

to the ios project

however when i upgrade the stable 2.19.2 i get this error

could not aot the assembly zstdsharp.dll.

This is a newly added dependency in 2.18. why do we have it? do we really need it?

With 2.17 when the connection string has +srv (dns seed list connection string) i am getting this error ```

List of configured name servers must not be empty.

In Windows with 2.19.2 this is working. But with ios i cant use the +srv in the connection string. When +srv in the connection string it works in the simulator. when i deploy it to the device i get the error

List of configured name servers must not be empty.

ZstdSharp.Port is a third-party managed library implementing the zstd compression algorithm. The driver uses it for wire protocol compression. It is not required unless you enable the zstd compressor for compressing network traffic. (It is off by default.)

Regarding the error List of configured name servers must not be empty. is from DnsClient.NET, the third-party library that we use for looking up SRV and TXT records in DNS. Mobile devices often have their DNS configuration locked down preventing DnsClient.NET from initializing.

The .NET/C# Driver is designed to work in server environments, not on mobile devices. For mobile development we recommend using the MongoDB Realm .NET SDK.

Sincerely,
James

Thank you for the information. It would be great to use the MongoDB Driver in xamarin ios/andorid applications. Because the drivers support .net standard they should be able to run on xamaring ios/android applications. The version 2.17 is working fine with xamarin ios. With 2.19 ZstdSharp.Port is causing problem. It has been newly added in 2.19.

I have released a MongoDB Client for iOS in the appstore ‎MongoDBProg2 - MongoDB Client on the App Store using the mongodb driver in ios side and also as a server side in bridge server.

Thank you for answering my all questions.

That is fantastic that you released your project in the AppStore. Congratulations!

As for the ZstdSharp.Port problem, I would suggest filing a bug with that project. Once it is resolved, we can pull in the updated dependency. ZstdSharp.Port is a completely managed implementation of the zstd compression algorithm. Therefore I’m not sure why Xamarin’s AOT compiler can’t process it.

Sincerely,
James