Using Novell.Directory.Ldap in mono (for Android and Touch)

I want to use the Novell.Directory.Ldap library in a MonoTouch and Mono project for Android. http://www.novell.com/coolsolutions/feature/11204.html

When I compile my project in the iOS simulator module, it compiles without errors and works correctly (in the iOS simulator).

When I compile my project in the iOS device module (to test the application using a physical device), I get this error:

Error MT2002: Failed to resolve "System.Void System.Security.Cryptography.RNGCryptoServiceProvider::.ctor(System.Byte[])" reference from "mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" (MT2002) (MyProject) 

How can I solve this problem? I can not find a solution.

Should this library work in MonoTouch and Mono for Android? Are there better LDAP solutions for Mono?

UPDATE: I just tested it with Mono for Android. It works great.

+4
source share
2 answers

The problem is resolved.

Instead of using the dll from Novell, I downloaded all the source files for the Novell LDAP library and put them in a new library project. Then I made a link to this library from my own Mono project.

When compiling my project and the library project, I got some errors from the library project. After resolving these errors manually, it works great for both (MonoTouch and Mono for Android).

+3
source

There are three questions, so I divided my answers three times. Please read all :-)

How can I solve this problem?

This is a common problem with a common solution to solve it.

The compiled code includes a link to "mscorlib, Version=1.0.5000.0

Most likely, because you did not use the compiler with Xamarin.iOS (MonoTouch), called smcs , to build the assembly. This compiler has set up links for using the right assembly mscorlib.dll (and report everything that is not in the MOBILE profile).

The fact that it can work for Xamarin.Android is that it uses JIT (only at compile time), so missing elements will not be found until runtime (and if execution reaches this code).

OTOH Xamarin.iOS uses AOT (compilation by time), since JIT'ing is not allowed (Apple) on devices. This means that the missing members are in the build . In this case, the (managed) linker cannot find the link and throw an MT2002 error.

So, the solution is to rebuild the assembly using smcs and fix, if any, build-time errors. For instance. IIRC that the RNGCryptoServiceProvider ctor is unavailable (and does nothing, since seeding is not possible) and should be replaced with the default ctor.

Should this library work in MonoTouch and Mono for Android?

Must. However, my personal experience with Novell.Directory.Ldap was not really good (problems with code and design, for example, streaming, in particular with SSL support).

Also, the code has not been updated for quite some time. You might be better off looking for (managed or native) alternatives for your LDAP needs.

Are there any better LDAP solutions for Mono?

Unfortunately, I did not use another similar library, so I can not offer alternatives (but maybe other people will be able to help).

+7
source

Source: https://habr.com/ru/post/1468909/


All Articles