AssemblyInfo.cs 中的 GuidAttribute 错误
GuidAttribute error in AssemblyInfo.cs
我使用 .NET Core RC2 编写了一个库,现在我正在将它更新为 RTM。除了一个问题外,迁移没有任何问题。出于某种原因,Visual Studio(以及 dotnet 实用程序)在 AssemblyInfo.cs:
中引发有关 Guid 的错误
The type 'GuidAttribute' exists in both
'System.Runtime.InteropServices.PInvoke, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and
'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
}
}
我真的不确定发生了什么,我开始认为这个错误可能具有误导性。我犯了什么错误但看不到吗?我该如何调试?
库System.Runtime.InteropServices.PInvoke在.Net Core的开发过程中存在,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,它们依赖于 .Net Standard 库的 1.0 版本,所以他们没有这个问题。
另一种可能的解决方案是从您的代码中删除 GuidAttribute
(或将其隐藏在 #if
后面),因为您很可能不需要它。
我使用 .NET Core RC2 编写了一个库,现在我正在将它更新为 RTM。除了一个问题外,迁移没有任何问题。出于某种原因,Visual Studio(以及 dotnet 实用程序)在 AssemblyInfo.cs:
中引发有关 Guid 的错误The type 'GuidAttribute' exists in both 'System.Runtime.InteropServices.PInvoke, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and '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
}
}
我真的不确定发生了什么,我开始认为这个错误可能具有误导性。我犯了什么错误但看不到吗?我该如何调试?
库System.Runtime.InteropServices.PInvoke在.Net Core的开发过程中存在,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,它们依赖于 .Net Standard 库的 1.0 版本,所以他们没有这个问题。
另一种可能的解决方案是从您的代码中删除 GuidAttribute
(或将其隐藏在 #if
后面),因为您很可能不需要它。