Question Migrating from .NET Framework to .NET Core

mauede

Well-known member
Joined
Sep 1, 2021
Messages
103
Location
Northwood - UK
Programming Experience
Beginner
I have written only 216 lines of C# code for my new project.
I would like to migrate from .NET Framework 4.8 to .NET Core 6.0
How can I do that?

Thank you in advance.
Maura
 
Last edited by a moderator:
There's no simple way to convert a project from one to the other. I would suggest that you create a new project targeting .NET 6 and then just copy the code across. Most likely the code will run unchanged.
 
I did that.
Instead of improving the compiler is now producing more errors.
My code references ConsoleX.
I downloaded CosoleX from GitHub and included the source code in my project.
ConsoleUI.cs contains the statement "using System.Windows.Forms".
When I use .NET Framework 4.8 I include the reference "System.Windows.Form" and such an error disappears.
Now I am using .NET Core 6.0. I still include the reference (attached snapshot) "System.Windows.Form" but the error does not disappear.
In fact, in the Framework list of the Solution Explorer, I can see System.Windows but I cannot see System.Windows.Forms.
If NET Core 6.0 were not supporting the reference to such an assembly I would expect I could not find it as a possible reference to add. It should be filtered out. But it is not.

Furthermore, the compiler is now marking other errors in the source code ConsoleUI.cs

I have to point out that ConsoleX is a package that targets .NET Framework 4.8
I include its source code in my project that is targeting .NET 6.0
Is this sort of "mix & match" feasible or is it nonsense?
Thank you so much.
 

Attachments

  • Capture.PNG
    Capture.PNG
    46.1 KB · Views: 13
From what I can see from the source code for ConsoleX, it's only dependency on WinForms is for the GUI file dialogs. If you don't need the functionality, since you are writing a console app after all, then just delete that code from your copy of ConsoleX.
 
Last edited:
If you really do need to reference Forms in a .Net 6 console application you must edit project file (right click project node in Solution Explorer and select edit it) and change TargetFramework to "net6.0-windows" and also add:
XML:
<UseWindowsForms>true</UseWindowsForms>
Then save/close and project file and rebuild.
 
Then you have done something wrong I guess, how does your project file look like?
 
The project file is no more loaded after the editing.
In fact, Visual Studio does not offer any option to build the solution.
I have attached a snapshot of the edited project file.
I did not know where to place the added statement in the project file
structure.
 
Can't see it.
 
Why do you need a picture by the way, it is just a couple of text lines?
 
Think we need to take a few steps back here. What project type did you create for .Net 6 ?
The link to consolex github?
 
Back
Top Bottom