0

I am using Visual Studio 2022, in a C# project, trying to resolve a assembly name/version mismatch issue.

I've read though this thread, which was a bit helpful: Strange issue with System.Net.Http 4.2.0.0 not found

But despite installing the latest System.Net.Http through NuGet, I am still unable to add System.Net.Http.WebRequestHandler from 4.2.0.0. It would only reference the 4.0.0.0 version.

When I try to build my installer, it is throwing these warnings, 1) they are being "under Windows System File Protection" and 2) it is bundling 2 of those System.Net.Http.dll with the 2 different versions mentioned above.

    WARNING: 'System.IO.Compression.FileSystem.dll' should be excluded because its source file 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.IO.Compression.FileSystem\v4.0_4.0.0.0__b77a5c561934e089\System.IO.Compression.FileSystem.dll' is under Windows System File Protection.
    WARNING: 'System.IO.Compression.dll' should be excluded because its source file 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.IO.Compression\v4.0_4.0.0.0__b77a5c561934e089\System.IO.Compression.dll' is under Windows System File Protection.
    WARNING: 'System.Net.Http.WebRequest.dll' should be excluded because its source file 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Net.Http.WebRequest\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Net.Http.WebRequest.dll' is under Windows System File Protection.
    WARNING: 'System.Diagnostics.Tracing.dll' should be excluded because its source file 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Diagnostics.Tracing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Diagnostics.Tracing.dll' is under Windows System File Protection.
    WARNING: 'System.Net.Http.dll' should be excluded because its source file 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Net.Http.dll' is under Windows System File Protection.

So my questions are:

  • How do you get Visual Studio 2022 to properly install and/or set those assembly version?
  • How do you get around those "under Windows System File Protection" warnings?

When I run Analyze Assembly Dependencies, I am getting this conflict, 2 different DLLs with the same name but different versions:

enter image description here

I have these components installed:

enter image description here

Edit: Is there a way to force/change the default version of the assembly? It only shows 4.2.0.0.

enter image description here

Bob Arnson
  • 21,377
  • 2
  • 40
  • 47
codenamezero
  • 2,724
  • 29
  • 64
  • The best way of getting rid of error is to remove the current version of the WebRequestHandler reference in the project using the Solution Explorer. Then add the latest reference. Your error is due to the version not matching the version of the Net Library you are using. – jdweng May 16 '23 at 14:21
  • @jdweng I did that, many times, it just won't work. I removed all those references, even uninstalled all the NuGet packages, then reinstall the NuGet packages, then go to the code and right click on my WebRequestHandler and add the assembly, but it won't let me choose, it just add the same wrong version again. This is after I restarted Visual Studio. I tried many many ways without success. – codenamezero May 16 '23 at 14:23
  • Read the Nov 5, 2018 comments : https://github.com/dotnet/runtime/issues/24373?force_isolation=true – jdweng May 16 '23 at 15:06

0 Answers0