Open wenchao-cui opened 1 year ago
To make it AOT compatible you need to make it trim compatible. To make it support trimming you need to annotate the library with DynamicallyAccessedMembers / DynamicDependency etc. Since there is no active development in dotnetty and there is no one to merge community PRs, then do not expect this to be solved.
邮件已收到,这是自动回复
(1) I changed all the dotnetty .csproj files changed TargetFrameworks to net7.0 added PublishAot
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net7.0</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Configurations>Debug;Release;Package</Configurations>
<Platforms>AnyCPU</Platforms>
<PublishAot>true</PublishAot>
</PropertyGroup>
(2) Compiled examples/Echo.Server as debug / release version, run Echo.Server.exe, everything was OK OK
appsettings.json { "ssl": "false", "port": "28007", "libuv": "false" }
(3) Published the project win-x64 OK.
But there was error to run the Echo.Server.exe
[F:\github\DotNetty\examples\Echo.Server\publish]$ Echo.Server.exe Unhandled Exception: System.AggregateException: One or more errors occurred. (Exception has been thrown by the target of an invocation.) ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: A type initializer threw an exception. To determine which type, inspect the InnerException's StackTrace property. ---> System.ArgumentNullException: Value cannot be null. at Internal.Reflection.Extensions.NonPortable.CustomAttributeInheritanceRules.GetMatchingCustomAttributes(MemberInfo, Type, Boolean, Boolean) + 0x1af at System.Reflection.CustomAttributeExtensions.GetCustomAttribute[T](MemberInfo, Boolean) + 0x2f at DotNetty.Transport.Channels.AbstractChannelHandlerContext.IsSkippable(Type, String, Type[]) + 0x9e at DotNetty.Transport.Channels.AbstractChannelHandlerContext.CalculateSkipPropagationFlags(Type) + 0x2c at DotNetty.Transport.Channels.DefaultChannelPipeline.TailContext..cctor() + 0x4f at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext) + 0xc6 --- End of inner exception stack trace --- at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext) + 0x167 at System.Runtime.CompilerServices.ClassConstructorRunner.CheckStaticClassConstructionReturnGCStaticBase(StaticClassConstructionContext*, Object) + 0xd at DotNetty.Transport.Channels.DefaultChannelPipeline..ctor(IChannel) + 0x3d at DotNetty.Transport.Channels.AbstractChannel.NewChannelPipeline() + 0x23 at DotNetty.Transport.Channels.AbstractChannel..ctor(IChannel) + 0x83 at DotNetty.Transport.Channels.Sockets.AbstractSocketChannel..ctor(IChannel, Socket) + 0x1a at DotNetty.Transport.Channels.Sockets.TcpServerSocketChannel..ctor() + 0x3a at System.Activator.CreateInstance[T]() + 0x39 --- End of inner exception stack trace --- at System.Activator.CreateInstance[T]() + 0xb7 at DotNetty.Transport.Bootstrapping.AbstractBootstrapb__10_0() + 0x22
at DotNetty.Transport.Bootstrapping.AbstractBootstrapd26.MoveNext() + 0xbb
--- End of stack trace from previous location ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb6
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x42
at Echo.Server.Program.d 0.MoveNext() + 0x38e
--- End of stack trace from previous location ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
at Echo.Server.Program.d__0.MoveNext() + 0x536
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.Wait(Int32, CancellationToken) + 0xc5
at Echo.Server!+0x332125
2.<>c__10
1.2.<InitAndRegisterAsync>d__27.MoveNext() + 0x4d --- End of stack trace from previous location --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb6 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x42 at DotNetty.Transport.Bootstrapping.AbstractBootstrap
2.