1

This is ordinary console application, I have installed in my computer NET.CORE, look to result of dotnet --info

.NET SDK (reflecting any global.json):
 Version:   5.0.202
 Commit:    db7cc87d51

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19042
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.202\

Host (useful for support):
  Version: 5.0.5
  Commit:  2f740adc14

.NET SDKs installed:
  1.0.0-preview2-003131 [C:\Program Files\dotnet\sdk]
  3.1.408 [C:\Program Files\dotnet\sdk]
  5.0.102 [C:\Program Files\dotnet\sdk]
  5.0.104 [C:\Program Files\dotnet\sdk]
  5.0.202 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

This is my project file, additionally I found all location of System.Runtime.dll and include it path to project file.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <RootNamespace>LinuxCamelCase</RootNamespace>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <ReferencePath>C:\Program Files\dotnet\sdk\3.1.408\;C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.14;C:\Program Files\dotnet\sdk\3.1.408\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\;C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\3.1.0\ref\netcoreapp3.1</ReferencePath>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <PlatformTarget>x64</PlatformTarget>
  </PropertyGroup>

    
  <ItemGroup>
    <PackageReference Include="MySqlConnector" Version="1.3.8" />
  </ItemGroup>

</Project>

However compilation in Visual Studio 2019 is impossible.

1>J:\Vs2019\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5): warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. Could not load file or assembly 'System.Runtime.Intrinsics.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.

1>J:\Vs2019\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5): warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. Could not load file or assembly 'System.Runtime.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.
1>vbc : error BC30002: Type 'System.Void' is not defined.
1>vbc : error BC30002: Type 'System.Void' is not defined.
1>vbc : error BC30002: Type 'System.String' is not defined.
1>vbc : error BC30002: Type 'System.String' is not defined.
1>vbc : error BC30002: Type 'System.Void' is not defined.
1>vbc : error BC30002: Type 'System.Object' is not defined.
1>vbc : error BC30002: Type 'System.Object' is not defined.
1>vbc : error BC30652: Reference required to assembly '<Missing Core Assembly>, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' containing the type 'Object'. Add one to your project.
1>vbc : error BC30652: Reference required to assembly '<Missing Core Assembly>, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' containing the type 'Object'. Add one to your project.

dotnet-core-uninstall

This tool cannot uninstall versions of the runtime or SDK that are 
    - SDKs installed using Visual Studio 2019 Update 3 or later.
    - SDKs and runtimes installed via zip/scripts.
    - Runtimes installed with SDKs (these should be removed by removing that SDK).
The versions that can be uninstalled with this tool are:

.NET Core SDKs:
  5.0.202  x64    [Used by Visual Studio. Specify individually or use --force to remove]
  5.0.104  x64
  3.1.408  x86
  3.1.408  x64
  1.0.1    x64    [Used by Visual Studio. Specify individually or use --force to remove]

.NET Core Runtimes:
  3.1.14  x64
  2.1.27  x64

ASP.NET Core Runtimes:
  5.0.5   x86
  5.0.5   x64
  3.1.14  x86
  2.1.27  x64

.NET Core Runtime & Hosting Bundles:

Of course, I have selected .NET CORE development during VS2019 installation. But now I have only one option of compilation

<TargetFramework>net5.0</TargetFramework>

Compilation for other framefork is impossible. Why?

I DON'T want to move to NET 5.0 from NET 3.1 and DON'T want to support in my Linux hosting environment NET CORE 5.0, because I have a lot of historical application and I don't want a lot of different version of NET CORE in Linux hosting.

I hope this is only bug and not a Microsoft Policy - don't allow developers to save preferred version of NET CORE.

Alex
  • 373
  • 1
  • 3
  • 13
  • 1
    did you include the .net core workload when installing vs2019? – sommmen May 08 '21 at 09:28
  • @sommmen Checking again, thank you, now VS require updating. – Alex May 08 '21 at 09:34
  • If it's fixed please post an answer and mark it as answered - or if it was a real simple troubleshooting step remove the question (ie. its not valuable to keep it on the site) if you could. – sommmen May 08 '21 at 09:39
  • @sommmen I have reinstalled VS2019 again from scratch, but nothing changing. – Alex May 08 '21 at 12:23

1 Answers1

0

Piggybacking on what @sommmen is saying, have you launched Visual Studio Installer, clicked the Modify button as shown here:

Modify button beside Visual Studio Professional 2019

First make sure you have the .NET desktop development workload selected:

.NET desktop development selection

And then scroll to the bottom of that page and select the .NET Core cross-platform development package as shown here:

.NET Core package selection

Be sure and click the install button and wait for the installation to finish. There is a good chance that this will resolve your issue.

jlavallet
  • 1,267
  • 1
  • 12
  • 33
  • Yes, Of course, I selected Cross Platform Development. But I can compile desktop application ONLY with NET 5.0 – Alex May 08 '21 at 15:16
  • @Alex,first copy the contents of your "answer" below and edit your original post placing this new information at the end. I'd suggest you put something like "UPDATE" as a header above that information. Then go delete your "answer". So let's go back to your original problem... I would also suggest that you include the .NET desktop development workload if you have not already. I will edit my answer above with another screenshot. – jlavallet May 08 '21 at 15:28
  • @Alex, look at the answers here: https://stackoverflow.com/questions/59610009/net-core-3-1-could-not-load-file-or-assembly-system-runtime-version-4-2-2-0 – jlavallet May 08 '21 at 16:03