我使用.NET Core RC2编写了一个库,现在我将其更新为RTM。除了一个,迁移中没有问题。出于某种原因,Visual Studio(以及dotnet实用程序)在AssemblyInfo.cs中引发有关Guid的错误:
类型' GuidAttribute'存在于两者中 ' System.Runtime.InteropServices.PInvoke,Version = 4.0.0.0, Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'和 ' System.Runtime.InteropServices,Version = 4.1.0.0
我不确定这里发生了什么。
这就是我的AssemblyInfo.cs的样子:
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("My.Library")]
[assembly: AssemblyTrademark("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f89c2fd8-91f3-4f5a-87b6-094ee19712cf")]
它都是通用的,由Visual Studio生成。
我的project.json也很简单:
{
"title": "My Library",
"version": "1.0.0-*",
"dependencies": {
"NETStandard.Library": "1.6.0",
"AWSSDK.Core": "3.2.4.1-beta",
"AWSSDK.EC2": "3.2.4.1-beta",
"System.Net.Primitives": "4.0.11",
"System.Threading.Tasks": "4.0.11",
"System.Collections": "4.0.11"
},
"frameworks": {
"netstandard1.5": {
"imports": [ "dnxcore50", "portable-net45+win8" ]
}
},
"buildOptions": {
"xmlDoc": true
}
}
我真的不确定发生了什么,我开始认为这个错误可能会产生误导。我做的是否有任何错误,但无法看到?我该怎么调试呢?
答案 0 :(得分:2)
.Net Core开发过程中存在库System.Runtime.InteropServices.PInvoke,GuidAttribute
类型被移动到它。但是this library was removed before the 1.0 version。
问题在于AWSSDK.Core 3.2.4.1-beta取决于它。
我认为解决此问题的最佳方法是升级到AWSSDK.Core和AWSSDK.EC2 3.2.5-beta,它依赖于1.0版本的.Net标准库,因此它们没有这个问题。
另一种可能的解决方案是从代码中删除GuidAttribute
(或将其隐藏在#if
后面),因为您很可能不需要它。