Skip to content
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

.NET HTTP3 interop scenarios #160

Closed
ladeak opened this issue Oct 12, 2023 · 3 comments
Closed

.NET HTTP3 interop scenarios #160

ladeak opened this issue Oct 12, 2023 · 3 comments

Comments

@ladeak
Copy link

ladeak commented Oct 12, 2023

I have been experimenting with this library. I have a tool that is written in .NET 8, AOT compiled, and I try to use the C# API from a VS Code Extension (electron) app.
When the tool uses HTTP2 to make HTTP requests with HttpClient in the .NET assembly, the request is sent, and a response is received.

However, when using HTTP3 in the .NET assembly (which uses msquic on Windows), I got an empty response. I would like to better understand what could be the reason behind it: likely that it cannot access the msquic lib.
So far, I tested that the native AOT package when simply used as an executable it can make the HTTP3 requests, and responses are received.

Could you point me to the right direction to continue my investigation on this?

@jasongin
Copy link
Member

jasongin commented Nov 3, 2023

it cannot access the msquic lib

I am aware there is currently a problem when an assembly depends on a native library that it expects to load from the same directory. So far I haven't found a good general solution. If that is the issue here, you should be able to work around the problem by explicitly loading the msquic native library with dotnet.load(). See the WPF example, which explicitly loads a couple native libraries that the WPF assemblies depend on.

@ladeak
Copy link
Author

ladeak commented Nov 4, 2023

msquic his is not loaded from the same directory, myquic is installed with a windows update, and I see dotnet loads it like this:
And this is how .NET does it: https://source.dot.net/#System.Net.Quic/System/Net/Quic/Internal/MsQuicApi.cs,87

I am using the .NET Publish AOT solution, so I am not sure if I can use the suggested dotnet.load()

https://github.com/microsoft/msquic/blob/main/docs/Platforms.md - I just found this:

MsQuic is shipped in-box in the Windows kernel in the form of the msquic.sys driver, to support built-in HTTP and SMB features. User mode applications use msquic.dll (built from here) and package it with their app.

What confuses me is that when I "simply" run the .NET AOT app from a console it can load msquic, but not from a VS Code plugin.

I wonder if this is related: dotnet/runtime#73290

Interestingly, when I try to load the library myself by hand in .NET like this:

bool loaded = NativeLibrary.TryLoad("C:\\Windows\\System32\\drivers\\msquic.sys", out msQuicHandle);

it returns success.

@ladeak
Copy link
Author

ladeak commented Nov 4, 2023

I will close this issue, as I think this is now an issue to be opened in .NET 8. See my comment in dotnet/runtime#73290

@ladeak ladeak closed this as completed Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants