4
votes

I don't know what I did, but I may have removed System.Net.Http 4.0.0.0 from the GAC. I have a Windows Portable Library that targets WinRT that was compiling and working fine, and now I get the following error every time I try and run it

Could not load file or assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.":"System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

how can I re-add System.Net.Http 4.0.0.0? Every time I look for the .dll, I find the 2.0.0.0 version?

4
Can you tell me if C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Net.Http.dll is missing?David Kean
I got all the way, BUT the last folder (second to last command) was v4.0_2.0.0.0_b03f5f7f11d50a3a, so, there is a 2 near the beginning, not a 4.joe_coolish
What version of Windows are you on?David Kean
Windows 8. I'm trying to build a WinRT applicationjoe_coolish
To repair, you will need to run System Restore to restore Windows binaries to an earlier version when it did work. To help me understand the cause of this, did you uninstall something recently that might have broken this?David Kean

4 Answers

8
votes

To repair this on versions of Windows prior to Windows 8, go to Add or Remove Programs and do a repair install of the .NET Framework 4.5.

To pair this on versions Windows 8 or greater, you will need to run System Restore to restore Windows binaries to an earlier version when it did work.

1
votes

Have you tried to delete, then re-add the reference from the project?

0
votes

Try folder:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0
and copy the dll into GAC using gacutil tool from folder
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin

0
votes

If it was but now is not, is high likely that you changed something in your project, if i understand correctly you're creating a Portable Library (not a Windows Store one), if that's the case, probably you changed what plataforms you're targeting, open the Properties of the project and in Library->Target Frameworks click on Change, there, if you have everything selected or .NET Framework 4.0.3 is selected, then System.Net.Http is not allowed, to solve this, you need to quit some selections and enable the .NET Framework 4.5, as this the minimum version to use System.Net.Http.