2

I'm working on Android App in Xamarin with C# code.

I have a library dll created by me that I'm using has an reference in the AndroidApp.

But I have a problem with one file.

It includes this:

using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;

This works fine in the original library, but using it has reference in my AndroidApp project makes app crash while is loaded, it opens but right after it crashes and without the file that includes this two references it works fine.

I know it because I've commented the code that uses this references and then works fine.

The output doesn't show any information about this error

4
  • 1
    do you have any reason to believe that this library will work with Android? Not every arbitrary .NET library will work in Xamarin projects Commented Mar 7, 2018 at 16:38
  • Yes because if I comment that part, it works!! Commented Mar 7, 2018 at 16:59
  • 1
    that would lead me to the exact opposite conclusion Commented Mar 7, 2018 at 17:30
  • You're not understanding. I need that library to reuse code. When I add it to android project doesn't show any error, but it crashes. But I'm not calling the method in any time Commented Mar 7, 2018 at 17:42

1 Answer 1

1

In most cases of 3rd party libraries, the C#(CIL) just invoke the native(C/C++) functions. Not implemented by itself even though the CoreFX.

It means that if the library has been implemented in target platform's (Android in your case) native code, you can invoke them in C# using DLL import or binding library otherwise impossible.

If you planned to make a shared assembly, you must check portability of the dependencies first. For example, the System.Drawing.Bitmap is possible in .NET Framework but Xamarin. Therefore, you must not use it in shared assembly which for .NET Framework and Xamarin.

And this is really helpful for it. The .NET API browser. You can search any class of C# and get the portability information about .NET Core, Standard, Framework, Xamarin and so on.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.