Global.Micrsoft.VisualBasic.ApplicationsServices... is not defined error BC30002
Asked Answered
L

3

11

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

Lynnelynnea answered 26/4, 2021 at 22:32 Comment(4)
We should never have to tell you to show us the code.Collett
@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".Lynnelynnea
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.Collett
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.Collett
A
17

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.

Alpenhorn answered 17/8, 2021 at 11:11 Comment(3)
Take care you have not another <MyType> tag. I had <MyType>Windows</MyType>. You just have to update from "Windows" to "Empty".Christianism
Same issue... you can just delete <MyType>Windows</MyType>Matthei
This is supposed to be an .NET Core 3 milestone issue. I faced same issue in .NET 7 today and same fix -> <MyType>Empty</MyType> fixed it. I'm yet to figure out sideeffects.Pentimento
M
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>
Macrography answered 6/5, 2023 at 2:59 Comment(1)
Just a note, targeting net7.0 for WinForms app I had to add '-windows' in a <TargetFramework> as it was missing and complier didn't like it.Retharethink
P
0

I came across this with the same errors upgrading .Net FW to .Net 8. The property page of the project has a drop-down for this - choose "Target OS" to be "Windows" and this modifies the .vbproj file for you.

Petepetechia answered 18/4 at 11:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.