akkadotnet / akka.net

Canonical actor model implementation for .NET with local + distributed actors in C# and F#.
http://getakka.net
Other
4.69k stars 1.04k forks source link

Akka.Actor: does not run inside Blazor WASM #5082

Open Aaronontheweb opened 3 years ago

Aaronontheweb commented 3 years ago

Version Information Version of Akka.NET? v1.4.20 Which Akka.NET Modules? Akka

Describe the bug At the moment it is not possible to start an ActorSystem inside a WASM Blazor application due to a number of platform compatibility / unsupported methods Akka.NET calls during startup.

To Reproduce

  1. Create Blazor WASM application;
  2. Call ActorSystem.Create

See https://github.com/petabridge/DrawTogether.NET/pull/10 for a code sample

Expected behavior Akka.NET should be able to start up correctly.

Actual behavior

blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: Exception has been thrown by the target of an invocation.
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 obj)
   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, Config config)
   at DrawTogether.UI.Client.Program.<>c.<Main>b__0_0(IServiceProvider sp) in D:\Repositories\DrawTogether.NET\src\DrawTogether.UI\Client\Program.cs:line 26

Screenshots You can see me try to run it here https://www.twitch.tv/videos/1050466404

Environment Windows, .NET 5, Chromium Browser

Aaronontheweb commented 3 years ago

https://github.com/akkadotnet/akka.net/pull/5085#issuecomment-858071518 - looks like this will be pretty complicated to implement