-
Notifications
You must be signed in to change notification settings - Fork 430
You must add a reference to assembly netstandard errors #542
Comments
Thank you, |
I managed to fix this problem by adding to csproj file with the references: <Reference Include="netstandard" /> I don't know if this workaround is good or has side effects, but it silenced the errors for me. |
Got the same problem, and the workaround fixes it. But why should this be necessary? Isn't 4.7.1 supposed to implement .NET Standard 2.0? |
Just a question, do you have ReSharper installed ? |
No |
I had the same issue with Visual Studio 15.4.4 with net471. Project didn't give errors with net47. |
Ran into a similar problem in a project targeting framework 4.6.1 but using newer netstandard memory cache libraries - fixed it with |
@AlexGhiondea any idea why they are having to add the netstandard reference manually on 471? |
It was fixed for Visual Studio 15.5: dotnet/msbuild#2567. |
This is because in 4.7.1 we no longer have to use the Support package to implicitly add references to facades since netstandard comes inbox starting from 4.7.1. That said, as @jp2masa we had a bug that was fixed in VS15.5 so you no longer have to add this manually. |
@joperezr I have VS 15.5.2, and experience the same errors when building from the command line. Visual Studio says there are no errors, but I get these errors from My problem was that my SDK was pinned to 2.0.3 via global.json, and resolved when pinning to 2.1.2. Strange that VS must be ignoring global.json. |
yeah I believe that what is happening is that VS doesn't use the CLI(SDK) for building, but instead calls into MSBuild directly, which version is tied to the VS version. That explains why you only see this when trying to build using the CLI, but I'm glad that the global.json workaround fixed the issue. |
yeah it seems to be just when you're using the msbuild cli tool to run builds that this issue crops up. unfortunately it seems to have caused some problems on our build server when i added the concrete reference to netstandard to our project so i had to remove it and i'm back in the same boat i was before when i try to cli build from VS Code :( |
These suggestions didn't solve my problem. I was working with a project and everything was working fine. I'm on .NET Core 2.0.3. All of a sudden it broke and now it gives me that annoying error. Any idea what might be wrong? |
@Nefcanto can you try with the latest released CLI? That should automatically add the reference to the netstandard facade if it needs it. |
I have the following issue with an integration test:
The <Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Reference Include="netstandard" />
</ItemGroup>
<!-- NuGet Libraries -->
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.0.1" />
<PackageReference Include="Microsoft.CodeCoverage" Version="1.0.3" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="NodaTime.Testing" Version="2.2.3" />
<PackageReference Include="NSubstitute" Version="3.1.0" />
<PackageReference Include="NUnit" Version="3.9.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.9.0" />
<PackageReference Include="Roslynator.Analyzers" Version="1.6.0" />
<PackageReference Include="Sendgrid" Version="9.9.0" />
</ItemGroup>
<!-- reference to project under test -->
<ItemGroup>
<ProjectReference Include="..\Portal\Portal.csproj" />
</ItemGroup>
<!-- Unit Test GUID -->
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<!-- include Razor Views -->
<ItemGroup>
<Folder Include="Views\" />
<Content Include="..\Portal\Views\**\*">
<Link>Views\%(RecursiveDir)\%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project> Visual Studio Version 15.5.3. Compilation of the project works fine and there are no assembly version conflicts reported during build. |
Same or similar problem
But:
I have tried the ideas and solutions from #2981, #860 and this one, but still the same error. |
cc: @dsplaisted |
In my case this was caused by the System.Immutable.Collections package and the workaround was to downgrade it: #534 |
For me, the error was on a VSTS build agent - the solution was to install the latest dotnet SDK |
@MattJeanes - Should be on the images as of the end of today - https://blogs.msdn.microsoft.com/devops/2018/01/19/january-2018-vsts-hosted-agent-image-updates/ |
@MatthewSteeples Those are the hosted agents, I was using a private one (should have clarified, my bad) - but yes that should solve the issue if anyone is getting it using the hosted agents. |
None of the above suggestions helped me. I'm using VS15.6 and .NET Core SDK 2.1.4. I don't have a global.json file. I explicitly added a reference to netstandard in each of the netstandard .csprojs. Any other ideas?
|
@jernelson7 this reference isn't required for the netstandard projects. If you don't have the up-to-date tools, you just need to add it to the project consuming those netstandard projects, so in this case, most likely you need to add to it your app directly. Check the error to see which project is complaining about this. |
only the comment of juscelior commented on Oct 25 2017 helped! I los a few hours on this as all I got was this:
|
@joperezr so what was the fix for this? And can you pin the fix someplace where people can find it. There are a bunch of random ideas that fix random problems for random people, but nobody from MS has put down The Fix(tm) that actually resolves this issue. We're blocked on upgrading a .NET 4.6.2 ASP.Net Web Forms project from going to .NET 4.7.2 so we can start sharing authentication cookies with its ASP.Net Core sister site. Bizarrely enough, publishing+precompiling in Debug mode allows this to work, but the moment you disable debug mode for precompilation you get jerked around by missing references to 'netstandard'. |
Getting the error message on your project is a symptom which may be caused by many different things like for example: Not enabling auto generation of binding redirects, using legacy VS versions to compile, using old-style packages.config instead of PackageReference for your NuGet references, manually adding references to dlls inside a restored NuGet package, etc. That is kind of the reason why you have seen different fixes work for different people, because unfortunately this problem may arise due to different circumstances. That said, the general advise which has worked most of the time is:
This really shouldn't block you at all, since netstandard.dll is inbox on .NET 4.7.2, as well as all the support for running netstandard assemblies. If you are hitting these sorts of issues while re-targeting, it may be because your project file has not been re-targeted correctly and perhaps has added some properties/references that were only meant for .NET 4.6.2. Whenever I need to re-target a .NET Framework project, I usually instead create a brand new 4.7.2 project, and just copy the source files over as well as add the missing references |
|
In my case i found out that the problematic nuget was System.Memory in version 4.5.1. when updated to version 4.5.3 it works!! |
I get this when I call: var rc = new RestClient(clientID, clientSecret,true); InnerException | {"Could not load file or assembly 'Flurl.Http, Version=2.3.2.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.":"Flurl.Http, Version=2.3.2.0, Culture=neutral, PublicKeyToken=null"} | System.Exception {System.IO.FileNotFoundException} This is from a clean install of the RingCentral.Client and the default dependencies install. |
The issue for me was having a NETStandard 2.1 library referenced and then removed but still present in binary directory. Due to dynamic loading (Autofac) it was trying to load it and complained about. So beside cleaning the project also ensure you delete everything in |
Hi, This OPEN for 4 years!!!! no one has considered to fix it? |
<ItemGroup>
<TrimmerRootAssembly Include="netstandard" />
</ItemGroup> |
I am running msbuild on a .net framework application in a Jenkins Build Job and getting the following error
... No option to change any code... Is there a workaround other than that... |
I haven't got this error in Rider IDE, only CLI. I got same error on some versions of MSBuild, e.g. the latest MSBuild 16(16.11.2) works fine, the MSBuild 17(17.0.4?) throws this error, I still got this error on some versions of MSBuild 16, seems randomly |
I have pinned one of those errors (
So my solution was to remove the partial class altogether and handle whatever was done there somewhere else. |
I had this same issue when targeting 4.8.0, Adding <system.web> <compilation debug="true" targetFramework="4.7.1" ><assemblies>
<add assembly="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"/>
</assemblies></compilation> Fixed it for me. |
We believe the issue has been fixed in MSBuild. If the issue still exists, file an issue in dotnet/msbuild. |
@fahadabdulaziz opened this here: microsoft/dotnet#527
Hi,
After targeting .Net Framework 4.7.1, in many projects referencing net standard libraries. I get these errors:
![errs](https://user-images.githubusercontent.com/5483584/31769585-f06cdab6-b4dc-11e7-9a58-f6d3f52341da.png)
csharp The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
Though I all the projects including that targeting net471 are building successfully!
Any thoughts ?
The text was updated successfully, but these errors were encountered: