22
votes

Just installed Visual Studio 2017 (full version) from MSDN website. Created a new Asp.Net Core Web Application (.Net Framework) with .net framework 4.6 selected. Project name = "WebApplicationWithTemplate"

Added another project of type Class Library (.Net Standard) again with .net framework 4.6 selected. Project name = "DataAccessRegular"

Next tried to add the reference of class library project to the Asp.Net Core web application and I get this error:

enter image description here

Cannot find project info for 'E:\Development\VS2017Solution\DataAccessRegular\DataAccessRegular.csproj'. This can indicate a missing project reference. WebApplicationWithTemplate C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets 92

Also created Class Library (.net core) project [not shown in the screen shot above] and added its reference to asp.net core project and still getting the same error.

Also read This link on github but did not find it helpful unfortunately.

The point for asking this is because I want to keep the model, service and data access layers in a separate project.

11

11 Answers

10
votes

To solve this, in your csproj for the class library, either change <TargetFramework>netstandard1.4</TargetFramework> to <TargetFramework>net46</TargetFramework> or <TargetFrameworks>netstandard1.4;net46</TargetFrameworks>

Note, that if you specify more than one target, element should be change to plural TargetFrameworks , not TargetFramework (Build errors when multi-targeting in csproj file)

What you're seeing is coming from the Class Library (.NET Standard) template actually targeting .NET Standard (netstandard1.4 specifically) rather than the selection in the target framework dropdown. Using the Class Library (.NET Framework) template instead would also work.

Update:

Additional options:

  • Change the web application to target .NET Framework 4.6.1 (this will allow things that target netstandard1.4 to be referenced
  • Change the class library to target netstandard1.3 (this will allow it to be referenced from projects targeting .NET Framework 4.6)

We're also tracking improving the way that these issues get surfaced with https://github.com/dotnet/sdk/issues/829 and https://github.com/dotnet/roslyn-project-system/issues/1470

20
votes

I got this problem after removing a nuget package (which I had built myself) from a solution then replacing it with a project reference to the project from which the package was built. The solution to the issue...? Close VS and reopen it.

16
votes

I resolved this by correcting my mistake that the reference was added both as a project reference AND as a browse reference.

The assembly was thus referenced twice - directly as an assembly - and indirectly as the output of a included project.

When I removed the browse reference and only kept the project reference it cleared up.

5
votes

Referenced project's path stored in .csproj is case sensitive! So, be aware, and check if you have the correct path in correct case! To do this:

  1. Right click on the project
  2. select Edit
  3. Check <ProjectReference Include=<Path>

NOTE (KDuenke): This can be an issue on a Windows machine as well, especially if you're using Docker for Windows.

3
votes

If you erroneously referenced the dll as well as having the project referenced you will see that the References/Assemblies node of the solution explorer contains .dll as well you can look under referenced projects and see the same named project. Remove either the contains .dll from the assemblies if you need the project referenced or remove the project if you only need a reference to the contains .dll.

In my case I just removed the assembly from the Reference/Assemblies list.

1
votes

I removed this tag from the .csproj file of the project that was the source of the error...

<ItemGroup>
    <Reference Include="MyIntegration">
      <HintPath>..\MyIntegration\bin\Debug\netstandard2.0\MyIntegration.dll</HintPath>
    </Reference>
  </ItemGroup>

Note: I had selected a 'Browse' reference of this .dll, which added the previous code to my .csproj. Removed and error went away.

FYI, a <ProjectReference> line is added to your .csproj every time you select a new project reference from Dependencies

0
votes

I has this same problem and remove reference class from assemblies and resolve this problem,

0
votes

Had this problem when renaming a project and the folder (with the .csproj file) as well. I did a dotnet restore on the two projects giving me this error (which had a reference to the project before renaming and after I added a reference to the "new" renamed project) and then the Solution succesfully built.

0
votes

If you have added the reference of dll to assembly and added as project reference as well in dependencies, then you will face this issue (one of the many possible reason)

You just need to delete the reference from assembly section of dependencies

Check Below: Example

0
votes

In my case, in Project A there was a project B project reference that included a NuGet package that was built from Project C which was also a project reference in Project A. Solution was to change the NuGet reference to a project reference.

0
votes

I just spent a day on this issue after renaming a project (files/folders/...)

None of the given answers helped. VS restarts, full clean/rebuilds, ... I even looked for any mention of the offending reference in any solution file (both using VS and Powershell) and nothing popped up, yet the error persisted.

In the end, I resolved it by VPN connecting to my office (I was working from home) where our Nuget server resides. Weirdly, no packages were downloaded (since they were all offline available already) but the issue was resolved.

Check if there's an issue with the connection to your Nuget server. I have no idea why but it fixed it for me.