-
Clone this repo and run
dotnet publish .\ReadyToRunRepro\ReadyToRunRepro.csproj --configuration=Release -p:PublishReadyToRun=true --runtime win-x64 --self-containedfollowed by
.\ReadyToRunRepro\bin\Release\net7.0\win-x64\publish\ReadyToRunRepro.exe -
See that the worker service correctly starts and runs without errors
-
Change the target framework in
ReadyToRunRepro.csprojto .NET 8:<TargetFramework>net8.0</TargetFramework> -
Publish again with the same command as in 1.:
dotnet publish .\ReadyToRunRepro\ReadyToRunRepro.csproj --configuration=Release -p:PublishReadyToRun=true --runtime win-x64 --self-containedand then start the published .NET 8 exe:
.\ReadyToRunRepro\bin\Release\net8.0\win-x64\publish\ReadyToRunRepro.exe -
The following exception occurs:
Unhandled exception. System.TypeLoadException: Return type in method 'ReadyToRunRepro.DataElementBase`1[TIdentifier].get_Id()' on type 'ReadyToRunRepro.DataElementBase`1[TIdentifier]' from assembly 'ReadyToRunRepro, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not compatible with base type method 'ReadyToRunRepro.DataElementBase.get_Id()'.
at ReadyToRunRepro.Service..ctor()
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitIEnumerable(IEnumerableCallSite enumerableCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(ServiceIdentifier serviceIdentifier)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
at Program.<Main>$(String[] args) in C:\source\ReadyToRunRepro\ReadyToRunRepro\Program.cs:line 8
Deleting either one of these three lines (commented with in code deleting this line will make the error go away) will make the problem go away:
-
in
Service.cs:private readonly NestedDictionary<NodeIdentifier, EventDefinitionIdentifier, EventDefinitionBase> dict = new();
-
in
Worker.csthis.logger.LogInformation("Service {service} acquired", this.service);
-
in
Types.cs:public record EventSettings : EventSettingsBase;