Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can we migrate between .NET versions in Visual Studio?

Status
Not open for further replies.

audaxviator

Programmer
Mar 19, 2018
11
0
0
GB
Hi all,

First time posting.

An application was originally developed in older versions of VS, and is currently maintained in Windows 10 / VS 2017. The application executes on .NET 4.0, but there are some features of .NET 4.5.1 that I would like to take advantage of.

Changing the application target from .NET 4.0 to .NET 4.5.1 did not help because the referenced assemblies were still .NET 4.0

Manually editing app.config and changing the supported runtime version also had no effect. Removing the .NET 4.0 assemblies and referencing .NET 4.5.1 was a near miss: the change updated Intellisense and a build succeeded, but its world fell apart at runtime by loading the .NET 4.0 assemblies and throwing the most peculiar exceptions declaring "bug"

I was annoyed and tried all of the above and setting a search path to the .NET 4.5.1 assemblies. This made the refences in VS2017 look right, and the .NET 4.5.1 features are picked up by intellisense ... but build failed and bigger problems emerged!

Code:
'byte[]' does not contain a definition for Length
object does not contain a constructor that takes 0 arguments
'System.Boolean' is not defined or imported
(attached screenshot shows over 3000 more ...)

Please tell me why I am finding it so hard to migrate from .NET 4.0 to .NET 4.5.1

Most assemblies with version 4.0.0.0 are from .NET 4.0
System.Runtime 4.0.10.0 is from .NET 4.5.1

There seemed to be no references to .NET 4.0 in the project, so what causes the error output referencing the automagically added mscorlib 4.0.0.0 and user specified System.Runtime 4.0.10.0?

Code:
Severity	Code	Description	Project	File	Line	Suppression State
Error	CS0433	The type 'AssemblyCompanyAttribute' exists in both 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' and 'System.Runtime, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'	AssemblyInfo.cs	12	Active

I tried undoing all this by removing the 4.5.1 Assemblies from the project and reverting to .NET 4 settings. This also failed. VS2017 requires references to the previous 4.0.0.0 file versions, and those probably came fom GAC. I cannot find the .NET 4 assemblies on the filesystem and they are not downloadable for Windows 10.

Visual Studio seems unable to recover from this. Source control cannot help because the code has not changed. How do I make this go away? Please help, many thanks!

Promised screenshot:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top