![](/img/trans.png)
[英]How can i enable debug in android project properties (Xamarin Android)
[英]In a DNX project, how can I target for Xamarin Android?
我正在编写一个Xamarin.Android应用程序,并希望引用我的库的NuGet包,这是一个以dotnet
为目标的DNX类库。 当我这样做时,编译器会发出警告
The type 'DateTime' is defined in an assembly that is not referenced.
You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, ...
IDE抱怨像这样的消息
Argument type 'System.DateTime [mscorlib, Version=2.0.5.0, Culture ...]' is
not assignable to parameter type 'System.DateTime [mscorlib, Version=4.0.0.0, ...]'
虽然构建成功并且代码有效。 如何在库/ project.json
更改它?
在工作中,我们目前正在将项目移植到project.json
-type(Package,DNX,无论名称是什么)。 目前,我们正在运行beta 7 Visual Studio集成,一般来说,一切正常。 我现在想要在ASP.NET 5和Xamarin.Android项目(来自NuGet提要)中重用我们的模型库之一。
因为我们曾与在Xamarin项目针对.NET 4.5.1类库绝对没有运气我迁移模型库的DNX项目瞄准net45
, dnx45
和dotnet
(赞成dnxcore50
,描述在这里 ),在该框架的部分project.json
正在
"frameworks": {
"net45": {
"frameworkAssemblies": {
"mscorlib": "4.0.0.0",
"System.Xml": "4.0.0.0",
"System.Collections.Concurrent": "4.0.0.0"
}
},
"dnx45": {
"frameworkAssemblies": {
"mscorlib": "4.0.0.0",
"System.Xml": "4.0.0.0",
"System.Collections.Concurrent": "4.0.0.0"
}
},
"dotnet": {
"dependencies": {
"System.Collections": "4.0.0",
"System.Linq": "4.0.0",
"System.Runtime": "4.0.0",
"System.Reflection": "4.0.0",
"System.Runtime.Extensions": "4.0.0",
"System.Threading": "4.0.0",
"System.Text.RegularExpressions": "4.0.0",
"System.Text.Encoding": "4.0.0",
"System.Collections.Concurrent": "4.0.0"
}
}
},
虽然本文建议使用net45
作为monoandroid51
项目的目标,但每当我向其添加NuGet包时,Android项目都会引用dotnet
库。
然后package.json
包含
<package id="My.Awesome.Lib" version="1.2.3-foo9" targetFramework="monoandroid51" />
和.csproj
有
<Reference Include="My.Awesome.Lib, Version=1.2.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\My.Awesome.Lib.1.2.3-foo9\lib\dotnet\My.Awesome.Lib.dll</HintPath>
<Private>True</Private>
</Reference>
到目前为止,除非我在dependencies
部分中的版本号高于4.0.0
,并且基本上在我做的时候燃烧,但是
但是当我构建项目时,我会得到编译器警告
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1706,3):
warning MSB3277: Found conflicts between different versions of the
same dependent assembly that could not be resolved. These reference
conflicts are listed in the build log when log verbosity is set to detailed.
在图书馆参考之后。 在Visual Studio中,每当我将一个值从Android项目传递给其中一个库类型时,我都会得到一条带有消息说明的红色波浪线
The type 'DateTime' is defined in an assembly that is not referenced.
You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, ...
以及
Argument type 'System.DateTime [mscorlib, Version=2.0.5.0, Culture ...]' is
not assignable to parameter type 'System.DateTime [mscorlib, Version=4.0.0.0, ...]'
这是完全v4.0.30319
,因为Xamarin BCL标记为运行时版本v2.0.50727
,而我的库是v4.0.30319
。
我现在想知道我是否需要针对某些PCL某些东西,或者是否还有其他东西我不知道。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.