-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could not load file or assembly 'netfx.force.conflicts' #23174
Comments
@ericstj do you know what 'netfx.force.conflicts' is? |
Hello, I got the same problem when I trying to run my .NET Framework ASP.NET app. Do I need to uninstall .NET Core 2.0 SDK? |
I found a solution: delete the |
For me, the application works when I run it in debug through Visual Studio 2017 15.3, but when I publish it to a folder that my IIS is looking at, it wasn't working. I got it working in the end, and here were the things that I tried:
|
Its a facade that references every contract assembly that is inbox in desktop: https://github.com/dotnet/corefx/blob/master/src/netfx.force.conflict/ref/netfx.force.conflicts.csproj It is only a ReferenceAssembly and should never make it to the application's output directory. There is no corresponding lib for this assembly since it has no typedefs and will never appear in the runtime assembly closure.
Looking at that callstack it appears that Asp.NET may be doing something unusual, it looks to me like it is trying to load reference assemblies for execution. That'll fail whenever there is any assembly with the ReferenceAssemblyAttribute. @pranavkm @DamianEdwards does this look right to you? |
@pranavkm can you take a look? This might need to go to a System.Web person. |
@pranavkm can you port to aspnet repo if appropriate? |
@danmosemsft this would be for System.Web, which isn't on GitHub, it's in TFS only. Once we see what's going on here, if we can't resolve immediately, we'll forward to the System.Web folks (different people from ASP.NET Core team). |
I can't quite figure out how the assembly gets to the output directory. @alfeg \ @oldrev \ @chris31389 could you share your application's csproj or possibly repro steps \ application? |
@Eilon - ah, you're quite right. |
We're seeing the same issue. We have .NET 4.7 ASP.NET projects referencing .NET Standard 1.6 projects, all using
This may be a separate issue, but it wasn't happening with Visual Studio 15.2 and the associated tooling. For our build server I've 'fixed' the issue by copying across the |
@pranavkm my project is quite big to share. I will try to create repro later. |
This issue also happens suddenly to me in a non-Core .NET 4.6.2 / 4.7 project (i.e. full .NET Framework) together with Visual Studio 2017 Community Edition. My guess is that some NuGet package I'm using was updated and (accidentially) brings in .NET Core. Maybe unrelated: I'm also getting tons of exclamation marks in my references list after upgrading all NuGet packages to their latest version: When having maximum build log verbosity, I find lines like:
I have no idea why the "packages.config" reference to this "System.Security.Cryptography.X509Certificates" assembly does not actually fetch it from the NuGet-downloaded "packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461" folder but instead looks in the MSBuild folder. |
@UweKeim I've got the same issue. I'm having loads of |
@chris31389 Is there a way to get the actual error message behind a yellow exclamation mark |
@UweKeim Not to my knowledge. The messages I got were from the build output. |
/cc @weshaggard @ericstj who may have insight. |
/cc @dsplaisted This is the built-in netstandard support for .NETFramework. For net461 and later you no longer need packages to get netstandard support, we put it in the build system. @Quppa to fix those warnings you should apply all of the suggested binding redirects. That should resolve the YSOD. For projects with web.config this means double clicking the warnings in the error window and letting VS modify your web.config. For app.config you can enable automatic bindingRedirects and they'll be automatically written to app.config on build. @UweKeim check your error list's warning tab. You may see the same redirect warnings that @Quppa was mentioning and applying the redirects will fix them. edit: you may be hitting dotnet/sdk#1499 |
@ericstj Thanks - adding the redirects has indeed resolved the YSOD. I'm confused why we aren't getting the same error when the solution is built with 15.2. |
@danmosemsft \ @ericstj I'm able to (inconsistently) repro the issue of the binary getting in to the bin directory with a repro app @MaximRouiller pointed to: https://github.com/alfeg/vs15_3repro. Here are the steps that I've had the most success in reproduction:
I'm going to loop in @HongGit to see if there's anything further that can to address from the BuildManager end. |
Welcome to DLL hell. This is what happens when Microsoft parrots the Java Maven world. One of the things I have always hated about Java. .NET used to be superior, but, now we are in DLL hell thanks to the advent of NuGet. |
To me, the yellow exclamation marks remain present, no matter what I do. To my surprise, my project otherwise seems to runs fully functional. |
@UweKeim see the linked issue I opened in the SDK repo (with workaround). I think this is what you are hitting. |
Awesome support, @ericstj, thanks a lot. That actually did the trick! (Although I have no idea what this actually does 😕) If the workaround will be no longer necessary in the future, will it do any harm to leave it inside my CSPROJ files? Steps to solveThe linked solution says to add the following to the CSPROJ file:
Sometimes more was necessary to add to the CSPROJ file. My working CSPROJ ended up with the following added:
What also helped me was to switch the projects back from .NET 4.7 to something lower like 4.6.2. This also requires to edit all "packages.config" files and replace "
And finally, I also needed to delete the |
@UweKeim glad that worked for you. The thing its doing is tricking the IDE into thinking that the references that replaced your project entries actually came from the project. Hopefully we'll get the SDK to fix this bug. FWIW the same bug was present even in the project.json nuget stuff but it was less common. The workaround is mostly harmless, but it could also cause the same issue if you happened to have full-path references in the project itself. If we wanted it to be more scoped we could refine the workaround to not have that behavior. @pranavkm I see the repro. The msbuild log doesn't show the copy happening. Indeed build of the SLN from msbuild does not repro. Build from VS does: 100% for me. I procmon'ed it and I see the copy happening from the devenv.exe process (not msbuild, though I do see the MSBuild traces so I'm certain its an out-of-proc build). I'm not getting a good callstack out of procmon so will need to debug VS to get the actual culprit. I suspect some ASP.NET component responsible for debugging the site, so would be happy if someone can step in and help from that side. |
Correction, it's not build in VS that reproduces the copy, it is debug. An updated procmon gave me a stack, here's the culprit:
@Eilon / @pranavkm do you know who owns mswebprj.dll? Looks like it isn't honoring Private/CopyLocal=false |
@Jinhuafei could you please take a look? |
I got my library down to netstandard1.3.... and managed to remove the mvc dependency, it seems to work now. |
I'm curious why @ericstj's workaround in https://github.com/dotnet/corefx/issues/23229#issuecomment-323119376 is not working for people. The key is to add it to all your projects in your solution(s), not just web projects. Once we did that, we have not seen the issue come back for over a week now. |
@ericstj, @mscrivo I have applied workarounds from both https://github.com/dotnet/corefx/issues/23229#issuecomment-323119376 and https://github.com/dotnet/corefx/issues/23229#issuecomment-324959465. netfx.force.conflicts is not present in /bin folders, but it complains on other reference dlls like System.Data.Common and System.Diagnostics.StackTrace with the same error:
What else can I try to either remove those Reference assemblies or make those not copy to bin folders? |
I have investigated more and found that it works fine when I build web project. But when I build one of the projects that it references after build of web project I get the error from above. In particular it makes my tests fail. Any clue on what can it be? I have applied the fix to all the projects in the solution. And All are using PackageReference for NuGet. |
@andrii-litvinov We had this same issue. When you rebuild an underlying project, without building the web project, it copies the "wrong" versions of the assemblies to the web To get around this, I manually adjusted the binding redirects in the web.config for several assemblies to
Visual Studio gives warnings about those binding redirects, but I have instructed my team to ignore them for now. |
@jeremyhayes thank you for sharing your workaround! It works very well for assemblies that exist in GAC, but in my case System.Data.Common is not in GAC so this solution does not work. I am trying to understand where do those assemblies come from, because they are of smaller size (30KB comparing to 150KB when compiling web app) and possible workarounds for this. |
The assemblies are coming from "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft.NET.Build.Extensions" (vs2017) or "C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions" (older VS's) or "C:\Program Files\dotnet\sdk\2.0.0\Microsoft\Microsoft.NET.Build.Extensions" (dotnet cli). The assemblies under the "ref" folders are the smaller versions: they are reference assemblies that do not contain any implementation, only the metadata for our public API. The assemblies in the "lib" folder are the actual implementation assemblies.
Yes, that's the bug that @BillHiebert is fixing in the web project system. It's copying the reference assemblies when it shouldn't because it doesn't notice that they set copylocal=false. Despite the fix going into the web project system we still need to make a change to the targets that are adding the reference assemblies because the project-system update won't go everywhere and we're finding more cases of other desktop build tools that try to load the reference assemblies for execution.
That will break anyone who's depending on API that was added in the later versions. The ones in the GAC will be missing the API or typeforwards that were added to the assemblies. We're working making a better fix for this, see: https://github.com/dotnet/corefx/issues/23830. |
@ericstj Thank you for a quick reply and detailed explanation. @jeremyhayes, @ijsgaus solution provided by @ericstj in https://github.com/dotnet/corefx/issues/23439#issuecomment-323855505 worked for me. I realize that it is temporary solution until better one is created by MS, but still it helps to move on with .NET Standard 2.0 on Full Framework web applications. |
I am getting a similar issue with a web application project when I try and do a release build - but strangely not when I do a debug build. I've tried the various fixes listed above with no joy. Any suggestions? |
@DaleKBurrell Did you try the steps I summarized? |
Sure did - but I found the cause and added it as an edit to my original comment. Thanks for replying. |
I've investigated and lost lots of time on the issue too. Now what happens, MSBuild 'thinks' it is copying and loading the correct version into your build, but in fact, the Nuget verion, might be -newer- than the ones from here (Microsoft.NET.Build.Extensions see above). What happens next is, I think, 3 things.
You can set the boolean switch on 'false' but now the .NEtstandard facade does not exist in your bin folder, and thus, the NuGet libraries that depend on them, will fail. |
This issue should be fixed in VS 15.4. @egbertn See dotnet/standard#481 for some background around the DLLs that are added and some of the issues that exist. We're not aware of any issues where an "older" version of a DLL will be incorrectly chosen over a "newer" one. In fact, we have a "Conflict Resolution" target which compares the DLLs and chooses the "best" one, primarily based on assembly version. When you say that a newer DLL from NuGet isn't being chosen, how are you determining that the NuGet one is "newer"? Thanks! |
In a solution (vstudio 2017 enterprise or community) with web projects target .net 4.6.1 and .net core 2 when I compile one of them the others get its bin folders corrupted and appears the file netfx.force.conflicts. This is causing me a lot of time lost. Please help with fix that wrong behavior. |
@techaimail what fixed it for me is to migrate the 4.6.1 project to the new CSProj style. I found the old style was causing me the issue. |
@Jetski5822 The new version of Csproj works fine in legacy Solutions? |
So I've just encountered this issue after trying to add an internal .net core library to a .net 4.6 project. Have absolutely zero idea what to do in this case, have tried some of the fixes above, but nothing seems to be getting me through. Is there a concise summary of what's happening and what needs to be done here? Completely hit a wall here and need to resolve. |
Hello @atrauzzi , what my team and I have been doing all this time is just deleting the According to @dsplaisted it was going to be solved in version 15.4, which is already out so try upating just in case. |
Updated to VS 15.4 and this is still persisting for me. Solution has a total of 20 projects (class libraries, asp.net mvc / web api, console apps, MS Test projects) - all targeting 4.6.2. Yellow Screen of Death appears when debugging asp.net applications. Typically it references a faliure to find the correct version of None of the above fixes have worked for me. The only way I can get the web apps to debug is to run a Clean, then have a powershell command that nukes This is a total pain in the a$$ - it's killing productivity. It only started after running a solution wide nuget update - how am I supposed to figure out which one of the 160+ packages is the root cause for this? |
Based on dotnet/sdk#1612, I guess this fix didn't make it in time for 15.4. |
This might help ignoring netfx.force.conflicts.
|
This does seem to be fixed in 15.5. I've removed the |
Thanks for the confirmation @Quppa. I'm closing this issue as there isn't any work left to track. |
@UweKeim Thanks, it worked like a charm! |
I've compiled project with new release of VS 2015.3. Installed .Net Core 2.0 SDK.
Project is a pretty old Asp.Net web application, where all project deps were converted to .Net Standard.
No on every page load I get
How to resolve this?
The text was updated successfully, but these errors were encountered: