"Not defined" errors when upgrading to VS 2019

ElrondCT used Ask the Experts™
I am trying to move a large Visual Basic .NET project from VS 2008 to VS 2019 Community Edition. In VS 2019, I am getting huge numbers of errors like

Requested operation is not available because the runtime library function 'System.Runtime.CompilerServices.AccessedThroughPropertyAttribute..ctor' is not defined.

Other functions are named on other occasions, such as "System.Runtime.CompilerServices.DateTimeConstantAttribute..ctor".

Even more strangely, I'm getting error BC30002, "Type 'System.String' is not defined", and the same error for other types (Void, Int32, DateTime, Decimal, etc.).

Clearly, some sort of reference linking the Windows forms app to runtime modules isn't getting loaded, but I can't figure out what's missing. I've looked at the VS 2019 version and the VS 2008 version, and the project references seem to match. Can you offer suggestions of how to get them properly loaded, and eliminate the current 75,000(!) errors?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Peter HutchisonSenior Network Systems Specialist

What type of project are you upgrading? Is a C/C++, C# or VB project and what version of .NET Framework are you using?
Visual Studio uses Intellisense to detect keyworks, types, references etc.
Make sure that you have all the relevent .NET frameworks installed esp 2.0, 3.0, 3.5 and 4.x.
Also, make sure that all the relevant 'workloads' are installed for visual studio for the language(s) you want to develop for.
1. Open Visual Studio.
2. Open Tools, Get Tools and Features.
3. Enable relevant workloads:
a) .NET desktop development for WPF and Windows Forms type projects (VB, C#, F#) that run from a EXE.
b) ASP.NET and web development for web based .NET projects.
c) Desktop development with C++ for older C/C++ projects.

d) Check that the correct Language pack is installed.
e) Individual components - The 'Microsoft Visual Studio Installer projects' is useful for creating Setup projects to deploy the application.

Apply any additional updates for Visual Studio for compatibility and bug fixes.

See also: https://docs.microsoft.com/en-us/visualstudio/porting/port-migrate-and-upgrade-visual-studio-projects?view=vs-2017
Éric MoreauSenior .Net Consultant
Top Expert 2016

Have you tried to convert the project on the same computer?

Was the VS2008 Express or a better version? Some features available in Pro or Enterprise are not available in lower edition (like Community).

I would start by checking the references. There are surely some that are not valid anymore.

If it is a large project, your solution is probably composed of many class libraries sub-projects? I would load one that has no reference on any other, fix all errors and then add a second project, fix until it builds, and a third ...
Thanks, both, for your comments. The application is written in Visual Basic. I've tried targeting both .NET Framework 3.5 and 4.0 in VS 2019. I have VS 2008 Professional, and am using VS 2019 Community, but the change in edition shouldn't affect the presence of System.String! I'm running both of them on the same computer (VS 2008 is still active); I've created a copy of the original folder of source files for the VS 2019 version of the application.

I created a simple application in VS 2019 using Framework 4.0, which ran with no problems, so it would seem that the needed components are installed. This is a desktop application, and .NET desktop development is checked as installed. Individual components include the .NET Framework targeting pack for 4, 4.5, and more. I have the English language pack, which is all I need. I have gone through all the references in the project; all the references shown in VS 2008 are also shown in VS 2019, and all seem to be valid (non-zero version number, valid path).

When I try to build the application to run (in Debug mode), I get literally tens of thousands of errors, but I think the most significant are:

error BC30652: Reference required to assembly '<Missing Core Assembly>, Version=, Culture=neutral, PublicKeyToken=null' containing the type 'Object'. Add one to your project.

error BC30652: Reference required to assembly 'mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' containing the type 'MarshalByRefObject'. Add one to your project.

("Containing the type" could refer to any of a number of different types).

I tried adding mscorlib in the References page of Properties, but when I do, I get the error, "A reference to 'mscorlib' could not be added. This component is already automatically referenced by the build system." It seems not to be automatic enough, though. I think the lack of a link with mscorlib is the fundamental issue, but I don't understand why it isn't linking and how to resolve it.
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

Are you certain that you did not create the new solution as a .NET Core solution?

I didn't create a new solution; I simply opened the existing solution. And since Add References includes Assemblies as an option, I'm pretty certain it's a .NET Framework solution (information I see online indicates that a .NET Core solution doesn't permit assembly references).

Did a migration utility pop up when you first opened this in 2019?

What kind of project is this (Web, WinForm, Console; etc.)?

This is a WinForms application. There was a bit of migration information (my Setup & Deployment projects were deactivated), but I don't think a full-fledged utility; I was surprised by how little seemed to be done to make the move from VS 2008 to VS 2019.
Peter HutchisonSenior Network Systems Specialist

See what is shown in Project menu, Project Properties, References and see if there any unresolved references. It could be an extra, or third party  assembly, library  or COM object that is referring to and is missing on your machine.
All references have a valid path and a non-zero version number.
Peter HutchisonSenior Network Systems Specialist

I think a reinstall of Visual Studio maybe in order.
A reinstall doesn't seem very useful, since as stated a freshly created solution doesn't give these errors. It would seem there's something about the solution/project that I'm carrying over from VS 2008 that's causing the issue. I just tried another VS 2008 solution which worked fine. It has only 5 references, all System.something; all of those are in my offending solution as well.
Peter HutchisonSenior Network Systems Specialist

Another option is to recreate the project. Create a new project with a similar name and settings and copy the program code and files across and add them to the new project and then see if that builds okay.
Yes, maybe that's what I need to do. Unfortunately, I have about 120 items in my project...
See https://docs.microsoft.com/en-us/visualstudio/msbuild/troubleshooting-dotnet-framework-targeting-errors?view=vs-2019
Just remove Version/Token and other attributes form references in *.vbproj file(s), leave reference name only.
Ark, it sounded like a great idea, but it didn't help at all. If anything, I have more errors, though I don't remember exactly how many I had previously.

I think the idea of recreating the project is the most realistic at this point, but I haven't had time to do that.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial