question

Prabs-7622 avatar image
0 Votes"
Prabs-7622 asked vb2ae answered

How to Migrate .Net Framework to .Net core application

Hi,
I have an desktop application with .Net framework 4.5 using Visual Studio 2015.
I want to convert .Net framework 4.5 application(desktop) to .Net Core 3.1 console application in Visual studio 2019
How to approach this?

Please help me on this

dotnet-csharpdotnet-runtimedotnet-runtime-coredotnet-console
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ASP.NET Core 3.1 is cross platform I recommend reading the migration documentation so you know what has changed.


0 Votes 0 ·

@Prabs-7622
Microsoft has provided a Portability Analyzer tool that focuses on analyzing your code and providing you with a detailed report on the compatibility between the current framework and the selected target framework.
Just be aware that it may have some false positives when targeting some third-party packages. You can use some other tools such as .NET API Catalog for verification.

0 Votes 0 ·
DuaneArnold-0443 avatar image
0 Votes"
DuaneArnold-0443 answered

The easiest thing you can do IMHO is make the core project and copy the classes from the old project to the core project. Then you'll have to figure out what namespaces a class you copied over to code is not valid in Core and either find the Core equivalent or remove the namespace altogether.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

karenpayneoregon avatar image
0 Votes"
karenpayneoregon answered

Hello,

To create a .NET Core 3.1 console project you need Visual Studio 2019 as Visual Studio 2015 and Visual Studio 2017 don't support .NET Core 3.1

Also note that references are done differently in .NET Core than .NET Framework e.g. lets say you need to connect to a database, (not saying you do) in .NET Framework the reference is in the project while in .NET Core you need to add an NuGet package.

Otherwise if you are not doing much outside normal coding you'll be fine.

Plain Jane project file

 <Project Sdk="Microsoft.NET.Sdk">
    
   <PropertyGroup>
     <OutputType>Exe</OutputType>
     <TargetFramework>netcoreapp3.1</TargetFramework>
   </PropertyGroup>
    
 </Project>

With a database provider

 <Project Sdk="Microsoft.NET.Sdk">
    
     <PropertyGroup>
         <OutputType>Exe</OutputType>
         <TargetFramework>netcoreapp3.1</TargetFramework>
     </PropertyGroup>
    
     <ItemGroup>
         <PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
     </ItemGroup>
    
 </Project>


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

vb2ae avatar image
0 Votes"
vb2ae answered

At the .net conf focus on windows they talked about a tool the upgrade assistant. It helps move .net framework desktop apps to .net 5. Maybe you could move it to .net 5 and then change the target framework to .net core 3.1

https://dotnet.microsoft.com/platform/upgrade-assistant


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.