MSB3644 The reference assemblies for framework were not found
Asked Answered
S

2

15

I am getting the following MSB3644 complication error:

The reference assemblies for framework ".NETFramework,Version=v4.0" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

From what I've read here, it is due to assemblies on my machine stored in "Program Files" and not in "Program Files (x86)". A FrameworkPathOverride property on MSBuild can fix it.

I've tried adding this property (FrameworkPathOverride) to the csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <Import Project="..\..\tools\common.props" />
  <PropertyGroup>
    <TargetFrameworks>net40;net45;netstandard1.2</TargetFrameworks>
    <GeneratePackageOnBuild>False</GeneratePackageOnBuild>
    <FrameworkPathOverride>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0</FrameworkPathOverride>
  </PropertyGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
    <Reference Include="System.Configuration" />
  </ItemGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
    <Reference Include="System.Configuration" />
  </ItemGroup>
  <PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.2' ">
    <DefineConstants>$(DefineConstants);NETSTANDARD</DefineConstants>
  </PropertyGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.2' ">
  </ItemGroup>
</Project>

That error then dissapears, but all my types and namespaces cannot be resolved, and I also get this build warning:

MSB3270 There was a mismatch between the processor architecture of the project being built "AMD64" and the processor architecture of the reference "C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.

After setting the project's target framework to x86, the warning disappears, but still no types or namespaces can resolve.

I have all the necessary frameworks installed:

enter image description here

I am using Visual Studio 2017 on Windows 10.

Swagsman answered 25/7, 2017 at 12:15 Comment(2)
How did you build your project? Since you have installed VS2017, how about the result when you build the project from VS? Besides, you said "assemblies on my machine stored in "Program Files" and not in "Program Files (x86)" but you override the framework path to "C:\Program Files (x86)", which confuse me. Isn`t the path "C:\Program Files "?Boni
Did you found a solution? I am having the same issue but compiling on a MACHerron
C
2

Got the same error. The framework version was installed alright on my computer (running the installer for this specific version of the framework did nothing - it told me it was already installed). But the framework was not installed "as part of" Visual Studio.

What fixed it for me : Run the VS installer (re-download it from here if you lost it), click "modify" on Visual Studio, go to the "individual components" tab, and check things that are missing under the .NET category.

I didn't set any FrameworkPathOverride on my csproj.

Conceal answered 15/4, 2019 at 15:9 Comment(0)
D
0

For anybody else stumbling across this question, I got this error because the LangVersion property set in the build configurations did not match the version set in the root PropertyGroup. Check if your project file contains multiple LangVersion properties and make sure they are all targeting the correct version number.

Dissidence answered 10/5, 2022 at 16:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.