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

ActorSystem.Create throws PlatformNotSupportedException on net7.0-android #6459

Closed
whoteit92 opened this issue Feb 27, 2023 · 4 comments · Fixed by #6463
Closed

ActorSystem.Create throws PlatformNotSupportedException on net7.0-android #6459

whoteit92 opened this issue Feb 27, 2023 · 4 comments · Fixed by #6463

Comments

@whoteit92
Copy link

Version Information
1.4.49
Akka.NET

Describe the bug
We have an application that we decided to port to .NET MAUI to have it also be available on Android. When the application is run on Android, the following exception is thrown.

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.PlatformNotSupportedException: Operation is not supported on this platform.
   at System.ConsolePal.get_BackgroundColor()
   at System.Console.get_BackgroundColor()
   at System.Reflection.RuntimePropertyInfo.StaticGetterAdapterFrame[ConsoleColor](StaticGetter`1 getter, Object _)
   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
   --- End of inner exception stack trace ---
   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
   at System.Reflection.PropertyInfo.GetValue(Object obj)
   at Akka.Actor.Internal.ActorSystemImpl.Start()
   at Akka.Actor.ActorSystem.CreateAndStartSystem(String name, Config withFallback, ActorSystemSetup setup)
   at Akka.Actor.ActorSystem.Create(String name, ActorSystemSetup setup)

To Reproduce
Steps to reproduce the behavior:

  1. Create a .NET MAUI project targeting .NET 7.0
  2. Add Akka.NET NuGet package
  3. Call ActorSystem.Create (name and ActorSystemSetup overload)
  4. Above exception will be thrown.

Links to working reproductions on Github / Gitlab are very much appreciated

Expected behavior
Either catch the exception thrown by the below line (ActorSystemImpl.cs) or add a compiler directive to not execute it on Android.
typeof(Console).GetProperty("BackgroundColor").GetValue(null); // HACK: Only needed for MONO

Actual behavior
PlatformNotSupportedException

Environment
Works fine on Linux and Windows. Throws on Android. Unable to test on iOS.

Additional context
Add any other context about the problem here.

@Aaronontheweb
Copy link
Member

Ah, so it's this line that throws?

// Force TermInfoDriver to initialize in order to protect us from the issue seen in #2432
typeof(Console).GetProperty("BackgroundColor").GetValue(null); // HACK: Only needed for MONO

That's ancient code - I bet it can be removed safely these days.

@Aaronontheweb
Copy link
Member

Added a PR to remove it here #6463

@Aaronontheweb Aaronontheweb added this to the 1.5.0 milestone Feb 27, 2023
@whoteit92
Copy link
Author

Thank you for the quick response, I will validate the official fix when the PR is merged (already validated that removing that line fixes the issue on our fork).

@Aaronontheweb
Copy link
Member

@whoteit92 sounds good - that bit of code was added there probably in 2015, when Mono was the only real game in town to run Akka.NET on POSIX systems. Not needed anymore in the days of .NET Core (and Mono probably fixed that bug at some point.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants