-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Description
In a class library, I have Newtonsoft.Json and Hangfire.AspNetCore referenced using the following package references.
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.22" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" PrivateAssets="All" />
This worked in .Net 9, but after targeting .Net 10, I now get the following runtime exception.
System.IO.FileNotFoundException: 'Could not load file or assembly 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.'
If I remove PrivateAssets="All" from the package reference, everything works, but this will mean that anyone who references my library will now have visibility to Newtonsoft.Json. My goal is to only use Newtonsoft with Hangfire out of necessity, but effectively "hide" it from the rest of the application.
Here is the full Stack Trace for the Exception.
at Hangfire.GlobalConfigurationExtensions.UseRecommendedSerializerSettings(IGlobalConfiguration configuration, Action`1 settingsConfiguration)
at Hangfire.GlobalConfigurationExtensions.UseRecommendedSerializerSettings(IGlobalConfiguration configuration, Action`1 settingsConfiguration)
at Hangfire.GlobalConfigurationExtensions.UseRecommendedSerializerSettings(IGlobalConfiguration configuration)
at [redacted]
at Hangfire.HangfireServiceCollectionExtensions.<>c__DisplayClass0_0.<AddHangfire>b__0(IServiceProvider provider, IGlobalConfiguration config)
at Hangfire.HangfireServiceCollectionExtensions.<>c__DisplayClass1_0.<AddHangfire>b__14(IServiceProvider serviceProvider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
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.GetService[T](IServiceProvider provider)
at Hangfire.HangfireServiceCollectionExtensions.ThrowIfNotConfigured(IServiceProvider serviceProvider)
at Hangfire.HangfireApplicationBuilderExtensions.UseHangfireDashboard(IApplicationBuilder app, String pathMatch, DashboardOptions options, JobStorage storage)
at [redacted]
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels