About migrating from .NET Framework 7.4.2 to .NET 5.0 Error

Nicholas Piazza 536 Reputation points
2021-02-02T12:54:17.847+00:00

After verifying portability of my .NET Framework 4.7.2 application to .NET 5.0, I tried using the instructions from How to Migrate from the .NET Framework to .NET 5 Controls | ComponentOne (grapecity.com). I created the new folder and the new project. However, when I try to build the .NET 5.0 version of the project, I get compiler error “CS0579: Duplicate ‘global::System.Runtime.Versioning.TargetFrameworkAttribute’ attribute’ as shown below.

// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")]

My project file is as follows:

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net5.0-windows</TargetFrameworks>
<UseWindowsForms>true</UseWindowsForms>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AssemblyName>DSAUCEx1_1Net5</AssemblyName>
<RootNamespace>DSAUCEx1_1</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\DSAUCEx1_1***.cs" />
<EmbeddedResource Include="..\DSAUCEx1_1***.resx" />
</ItemGroup>
</Project>

Can you tell me what I need to do to fix this problem? Also, I would like to know what to do with my existing app.config file which references the old framework. I suspect I need a modified version of that for the new .NET 5.0 project. The app.config file is shown below.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

Here is the link to those instructions I used: https://www.grapecity.com/blogs/how-to-migrate-from-the-dot-net-framework-to-dot-net-5-controls

Appreciate any help you could give me.

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,873 questions
0 comments No comments
{count} votes

Accepted answer
  1. Daniel Zhang-MSFT 9,621 Reputation points
    2021-02-03T07:04:51.957+00:00

    Hi NicholasPiazza-0093,
    You can add the following line to the <PropertyGroup> to fix the problem.

    <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>  
    

    If not successful, you can try the other methods in this thread.
    About porting from .NET Framework to .NET Core, I suggest you follow this document.
    And you can also try the try-convert to migrate.
    More suggestions in this thread you can refer to.
    Best Regards,
    Daniel Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful