sun*_*ide 5 c# xamarin.android xamarin .net-core dnx
我正在编写一个Xamarin.Android应用程序,并希望引用我的库的NuGet包,这是一个有目标的dotnetDNX类库.当我这样做时,编译器会发出警告
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, ...
Run Code Online (Sandbox Code Playgroud)
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, ...]'
Run Code Online (Sandbox Code Playgroud)
虽然构建成功并且代码有效.我怎样才能在库/中更改它project.json?
在工作中,我们目前正在将项目移植到project.json类型的(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"
}
}
},
Run Code Online (Sandbox Code Playgroud)
虽然本文建议使用net45作为monoandroid51项目的目标,但dotnet每当我向其添加NuGet包时,Android项目都会引用该库.
该package.json则包含
<package id="My.Awesome.Lib" version="1.2.3-foo9" targetFramework="monoandroid51" />
Run Code Online (Sandbox Code Playgroud)
而.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>
Run Code Online (Sandbox Code Playgroud)
这工作了,到目前为止,除非我有高于版本号4.0.0的dependencies一部分,当我这样做基本上燃烧,但以下
但是当我构建项目时,我会得到编译器警告
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.
Run Code Online (Sandbox Code Playgroud)
在图书馆参考之后.在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, ...
Run Code Online (Sandbox Code Playgroud)
以及
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, ...]'
Run Code Online (Sandbox Code Playgroud)
这是完全合理的,因为Xamarin BCL被标记为运行时版本v2.0.50727,而我的库是v4.0.30319.
我现在想知道我是否需要针对某些PCL某些东西,或者是否还有其他东西我不知道.
| 归档时间: |
|
| 查看次数: |
753 次 |
| 最近记录: |