C# error when I try to run
-
This is the error I get when I try to run the sample app: _The reference assemblies for .NETFramework,Version=v4.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks_ I have downloaded and run "ndp481-devpack-enu.exe" from "dotnet.microsoft.com/en-us/download/visual-studio-sdks?cid=msbuild-developerpacks". But I am new to C# so I may have done something wrong.
-
This is the error I get when I try to run the sample app: _The reference assemblies for .NETFramework,Version=v4.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks_ I have downloaded and run "ndp481-devpack-enu.exe" from "dotnet.microsoft.com/en-us/download/visual-studio-sdks?cid=msbuild-developerpacks". But I am new to C# so I may have done something wrong.
If you got the code from an article, then there is a "Add a Comment or Question" button at the bottom of that article, which causes an email to be sent to the author. They are then alerted that you wish to speak to them. Posting this here relies on them "dropping by" and realising it is for them - we have no idea what "sample app" you are referring to!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
-
This is the error I get when I try to run the sample app: _The reference assemblies for .NETFramework,Version=v4.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks_ I have downloaded and run "ndp481-devpack-enu.exe" from "dotnet.microsoft.com/en-us/download/visual-studio-sdks?cid=msbuild-developerpacks". But I am new to C# so I may have done something wrong.
Member 16073627 wrote:
The reference assemblies for .NETFramework,Version=v4.0 ... ndp481-devpack-enu.exe
You have downloaded the developer pack for .NET Framework 4.8.1, whereas your error message says your project targets .NET Framework 4.0.0. The page you've linked to doesn't provide a download for 4.0.0; this page[^] explains why:
Install the .NET Framework developer pack or redistributable - .NET Framework | Microsoft Learn[^]:
Starting with Visual Studio 2022, Visual Studio no longer includes .NET Framework components for .NET Framework 4.0 - 4.5.1 because these versions are no longer supported. Visual Studio 2022 and later versions can't build apps that target .NET Framework 4.0 through .NET Framework 4.5.1. To continue building these apps, you can use Visual Studio 2019 or an earlier version.
According to this page[^], if you install VS2019 and select the ".NET 4 multi targeting pack" option, then you may be able to build .NET Framework 4.0 applications in VS2022. Otherwise, you'll need to stick with VS2019.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer