aspnetcore: View assembly location fails when path contains special characters

I’m not sure this is really a bug in asp.net or not but anyway,

As part of a service fabric deployment i have an app deployed in the following folder C:\SFDevCluster\Data\_App\_Node_0\Fabric.AdminType_App121\Services.AdminPanelPkg.Code.5.29.0.3419f33.lu1b%2B%\ however when the app starts if failes to locate one of the view assemblies because its trying to use the following path C:\SFDevCluster\Data\_App\_Node_0\Fabric.AdminType_App121\Services.AdminPanelPkg.Code.5.29.0.3419f33.lu1b+%

In other words, its unescaping the folder path so that %2B is turned into + causing the lookup to fail.

Additional context

The exception it self:

File name: 'C:\SFDevCluster\Data\_App\_Node_0\Fabric.AdminType_App121\Services.AdminPanelPkg.Code.5.29.0.3419f33.lu1b+%\Microsoft.AspNetCore.Authentication.AzureAD.UI.Views.dll'
   at Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute.GetRelatedAssemblies(Assembly assembly, Boolean throwOnError, Func`2 fileExists, Func`2 loadFile)
   at Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute.GetRelatedAssemblies(Assembly assembly, Boolean throwOnError)
   at Microsoft.AspNetCore.Authentication.AzureADAuthenticationBuilderExtensions.GetAdditionalParts()+MoveNext()
   at Microsoft.AspNetCore.Authentication.AzureADAuthenticationBuilderExtensions.<>c__DisplayClass6_0.<AddAdditionalMvcApplicationParts>b__0(ApplicationPartManager apm)
   at Microsoft.Extensions.DependencyInjection.MvcCoreMvcBuilderExtensions.ConfigureApplicationPartManager(IMvcBuilder builder, Action`1 setupAction)
   at Microsoft.AspNetCore.Authentication.AzureADAuthenticationBuilderExtensions.AddAdditionalMvcApplicationParts(IServiceCollection services)
   at Microsoft.AspNetCore.Authentication.AzureADAuthenticationBuilderExtensions.AddAzureAD(AuthenticationBuilder builder, String scheme, String openIdConnectScheme, String cookieScheme, String displayName, Action`1 configureOptions)

dotnet info:

 Version:   3.0.100
 Commit:    04339c3a26

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18985
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100\

Host (useful for support):
  Version: 3.0.0
  Commit:  7d57652f33

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (12 by maintainers)

Most upvoted comments

Assembly.Location is strictly better than Assembly.CodeBase.

Assembly.CodeBase is obsolete property. The only reason why it was included in .NET Core was .NET Framework compatibility. The original purpose of Assembly.CodeBase was CAS (Code Access Security). It was meant to describe where the assembly was downloaded from for the Internet Zone security checks. It also explains some of its weird behaviors. For example, if the assembly is loaded as byte array, it returns the location of the caller of the Assembly.Load method.

shadow-copied assemblies

Shadow copying does not exist in ,NET Core.