Application fails to start when setting custom ApplicationName
@captainsafia , @gfoidl , please have a closer look at the problem @Toudahl is complaining.
Here is the problematic part in
Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions
The fact that the value is set by default to the entry-point assembly name, doesn't allow to treat the
ApplicationNameas assembly name and try loading it !!!This is breaking change that is not even documented.
Also, even though the
managerinstance could be provided viaDI, thePopulateDefaultPartsmethod is internal !!! and not marked asoverride- I hardly understand the reason behind letting user to injects their own implementation if he can't provide his own implementation ofPopulateDefaultPartsmethod.Please reopen and provide estimations for the fix. Thanks
Originally posted by @jvmlet in #53791
It's not a breaking change, it's been that way for years. Don't set the application name because it is used as an assembly name. Use another configuration entry.
It's not a breaking change, it's been that way for years. Don't set the application name because it is used as an assembly name. Use another configuration entry.
It's been so long, so I found a different way to set an application name.
But is there an official correct way that I might have overlooked?
Thanks for the quick response, @davidfowl , but with dotnet 6 things are working as expected.
Also, using the standard application name entry has advantage of being picked up by other libraries, like OTEL when publishing logs, metrics and actions. Using another entry will break this.
Don't set the application name because it is used as an assembly name.
This is not true, have a look at documentation comments.
The fact that the value is set by default to the entry-point assembly name, doesn't allow to treat the ApplicationName as assembly name and try loading it !!!
https://github.com/dotnet/aspnetcore/issues/7315
@davidfowl , have you read the issue ?
I'm setting custom ApplicationName with below code which works with dontnet 6 but fails with 8 because dotnet8 treats ApplicationName value as assembly name and tries to load it (MyCustomApplicationName):
.ConfigureAppConfiguration((ctx, b) => {
ctx.HostingEnvironment.ApplicationName = "MyCustomApplicationName";
})
It's been so long, so I found a different way to set an application name.
What solution have you gone for?
It's been so long, so I found a different way to set an application name.
What solution have you gone for?
I simply set it after creating the builder. So far it seems it didn't break anything.
var builder = WebApplication.CreateBuilder(args); builder.Environment.ApplicationName = "awesome-app";
It's been so long, so I found a different way to set an application name.
What solution have you gone for?
I simply set it after creating the builder. So far it seems it didn't break anything.
var builder = WebApplication.CreateBuilder(args); builder.Environment.ApplicationName = "awesome-app";
I think it won't work for me, later I use AddControllers() which eventually gets to the problematic part mentionned at the beginning of this post. Thank you for your answer however, much appreciated :)