Skip to content

Commit 0b70717

Browse files
On platforms that don't support Quic, allow PlatformNotSupportedException
1 parent 8ca5d1e commit 0b70717

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/Servers/Kestrel/Transport.Quic/src/WebHostBuilderQuicExtensions.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static class WebHostBuilderQuicExtensions
2020
/// <returns>The <see cref="IWebHostBuilder"/>.</returns>
2121
public static IWebHostBuilder UseQuic(this IWebHostBuilder hostBuilder)
2222
{
23-
if (QuicImplementationProviders.Default.IsSupported)
23+
if (IsQuicSupported())
2424
{
2525
return hostBuilder.ConfigureServices(services =>
2626
{
@@ -44,4 +44,18 @@ public static IWebHostBuilder UseQuic(this IWebHostBuilder hostBuilder, Action<Q
4444
services.Configure(configureOptions);
4545
});
4646
}
47+
48+
private static bool IsQuicSupported()
49+
{
50+
try
51+
{
52+
return QuicImplementationProviders.Default.IsSupported;
53+
}
54+
catch (PlatformNotSupportedException)
55+
{
56+
// On some platforms, System.Net.Quic is just a stub assembly in which every method throws PlatformNotSupportedException,
57+
// including the QuicImplementationProviders.Default.IsSupported getter.
58+
return false;
59+
}
60+
}
4761
}

0 commit comments

Comments
 (0)