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

GetApplicationPartManager uses environment variable ApplicationName to get entryAssemblyName is that the expected behavior? If we override ApplicationName, app crashes #47643

Closed
modios opened this issue Apr 11, 2023 · 3 comments
Labels
area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels

Comments

@modios
Copy link

modios commented Apr 11, 2023

Summary

GetApplicationPartManager does var entryAssemblyName = environment?.ApplicationName; and hence
taking the entryAssemblyName from the environment variable ApplicationName.
But the environment variable ApplicationName can be overridden.

For existing application that override the ApplicationName, which indeed by default holds the assembly name, this will cause the app to crash.

Is there another way to set the entryAssemblyName in the code that does not depend on an environment variables?

Motivation and goals

Change the existing logic for setting entryAssemblyName to something that doesn't depend on environment variables.
Hence existing applications that override ApplicationName default value will not crash and new applications will have the
ability to set ApplicationName to something other than the default value if needed.

Examples

Adding for example

.AddApiExplorer(options =>
                 {
                     options.GroupNameFormat = "'v'VVV";
                     options.SubstituteApiVersionInUrl = true;
                 });

in our application will fail in case the ApplicationName has been overridden and doesn't hold the default assembly name.

@modios modios added the design-proposal This issue represents a design proposal for a different issue, linked in the description label Apr 11, 2023
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label Apr 11, 2023
@captainsafia
Copy link
Member

@modios Is there a chance you can provide a complete repro here?

in our application will fail in case the ApplicationName has been overridden and doesn't hold the default assembly name.

Based on the example that you provided here, it appears that you are using the ApiVersioning library?

A stacktrace and repro would be helpful here...

@captainsafia captainsafia added area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels and removed design-proposal This issue represents a design proposal for a different issue, linked in the description needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically labels Apr 11, 2023
@davidfowl
Copy link
Member

Yes it’s by design. The application name on the hosting environment should be a valid assembly name.

@modios
Copy link
Author

modios commented Apr 12, 2023

@captainsafia and @davidfowl thank you very much for your quick response. Helped me a lot to clarify things.
Realized that the issue only arises when running integration tests using WebApplicationFactory and which was able to solve using details from #7315.

yes @captainsafia this appeared when using ApiVersioning. It's a little bit complicated to provide a repo with an example.
I think I can close the issue, so will do.

Thank you again.

@modios modios closed this as completed Apr 12, 2023
@ghost ghost locked as resolved and limited conversation to collaborators May 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
Projects
None yet
Development

No branches or pull requests

3 participants