Can’t build solution in Visual Studio

Problem:

When I wanted to build the solution in Visual Studio, I got message: Rebuild All failed.

Description:

I have 2 projects in the solution. MainApplication and ClassLibrary. The MainApplication has reference to ClassLibrary.

Project hierarchy in Solution Explorer in Visual Studio
Project hierarchy in Solution Explorer in Visual Studio

The Error List shows no error. There is also no error in code.

No error in Error List
No error in Error List

Then I switched to Output window and here I got more informations.

Output Window in Visual Studio
Output Window in Visual Studio

From the Output you see, that the ClassLibrary was successfully built. Problem was during the building of the MainApplication.

warning MSB3274: The primary reference "D:\Temp\13\MySolution\ClassLibrary\bin\Debug\ClassLibrary.dll" 
could not be resolved because it was built against the ".NETFramework,Version=v4.7.2" framework. 
This is a higher version than the currently targeted framework ".NETFramework,Version=v4.6.1".
2>D:\Temp\13\MySolution\MainApplication\Form1.cs(25,23,25,35): error CS0103: 
The name 'ClassLibrary' does not exist in the current context

From this information we know that the MainApplication has targeting Framework v4.6.1 but the ClassLibrary has higher version v4.7.2.

Solution:

I changed the Target Framework from v4.6.1 to v4.7.2 in MainApplication Project Properties.

Target Framework in Project Properties
Target Framework in Project Properties

After this change the Visual Studio successfully rebuilt the projects.

Summary:

The given project’s Target Framework version should be higher or equal than the target Framework version of referenced projects.


6x faster WordPress Hosting6x faster WordPress Hosting

Leave a Reply

Your email address will not be published. Required fields are marked *

14 + nineteen =