michele74c
michele74c

Reputation: 63

Convert a .NET Framework VB project to .NET Core

For some reasons, I have to convert some projects (VB.NET and C#) to .NET Core.

I've followed info from various sources, from Convert .Net Core to .Net Framework and the Assembly Portability preventively to be conscious about the work to do.

Visual Studio 2019 Intellisense, after the conversion, does not show any alert BUT Visual Basic Projects does not compile.

The Visual Compiler shows the error for the namespaces "Global.Microsoft.VisualBasic.Devices" and "Global.Microsoft.VisualBasic.ApplicationServices" ("Type 'Global.Microsoft...' is not defined").

For each VB project, I have updated Microsoft.VisualBasic package. The current version is now 10.3.0. But the problem still persists.

Every project is targeted to .NET Core 3.1 framework.

What could be the problem?

Upvotes: 3

Views: 2924

Answers (3)

Rob Platt
Rob Platt

Reputation: 23

While the solution posted by @michele74c worked, I was also able to resolve this by removing

<MyType>Console</MyType> 

from my .vbproj file.

Upvotes: 1

michele74c
michele74c

Reputation: 63

This is the solution to my case: compiling succeded adding

<VBRuntime>Embed</VBRuntime>

to .vbproj file. stackoverflow.com/a/20005217/3185385

Upvotes: 3

jmcilhinney
jmcilhinney

Reputation: 54457

That's stuff relating to VB-specific features of the Application Framework and the My namespace. For instance, My.Computer exposes an instance of the Microsoft.VisualBasic.Devices.Computer type. Microsoft.VisualBasic.ApplicationServices relates to things like the shutdown mode that you can set in the project properties and the Startup event that you can handle to act at application startup.

You basically need to make sure none of those things are in use in your app before trying to migrate from .NET Framework to .NET Core. I've never tried it but I would assume that that means disabling the Application Framework and creating your own Main method as an entry point, just as you would in C#, and also replacing any uses of the My namespace with the equivalent .NET Framework types and members, as you would use in C#.

Upvotes: 0

Related Questions