在Android应用程序C#的.dll库应用程序、Android、dll

2023-09-06 02:20:22 作者:微笑勉强的有点

我目前使用Monodroid开发Android应用程序。我是相当新的手机应用程序让我困惑了几件事情:

什么顾名思义是一款Android库?我用的是单声道模板创建的Andr​​oid库:创建一个单声道为Android类库=>写code构筑成.DLL =>与从Visual Studio模拟器中运行并能正常工作在模拟器。不过是.dll文件的android库?或者,它是由单工作的仿真器和真实的Andr​​oid库应该JAR之前转换?

我可以直接用我定义的.dll文件用C#编写,使这个应用程序吗?我试了一下在单声道通过直接引用它在我的Andr​​oid应用程序,它是建筑,没有错误。但是,当模拟器中运行这个程序,它让stucked(仍然没有错误) - 什么是正确的方式来使用C#的.dll文件在Android应用程序项目

我知道有相当一对夫妇的话题讨论阅读我还是不能得到解决与此库引用问题,因此,如果任何人都可以提供任何线索后,C#和Android以及有关单,但之间的联系/想法将是最AP preciated

解决方案 在生成的DLL编译反对单声道为Android资料,它基于月光(单声道的实现的Silverlight)。在运行时,.NET code是针对其作为应用程序的一部分运行在Mono运行时直接运行。当.NET code子类从Java端(如java.lang.Object继承)的东西,单声道为Android产生的调用包装来处理运行时之间的沟通。 从技术上讲,你可以在单声道使用普通的.NET的DLL的Andr​​oid应用程序,但我不会推荐它。通过单声道为Android公开的个人资料较完整的.NET框架小得多(而且甚至不是完全等同于Silverlight中的),因此,如果您的DLL引用未在单声道发现Android的一个方法,你应用程序会崩溃。相反,我会建议创建一个单独的类库为你的应用程序,并使用文件链接跨项目共享的源文件。我的此处博客文章中对如何做到这一点的例子。

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

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?

VS2015安装图解教程 vs2015 vs2017 vs2010 vs2012 vs2018 夜鹰教程网

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

解决方案

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. 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.