interactive icon indicating copy to clipboard operation
interactive copied to clipboard

System.Net.Http.Json not recognized

Open Expecho opened this issue 1 year ago • 2 comments

Describe the bug

After loading System.Net.Http.Json the assembly is not loaded:

#r "nuget:System.Net.Http.Json"
using System.Net.Http.Json;

results in

The type or namespace name 'Json' does not exist in the namespace 'System.Net.Http' (are you missing an assembly reference?)

This happened as soon as I installed the latest version of Polyglot Notebooks in VS code requiring .Net 8.

Seems the same as this issue

Please complete the following:

Which version of .NET Interactive are you using? (In a notebook, run the #!about magic command. ):

image

  • OS
    • [x] Windows 11
    • [ ] Windows 10
    • [ ] macOS
    • [ ] Linux (Please specify distro)
    • [ ] iOS
    • [ ] Android
  • Browser
    • [ ] Chrome
    • [x] Edge
    • [ ] Firefox
    • [ ] Safari
  • Frontend
    • [ ] Jupyter Notebook
    • [ ] Jupyter Lab
    • [ ] nteract
    • [x] Visual Studio Code
    • [ ] Visual Studio Code Insiders
    • [ ] Visual Studio
    • [ ] Other (please specify)

Screenshots

image

Expecho avatar Dec 18 '23 12:12 Expecho

I've also experienced this issue.

My workaround was to downgrade the Polyglot notebook version to 1.0.456201 which worked as expected.

rob-nice avatar Jan 03 '24 09:01 rob-nice

I'm seeing this issue as well. I wrote an extension method as a work around for ReadFromJsonAsync:

public static async Task<T> ReadJsonAsync<T>(this HttpContent response  ){
			return await response.ReadAsStringAsync().
				ContinueWith<T>(s=>JsonSerializer.Deserialize<T>(s.Result));
		}

mjamesharmon avatar Jan 04 '24 23:01 mjamesharmon

any news about this?

yueyinqiu avatar Mar 13 '24 11:03 yueyinqiu

This doesn't work because System.Text.Json.Http is a framework assembly. If you use #r without the nuget prefix it will work:

#r "System.Net.Http.Json"
using System.Net.Http.Json;

jonsequitur avatar Mar 14 '24 22:03 jonsequitur

Thanks!

Expecho avatar Mar 22 '24 07:03 Expecho