.netvb.netupgradevisual-studio-2022vbc

'Type "Global.Microsoft.VisualBasic..." is not defined' - after upgrading project to NET 8.0


I'm using latest version of VS 2022 preview, and I'm suffering these four compiler errors after using Net Upgrade Assistant to upgrade a .NET 4.8.1 project to .NET 8.0 preview:

BC30002 Type 'Global.Microsoft.VisualBasic.ApplicationServices.ApplicationBase' is not defined.
BC30002 Type 'Global.Microsoft.VisualBasic.ApplicationServices.User' is not defined.
BC30002 Type 'Global.Microsoft.VisualBasic.Devices.Computer' is not defined.
BC30002 Type 'Global.Microsoft.VisualBasic.MyServices.Internal.ContextValue' is not defined.

A more detailed sample of one of these errors:

Severity    Code    Description Project File    Line    Suppression State
Error   BC30002 Type 'Global.Microsoft.VisualBasic.ApplicationServices.ApplicationBase' is not defined. Extensions.Shell32Core  C:\Users\Administrador\Desktop\DevCase\v5.0\Solution\DevCase for .NET Framework\Projects\Extensions\Extensions.Shell32Core\vbc  1   Active

The errors does not point to any line in the source-code files, the "File" column points to "vbc" (vb.net compiler executable).

This is very strange to me.

I thought that maybe it was a external... "special" or auto-generated file which is causing these errors, so I used a third party tool (similar to DnGrep) to search for those namespaces inside all the files, but no plain-text nor binary file in the source-code directory contains any of those four namespaces.

The project that I upgraded is just a dynamic-link library project written in VB.NET, and the contents are very simple with just two modules with few method extensions defined.

I cleaned and tried to rebuild the solution, I also deleted the ".vs" directory, but the errors persists.

Maybe the errors could be related to modules usage or method extensions?, because I upgraded another five VB.NET projects that does not contain modules with method extensions and it worked fine. And all the projects that I upgraded, including this problematic project, all are from the same solution.

Why I'm having those compiler errors and how do I fix them?.

In this zip file you can download and check both the original working project and the problematic upgraded project: https://www.mediafire.com/file/0d7n8g3upf3nt0c/Extensions.Shell32.zip/file


Solution

  • I've found an user that suffered the same exact compiler errors, and fortunately a solution is detailed that for the moment is working for me when upgrading this kind of projects that contains modules with method extensions.

    The solution is:

    Simply put, add the following to your newly created .vbproj-file:

    <PropertyGroup>
    <MyType>Empty</MyType>
    </PropertyGroup>

    Place at the end of of .vbproj-file just before end tag.

    It seems to be a bug as pointed out by the author of that answer.