添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
性感的夕阳  ·  Can't compile Node ...·  昨天    · 
腹黑的领带  ·  android ...·  昨天    · 
腹黑的西装  ·  How to use pip ...·  9 小时前    · 
气势凌人的莴苣  ·  TypeScript project ...·  8 月前    · 
大鼻子的打火机  ·  CMake and GNU ARM ...·  1 年前    · 
豪气的荒野  ·  Setting Environment ...·  1 年前    · 

I am not a developer but I needed to make some changes to an older C# program in Visual Studio. So, I made the change and when I went to build, it said this:

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.

So I did go and download the Developer Pack for 4.8 but Visual Studio is still not building it.

What is an easy way to fix this?
Thanks!
Brian

Yeah, VS2022 doesn’t support .NETFramework,Version=v4.0 out of the box. And finding and adding that support is kind of a trick. I think, though, that you should probably be able to just target framework 5.0, (nope editing, actually framework 4.8 for 2022) and build it just fine with no serious repercussions if it’s not an ancient codebase.

CraiGrrr:

Yeah, VS2022 doesn’t support .NETFramework,Version=v4.0 out of the box. And finding and adding that support is kind of a trick. I think, though, that you should probably be able to just target framework 5.0, (nope editing, actually framework 4.8 for 2022) and build it just fine with no serious repercussions if it’s not an ancient codebase.

Is this the proper way to set it?

<TargetFramework>net50</TargetFramework>

The reason I asked is that it didn’t work correctly.

Severity	Code	Description	Project	File	Line	Suppression State
Error	CS1002	; expected	PSI-LOC	\\fileserver\utility\Development\C#\Projects\LOC 2023\PSI-LOC\ConsoleApplication1\Program.cs	158	Active
Error	CS1003	Syntax error, '(' expected	PSI-LOC	\\fileserver\utility\Development\C#\Projects\LOC 2023\PSI-LOC\ConsoleApplication1\Program.cs	158	Active
Error	CS1026	) expected	PSI-LOC	\\fileserver\utility\Development\C#\Projects\LOC 2023\PSI-LOC\ConsoleApplication1\Program.cs	158	Active
Error	CS1525	Invalid expression term 'else'	PSI-LOC	\\fileserver\utility\Development\C#\Projects\LOC 2023\PSI-LOC\ConsoleApplication1\Program.cs	158	Active
Error	CS8641	'else' cannot start a statement.	PSI-LOC	\\fileserver\utility\Development\C#\Projects\LOC 2023\PSI-LOC\ConsoleApplication1\Program.cs	158	Active
Error	CS1003	Syntax error, 'switch' expected	PSI-LOC	\\fileserver\utility\Development\C#\Projects\LOC 2023\PSI-LOC\ConsoleApplication1\Program.cs	190	Active
Warning	NETSDK1138	The target framework 'net50' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/dotnet-core-support for more information about the support policy.	PSI-LOC	C:\Program Files\dotnet\sdk\7.0.302\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.EolTargetFrameworks.targets	28	
Warning	MSB3243	No way to resolve conflict between "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "System.Core". Choosing "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily.	PSI-LOC	C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets	2352	
Warning	MSB3243	No way to resolve conflict between "System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "System.Data". Choosing "System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily.	PSI-LOC	C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets	2352	
              

Good morning.

To resolve this type of problem, assuming there is no more error, it would simply be in the project properties, in case the solution has only one project, or all projects that use the 4.0 framework and change to a higher version.

However, right when opening the solution, the Visual Studio already gives the option to do this before opening the projects. Then you choose the latest version and the project will be converted automatically. Save everything beforehand so in case anything goes wrong you have the original project.

Mike400:

The easiest way to do this is to change the target framework in the project configuration. Net4.0 is no longer supported by Microsoft.

So I did INSTALL OTHER FRAMEWORKS, it took me to a Microsoft site and I downloaded .net 7, installed it, rebooted and still cannot find it in the dropdown box for my project. Is there something I am doing wrong?

I tried the update-assistant in the command line and it converted it to .net 7 but still got some build errors…might be outside my paygrade to fix and a result of me changing the code but going to go through each one and see if I can fix.