Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# .dll library in Android app

I'm currently using Monodroid to develop an android app. I'm rather new to phone apps so am confused over a couple things:

  1. What by definition is an android library? I use the Mono template to create android library: Create a Mono for Android Class Library => write the code and build into .dll => run with emulator from Visual Studio and it works fine in the emulator. But is the .dll file a android library? Or it is converted by Mono before working on the emulator and the 'REAL' android library should be JAR?

  2. Can I directly use my defined .dll written in C# to make this app? I tried it in Mono by directly referencing it in my android app and it is building, no errors. But when the emulator run this app, it get stucked (still no error) - what is the right way to use c# .dll in Android app project?

I realize there are quite a couple topics discussing the link between c# and android and about mono but after reading I still cannot get around with this library referencing problem so if anyone could offer any hint/thoughts would be most appreciated

like image 988
lynnyilu Avatar asked Dec 06 '11 02:12

lynnyilu


People also ask

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

Is C language easy?

Compared to other languages—like Java, PHP, or C#—C is a relatively simple language to learn for anyone just starting to learn computer programming because of its limited number of keywords.

What is C in C language?

What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.

What is the full name of C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.


1 Answers

  1. The DLL generated is compiled against the Mono for Android profile, which is based on Moonlight (Mono's implementation of Silverlight). At runtime, .NET code is run directly against the Mono runtime which runs as part of your application. When .NET code subclasses something from the Java side (e.g. Java.Lang.Object), Mono for Android generates callable wrappers to handle communication between runtimes.
  2. Technically you can use a normal .NET DLL in your Mono for Android application, but I wouldn't recommend it. The profile exposed by Mono for Android is much smaller than that of the full .NET framework (and isn't even completely equivalent to that of Silverlight), so if your DLL references a method that isn't found in Mono for Android, your application will crash. Instead, I would recommend creating a separate class library for your application, and share source files across projects using file linking. My blog post here contains an example of how to do that.
like image 108
Greg Shackles Avatar answered Oct 15 '22 20:10

Greg Shackles