本文介绍了prexisiting的DLL(.NET框架4)问题单为Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个新的单声道为Android应用程序中使用 http://xamarin.com/monoforandroid

I am creating a fresh Mono for android application using http://xamarin.com/monoforandroid

我选择的单声道的使用Visual C#的选项Android应用程序。

I selected Mono for Android Application using Visual C# option.

我的Andr​​oid版本的目标是:

My Android target version is :

我去了该项目的参考,并试图将我的pre现有的DLL(在.NET框架4发)我得到这个错误:

I went to references of the project and tried adding my pre existing dlls (made in .NET 4 Framework)and I got this error:

奇怪的东西是没有选择改变,从项目属性的.NET框架。你能告诉我,我缺少的是什么?

The strange stuff is there is no option to change the .NET Framework from project properties. Can you tell me what I am missing?

推荐答案

这里的问题是,你要引用一个.NET 4的DLL从没有.NET项目4单声道为Android使用自己的轮廓用于.NET,这是非常相似的Silverlight(但不完全相同)的。虽然它可能是增加编译为一个不同的配置文件的DLL将工作,这是非常危险的,因为你可能会遇到在运行时的问题,你的应用程序会崩溃,由于一些从单是失踪了Android的轮廓。

The problem here is that you're trying to reference a .NET 4 DLL from a project that isn't .NET 4. Mono for Android uses its own profile for .NET, which is very similar to that of Silverlight (but not exactly the same). While it's possible that adding a DLL compiled for a different profile will work, it's very risky as you will probably run into problems at runtime where your app will crash, due to something being missing from the Mono for Android profile.

最好的答案,现在是创建一个单声道为Android类库,链接从您想使用的库中的相应文件,并引用。这会给你编译时检查,你不使用任何不支持的Mono的针对Android的空间,有助于保持你从长远来看更理智。我有一个旧的博客post在这里的是如何跨项目链接文件的谈判。

The best answer right now is to create a Mono for Android class library, link in the appropriate files from the library you want to use, and reference that. This will give you compile-time checking that you're not using anything unsupported by the Mono for Android profile, and help keep you more sane in the long run. I have an old blog post up here that talks about how to link files across projects.

这是说,在这种情况下,你很幸运,因为别人已经为你做的最后一部分!请查看这个叉Json.NET 的提供版本的MonoTouch和Mono为Android。

That said, in this case you're in luck because someone else has already done that last part for you! Check out this fork of Json.NET which provides versions for MonoTouch and Mono for Android.

这篇关于prexisiting的DLL(.NET框架4)问题单为Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 23:45