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

DotNetty .net7.0 published Aot ok, but error to run examples/Echo.Server #600

Open
wenchao-cui opened this issue Nov 14, 2022 · 2 comments

Comments

@wenchao-cui
Copy link

wenchao-cui commented Nov 14, 2022

(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.CreateInstanceT + 0x39
--- End of inner exception stack trace ---
at System.Activator.CreateInstanceT + 0xb7
at DotNetty.Transport.Bootstrapping.AbstractBootstrap2.<>c__101.b__10_0() + 0x22
at DotNetty.Transport.Bootstrapping.AbstractBootstrap2.<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.AbstractBootstrap2.d__26.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

@wenchao-cui wenchao-cui changed the title DotNetty .net7.0 published Aot ok, but run error DotNetty .net7.0 published Aot ok, but error to run examples/Echo.Server Nov 14, 2022
@ScarletKuro
Copy link
Contributor

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.

@wenchao-cui
Copy link
Author

wenchao-cui commented Nov 21, 2022 via email

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

No branches or pull requests

2 participants