I wrote a library using .NET Core RC2 and now I'm updating it to RTM. There was no issue in the migration except one. For some reason, Visual Studio (as well as the dotnet utility) throws an error about the Guid in AssemblyInfo.cs:
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
I'm not sure what's happening here.
This is what my AssemblyInfo.cs looks like:
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")]
It's all generic and was generated by Visual Studio.
My project.json is also pretty simple:
{
"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
}
}
I'm really not sure what's going on and I'm starting to think the error might be misleading. Is there any mistake I made but just can't see? How can I debug this?
The library System.Runtime.InteropServices.PInvoke existed during the development of .Net Core, and the GuidAttribute type was moved to it. But this library was removed before the 1.0 version.
The problem is that AWSSDK.Core 3.2.4.1-beta depends on it.
I think the best way to fix this is to upgrade to AWSSDK.Core and AWSSDK.EC2 3.2.5-beta, which depend on 1.0 versions of .Net Standard libraries, so they don't have this problem.
Another possible solution would be to remove the GuidAttribute from your code (or hide it behind an #if), since you very likely don't need it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With