在Xamarin单项目Microsoft.Threading.Tasks.Extensions [英] Microsoft.Threading.Tasks.Extensions in Xamarin Mono projects

查看:800
本文介绍了在Xamarin单项目Microsoft.Threading.Tasks.Extensions的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立了一个的NuGet包我Simple.OData.Client与Xamarin Android和iOS的支持。此库使用Microsoft.Bcl.Async。使用Android和iOS模拟器测试OK了,但是当我安装这个新的NuGet包到另一个项目,它不能编译的Droid /触摸项目的以下信息:

I have built a NuGet package for my Simple.OData.Client with support for Xamarin Android and iOS. This library uses Microsoft.Bcl.Async. Tests using Android and iOS simulator went OK, but when I install this new NuGet package into another project, it fails to compile Droid/Touch projects with the following message:

C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(720,2): error : Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Microsoft.Threading.Tasks.Extensions, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono for Android profile?
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(720,2): error : File name: 'Microsoft.Threading.Tasks.Extensions.dll'

当然有单声道平台没有Microsoft.Bcl.Async包(还),而另一方面,因为库测试通过在这些平台上,我想这更是一个挑战,使Visual Studio的快乐,而不是做一些code修改。

Of course there is no Microsoft.Bcl.Async pack (yet) for Mono platforms, on the other hand since the library tests pass on these platforms, I guess this more of a challenge to make Visual Studio happy rather than do some code modification.

有没有人设法在Mono PCLS使用依赖于M​​icrosoft.Bcl.Async?

Has anyone managed to use on Mono PCLs dependent on Microsoft.Bcl.Async?

推荐答案

一般来说,如果在你的包中的code依赖于其他的NuGet包,你需要声明一个包依赖,使任何人在安装程序包将得到一个你依赖了。这应该照顾的问题是这样的。

Generally, if the code in your package depends on another NuGet package, you need to declare a package dependency so that anyone installing your package will get the one you depend on too. That should take care of issues like this.

然而,在这种情况下,它是一个复杂得多。由于Microsoft.Bcl.Async不支持单声道的平台,你不能声明包的依赖(或者,如果你做的总是无法安装)。不幸的是,Microsoft.Bcl.Async许可它限制为Windows平台。我不是律师,但我认为,这意味着你不应该散布Microsoft.Threading.Tasks.Extensions.dll为你包的一部分。最后,还有单声道平台没有正式支持PCL还,所以如果你不拿出的作品现在,当官方支持PCL出来它可能会改变一个解决方案。

However, in this case it is a lot more complicated. Since Microsoft.Bcl.Async doesn't support Mono platforms, you can't declare that package dependency (or if you did it would always fail to install). Unfortunately the license for Microsoft.Bcl.Async restricts it to "Windows platforms". I'm not a lawyer but I think that means you shouldn't distribute Microsoft.Threading.Tasks.Extensions.dll as part of your package. Finally, there's no official PCL support for Mono platforms yet, so if you do come up with a solution that works now it may change when official PCL support comes out.

如果你想尝试得到这个工作,你基本上需要做的是使用相同的名称创建自己的DLL是Microsoft.Bcl和Microsoft.Bcl.Async对单平台上使用。在这些组件中,把型前锋的类型单已经实现(这大概应该是在系统的类型。*的DLL),并为其他的你自己的实现(AsyncBridge源$ C ​​$ c是有益的为了这)。这是我做我的BUILD 2012 PCL演示之一。在code因为这是这里。 AsyncFacades和AsyncBridge是相关的项目。

If you want to attempt getting this to work, what you basically need to do is create your own DLLs with the same names as are in Microsoft.Bcl and Microsoft.Bcl.Async for use on Mono platforms. In those assemblies, put type forwards for the types that Mono already implements (which should probably be the types in the System.* DLLs), and create an implementation of your own for the other ones (the AsyncBridge source code is useful for this). This is what I did for one of my BUILD 2012 PCL demos. The code for that is here. AsyncFacades and AsyncBridge are the relevant projects.

这篇关于在Xamarin单项目Microsoft.Threading.Tasks.Extensions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆