![](/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.