question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Xamarin.Mac: WebHost.RunAsync without CancellationToken fails with Unsupported platform exception

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

WebHost.RunAsync() fails with unsupported platform exception with Xamarin.Mac if no cancellation token specified. If CancellationToken is set - no exceptions

Expected Behavior

No exception and valid behavior

Steps To Reproduce

var webHost = new WebHostBuilder()
                .UseUrls(url)
                .ConfigureServices(services =>
                {
                    services.AddRouting();
                })
                .Configure(app =>
                {
                    app.UseRouter(router);
                })
                .UseKestrel()
                .Build();

            listeningTask = webHost.RunAsync()
                .ContinueWith(x =>
                {
                    if (x.IsFaulted)
                    {
                        Logger.Debug(x.Exception, "Run async failed");
                    }
                });

Exceptions (if any)

System.PlatformNotSupportedException: Operation is not supported on this platform. at System.Console.add_CancelKeyPress (System.ConsoleCancelEventHandler value) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/src/Xamarin.Mac/mcs/class/corlib/System/Console.cs:948 at Microsoft.AspNetCore.Hosting.WebHostExtensions.AttachCtrlcSigtermShutdown (System.Threading.CancellationTokenSource cts, System.Threading.ManualResetEventSlim resetEvent, System.String shutdownMessage) [0x00031] in <127e718ac42e4542a71b54cec3ef156b>:0 at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync (Microsoft.AspNetCore.Hosting.IWebHost host, System.Threading.CancellationToken token) [0x000ca] in <127e718ac42e4542a71b54cec3ef156b>:0

.NET Version

No response

Anything else?

Visual Studio for Mac information:

=== Visual Studio Enterprise 2019 for Mac ===

Version 8.10.17 (build 2) Installation UUID: bca04928-dcb5-4e15-8241-ef7d600b17ff GTK+ 2.24.23 (Raleigh theme) Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

Package version: 612000162

=== Mono Framework MDK ===

Runtime: Mono 6.12.0.162 (2020-02/2ca650f1f62) (64-bit) Package version: 612000162

=== Roslyn (Language Service) ===

3.10.0-4.21269.26+029847714208ebe49668667c60ea5b0a294e0fcb

=== NuGet ===

Version: 5.9.0.7134

=== .NET SDK (x64) ===

SDK: /usr/local/share/dotnet/sdk/5.0.404/Sdks SDK Versions: 5.0.404 3.1.416 MSBuild SDKs: /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet Runtime Versions: 5.0.13 3.1.22

=== .NET Core 3.1 SDK ===

SDK: 3.1.416

=== .NET 5.0 SDK ===

SDK: 5.0.404

=== Xamarin.Profiler ===

Version: 1.6.15.68 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Xamarin.Android ===

Not Installed

=== Eclipse Temurin JDK ===

Java SDK: Not Found

=== Android SDK Manager ===

Version: 16.10.0.13 Hash: 1b81df5 Branch: remotes/origin/d16-10 Build date: 2021-11-12 01:17:32 UTC

=== Android Device Manager ===

Version: 16.10.0.15 Hash: 89dcc0b Branch: remotes/origin/d16-10 Build date: 2021-11-12 01:17:52 UTC

=== Apple Developer Tools ===

Xcode 13.2.1 (19586) Build 13C100

=== Xamarin.Mac ===

Version: 8.4.0.0 (Visual Studio Enterprise) Hash: 8fc41ae82 Branch: xcode13.2 Build date: 2021-12-09 01:07:56-0500

=== Xamarin.iOS ===

Xamarin.iOS not installed. Can’t find mtouch or the Version file at /Library/Frameworks/Xamarin.iOS.framework/Versions/Current.

=== Xamarin Designer ===

Version: 16.11.0.60 Hash: 56f9b80b0 Branch: remotes/origin/d16-11 Build date: 2021-12-15 02:44:16 UTC

=== Build Information ===

Release ID: 810170002 Git revision: 58f7763d4d64fcf005a474d25a5d9fd5ce46d7f5 Build date: 2022-01-05 12:51:28-05 Build branch: release-8.10

=== Operating System ===

Mac OS X 12.2.0 Darwin 21.3.0 Darwin Kernel Version 21.3.0 Wed Jan 5 21:37:58 PST 2022 root:xnu-8019.80.24~20/RELEASE_X86_64 x86_64

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
MaximLipnincommented, Mar 9, 2022

At first glance, PNSE in System/Console.cs on Mono side seems to be expected behavior - at least there has not been any relevant changes for a couple of years.

0reactions
msftbot[bot]commented, Mar 12, 2022

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Running .NET Core Web host and Kestrel server on Xamarin ...
In one of my previous Xamarin projects, I needed a simple Web server ... throws an exception: “Operation is not supported on this...
Read more >
PlatformNotSupportedException in iOS Release build only
The NotSupportedPlatform exception is quite specifically called out as being an issue with Xamarin.iOS using a version of microsoft.extensions.
Read more >
Connection Troubleshooting for a Xamarin.iOS Build Host
This guide provides troubleshooting steps for issues that may be encountered using the new connection manager, including connectivity and ...
Read more >
C# – Graceful shutdown with Generic Host in .NET Core 2.1
However, shutdown is not graceful – application still have unfinished ... and an IDE called MonoDevelop (also knows as Xamarin Studio or Visual...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found