9

I'm converting some old legacy VB apps from .NET framework to .NET 5, and have worked through most of the issues, however, I'm lost on these:

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

VisualBasic 10.3.0 package is included in the project.

Any tips are appreciated.

Thanks, Bill

Bill Hall
  • 91
  • 1
  • 3
  • We should never have to tell you to show us the code. – jmcilhinney Apr 27 '21 at 00:30
  • 1
    @jmcilhinney, generally I would agree. However, in this case I have thousands of lines of code, and have no clue what specific code is producing those errors. Unlike most errors, I can't just double-click on those and have it open the offending code. And the error indicates the file is "vbc" - my ignorance is showing, but I have no idea what that indicates. The code is also proprietary to my company. If I could reproduce the issues I could provide sample code, but I wouldn't even know where to start in this case. tl&dr: I don't know what code is producing the error, or the file "vbc". – Bill Hall Apr 27 '21 at 16:48
  • That is all relevant information that should be included in a full and clear explanation of the problem. Exactly where the error is generated is always relevant so, if there's a specific reason that you can't provide that, that is relevant too. – jmcilhinney Apr 28 '21 at 00:38
  • How exactly are you performing this migration? It sounds like there is some `My` code somewhere that is not compatible with .NET 5. That was one of the last pieces added - VB WinForms was supported in .NET 3.1 but it wasn't surfaced because some VB specific features, including `My`, had not been implemented - so there may be critical differences that are preventing your old code upgrading. – jmcilhinney Apr 28 '21 at 00:41

2 Answers2

12

I came accross the same issue today trying to update a .net framework (4.6 but I guess it applies to 4.x generally) to .net 5 using Microsofts Upgrade assistent.

I found the solution in this bug report on github:

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 </Project> end tag.

jjthebig1
  • 629
  • 7
  • 12
Jan
  • 3,825
  • 3
  • 31
  • 51
  • 3
    Take care you have not another tag. I had Windows. You just have to update from "Windows" to "Empty". – Carlos Aug 17 '21 at 12:08
  • Same issue... you can just delete Windows – xvan Nov 13 '22 at 02:30
  • 1
    This is supposed to be an .NET Core 3 milestone issue. I faced same issue in .NET 7 today and same fix -> Empty fixed it. I'm yet to figure out sideeffects. – Venkat Dec 07 '22 at 09:26
5

I have noticed that the answers provided so far only offer workarounds for this issue, rather than addressing its root cause. If you are encountering the BC30002 error when upgrading legacy VB projects to .NetCore/.Net framework, I suggest adding <UseWindowsForms>true</UseWindowsForms> within the <PropertyGroup>, as shown below:

  <PropertyGroup>
    <TargetFramework>net6.0-windows</TargetFramework>
    <Platforms>x64</Platforms>
    <UseWindowsForms>true</UseWindowsForms>
    <MyType>Windows</MyType>
  </PropertyGroup>
ZIQIANG ZHAO
  • 61
  • 1
  • 1