带有BCL异步发行版的Xamarin.Mac 4.5不能解析System.Threading.Tasks [英] Xamarin.Mac 4.5 with BCL Async release compile fails to resolve System.Threading.Tasks

查看:161
本文介绍了带有BCL异步发行版的Xamarin.Mac 4.5不能解析System.Threading.Tasks的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在Xamarin Studio中使用.NET 4.5,并带有可移植的库和Xamarin.Mac项目.当Xamarin.Mac项目设置为.NET 4.5并通过nuget添加Microsoft Async时,在Debug中的编译将成功,但是Release/AppStore将失败,

I have been using .NET 4.5 in Xamarin Studio with portable libraries and a Xamarin.Mac project. When the Xamarin.Mac project is set to .NET 4.5 and Microsoft Async is added via nuget, compile in Debug will succeed but Release/AppStore will fail with

错误MM2002:无法解析程序集:'System.Threading.Tasks,

error MM2002: Failed to resolve assembly: 'System.Threading.Tasks,

在这种情况下,没有必要从BCL添加dll(System.Threading.Tasks和System.Runtime),因为它们已经在.NET 4.5中.如果您切换到.NET 4.0,则可以使用,但是.NET 4.5中已经有很多代码,由于其他依赖性,这些代码无法撤消.

In this case, it is unnecessary to add the dlls (System.Threading.Tasks and System.Runtime) from BCL because they are already in .NET 4.5. If you switch to .NET 4.0 it will work, but I have a lot of code already in .NET 4.5 that cannot be reversed because of other dependencies.

以某种方式,BCL无法将Xamarin.Mac .NET 4.5项目识别为.NET 4.5,并且仍然需要dll.

Somehow, BCL is not recognizing the Xamarin.Mac .NET 4.5 project as .NET 4.5 and still requiring the dlls.

要复制:

  1. 创建一个新的Xamarin.Mac项目
  2. 将其设置为.NET 4.5
  3. 使用nuget来获取Microsoft Async(正确通知它不会拉入System.Threading.Tasks或System.Runtime)
  4. 切换到发布版本
  5. 编译

BCL如何知道是否使用了.NET 4.0或.NET 4.5?也许我可以在csproj中声明一些内容,以使其识别出System.Threading.Tasks(和System.Runtime)已经包含在内.还是一些环境变量?还是...?

How does BCL know if .NET 4.0 or .NET 4.5 is used? Maybe there is something I can declare in the csproj to make it recognize that System.Threading.Tasks (and System.Runtime) is already included. Or maybe some Environment variable? Or...?

注意.可以从net40 nuget文件夹引用System.Threading.Tasks和System.Runtime.并且在测试项目中,这实际上可以工作-尽管它抱怨预定义类型System.Runtime.CompilerServices.AsyncStateMachineAttribute' is defined multiple times. Using definition from mscorlib.dll'".但是,在我的情况下,我有一个使用EventArgs的可移植库,并且构建失败,并出现错误CS1684:引用类型System.EventArgs' claims it is defined assembly System.Runtime-当然不是.

Note. It is possible to reference the System.Threading.Tasks ans System.Runtime from the net40 nuget folder. And in the test project, this actually works - though it complains about "The predefined type System.Runtime.CompilerServices.AsyncStateMachineAttribute' is defined multiple times. Using definition frommscorlib.dll'" However, in my case I have a portable library which uses EventArgs and the build fails with error CS1684: Reference to type System.EventArgs' claims it is defined assemblySystem.Runtime - which of course it isn't.

推荐答案

我不确定Xamarin.Mac是否支持PCL.您可以尝试添加具有绑定重定向的app.config,类似于此处所述: http://motzcod.es/post/78863496592/portable-class-libraries-httpclient-so-happy

I'm not sure how well Xamarin.Mac supports PCLs. You can try to add an app.config with binding redirects, similar to what is described here: http://motzcod.es/post/78863496592/portable-class-libraries-httpclient-so-happy

否则,我建议向Xamarin提交错误.

Otherwise, I'd suggest filing a bug with Xamarin.

这篇关于带有BCL异步发行版的Xamarin.Mac 4.5不能解析System.Threading.Tasks的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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