MagicOnion icon indicating copy to clipboard operation
MagicOnion copied to clipboard

Console app probem: PlatformNotSupportedException

Open mariorancic01 opened this issue 1 year ago • 1 comments

I was using services very successfully in Wpf app, now when i need to use the same client in my console app i got exception : The type initializer for 'MagicOnion.Client.DynamicClient.DynamicClientBuilder`1' threw an exception.' PlatformNotSupportedException: Dynamic code generation is not supported on this platform.

Here is the same code i used in WPF APP: var channel = GrpcChannel.ForAddress("myAddress"); var proxy = MagicOnionClient.Create<IArmatura>(channel)!;

mariorancic01 avatar Mar 05 '24 19:03 mariorancic01

i found solution to my own problem. I just needed to set PublishAot parameter to false instead of true

mariorancic01 avatar Mar 09 '24 18:03 mariorancic01

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Sep 06 '24 00:09 github-actions[bot]

How do I fix that? I want to use AOT @mayuki

System.PlatformNotSupportedException: Dynamic code generation is not supported on this platform.
   at System.Reflection.Emit.AssemblyBuilder.ThrowDynamicCodeNotSupported()
   at System.Reflection.Emit.AssemblyBuilder.EnsureDynamicCodeSupported()
   at System.Reflection.Emit.AssemblyBuilder.DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, IEnumerable`1 assemblyAttributes, Assembly callingAssembly)
   at MagicOnion.Server.Glue.MagicOnionGlueService.CreateType()
   at Microsoft.Extensions.DependencyInjection.MagicOnionServicesExtensions.AddMagicOnionCore(IServiceCollection services, Action`1 configureOptions)
   at Microsoft.Extensions.DependencyInjection.MagicOnionServicesExtensions.AddMagicOnion(IServiceCollection services, Action`1 configureOptions)
   at Program.<Main>$(String[] args) in E:\Projects\Company_Projects\TeraSync\TeraSync.Service\Program.cs:line 10

flier268 avatar Jan 09 '25 06:01 flier268

At the moment, MagicOnion do not support Native AOT on the server or client. We would like to support it in the future.

mayuki avatar Jan 10 '25 03:01 mayuki