Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dotnet 5 Error #458

Closed
mateli opened this issue Apr 24, 2024 · 7 comments
Closed

Dotnet 5 Error #458

mateli opened this issue Apr 24, 2024 · 7 comments

Comments

@mateli
Copy link

mateli commented Apr 24, 2024

Create a dotnet 5 WPF project (In VS 2022)
Add Vanara.Library 4.0 (3.X works)

An error similar to this occurs:
WpfApp2_1zvoyk2w_wpftmp.AssemblyInfo.cs(21, 38): [CS0433] The type 'SupportedOSPlatformAttribute' exists in both 'Vanara.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=c37e4080322237fa' and 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

@dahall
Copy link
Owner

dahall commented Apr 27, 2024

Hm. Doesn't make sense since the compiler directive for that class is:

#if !NET5_0_OR_GREATER

I would make sure you clean the project and the refetch all NuGet assemblies. There is a chance it is using an assembly version for .NET 4.x.

@mateli
Copy link
Author

mateli commented May 24, 2024

Tried adding the new 4.0.1 to a new dotnet 5 project and got the same error. After locating the nuget directory it has standard 2.0, netcoreapp3.1, net45, net48, netcoreapp3.1, net6, net7, net8.0-windows7.0. Net5 is indeed missing as well as net8.0 non-windows. Is there a 5.0 version built and uploaded to NuGet?

Likewise 3.4.17 doesn't seem to have a net5 build however it does work in net5. I would guess that the fallback is netcoreapp3.1.

I do think that there should be a build for every version of dotnet unless there is a reason to exclude some because of incompatibility problems that can't be fixed.

@dahall
Copy link
Owner

dahall commented May 25, 2024

.NET 5.0 is now deprecated by Microsoft. .NET 8.0 requires the "windows" platform tag for assemblies that use PInvoke and/or COM. This error is resolved if using one of the supported .NET versions.

@mateli
Copy link
Author

mateli commented May 25, 2024

Yeah I can't tell my customer to move their entire production environment to another framework. This would require a huge amount of testing and certification. Not everyone stop using a framework or product just because Microsoft abandons it.

The solution then is either to include vanara as source in my build or to create a new nuget package targeting more framework versions.

The code to make it work with 5.0 is according to previous posts already there so it's not like fixing this requires digging in to something specific to that version. If it doesn't build that's a different problem.

Sure I would prefer using at least 6.0 for multiple reasons but it's not my call to make.

@dahall
Copy link
Owner

dahall commented May 25, 2024

Let me see if I can make it work for NET 5 and I'll add in the next release.

@dahall
Copy link
Owner

dahall commented May 26, 2024

I have added back .NET 5.0 for the 4.0.2 release coming shortly. You can find the pre-release on AppVeyor (see homepage).

@dahall dahall closed this as completed May 26, 2024
@mateli
Copy link
Author

mateli commented May 26, 2024

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants