Home > Blockchain >  Visual Studio 2022 Community Edition missing libraries or installation problem
Visual Studio 2022 Community Edition missing libraries or installation problem

Time:05-26

I bought a new laptop and installed VS Community 2022 (used 2019 previously). I mostly create VB.Net console applications. I had to update a few of my utility apps and all worked fine. I then created a new app to automatically copy and rename photos from Google Drive to One Drive but I was surprised when standard libraries appear to be missing. For example:

Dim image As Bitmap = New Bitmap(Fpath)

shows a red underline below both Bitmaps and reports bitmap is not defined. Even if I change this to System.Drawing.Bitmap, it still says undefined. If I do type in System.Drawing, then intellisense shows only a few options Classes, Structures, etc. like Color, ColorConverter, etc. I had the same problem with System.IO.File.ReadAllBytes.

I uninstalled and reinstalled, selecting more options in case it needs other things. The System.IO.File.ReadAllBytes now works but System.Drawing.Bitmap is still undefined.

I can go to the menu item Project / Add Project Reference... and select COM, search for Drawing and 2 are shown (2.0 and 2.4). Checking either reports no errors however when I go back again, they remain unchecked.

Any suggestions?

CodePudding user response:

In the .NET Framework, the Bitmap and Color types are both defined in the System.Drawing.dll assembly, so being able to access one would mean being able to access the other. In .NET Core, the Color structure is defined in the System.Drawing.Primitives.dll assembly, while the Bitmap class is defined in the System.Drawing.Common.dll. The former is a standard part of .NET Core and is cross-platform while the latter is part of the platform extensions that is specific to Windows.

As you have access to Color and not Bitmap, you have presumably created a project targeting .NET Core rather than .NET Framework. Note that .NET 5 and later are based on .NET Core. You need to either install the appropriate NuGet package to reference the appropriate assembly or else create a new project targeting .NET Framework. All the VS project templates that target .NET Framework say so in the name.

  • Related