Aspnetcore: [Announcement] Known issue in 3.0.2 and 3.1.1 for ASP.NET Core

Created on 14 Jan 2020  路  33Comments  路  Source: dotnet/aspnetcore

Packages and Shared Framework

Scenario

If your project has a package reference that transtively references certain assemblies in the Microsoft.AspNetCore.App shared framework
that are also available as NuGet packages and executes on a runtime other than 64-bit Windows, you will receive a runtime exception at the time the assembly is loaded with a message like:

Could not load file or assembly 'Microsoft.AspNetCore.DataProtection.Abstractions, Version=3.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)

Workaround

Reference the package for the assembly which is failing to load explicitly in your application.

List of assemblies impacted:

  • Microsoft.AspNetCore.DataProtection.Abstractions
  • Microsoft.AspNetCore.Cryptography.Internal
  • Microsoft.AspNetCore.Cryptography.KeyDerivation
  • Microsoft.AspNetCore.Metadata

Identity UI

Scenario

Alternatively, if you use the Microsoft.AspNetCore.Identity.UI package and executes on a runtime other than 64-bit Windows, you will receive a runtime exception at the time the Microsoft.AspNetCore.Http.Features assembly is loaded with a message like:

FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.Http.Features, Version=3.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

Workaround

Reference the Microsoft.AspNetCore.Http.Features package explicitly in your application.

Azure App Service

Note that by default Azure App Service runs websites in an x86 Windows environment, so you might see these issues when you deploy to
Azure App Service, even if your app works locally on your 64-bit Windows development machine. To workaround, you can either apply one of
the workarounds above or configure your app to run in a 64-bit environment. See the documentation for details.

See also

https://github.com/aspnet/Announcements/issues/398 which is still present in these releases.

area-platform

Most helpful comment

Could not load file or assembly 'Microsoft.AspNetCore.Razor.Runtime, Version=3.1.1.0
馃槩

Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.Razor.Runtime, Version=3.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.AspNetCore.Razor.Runtime, Version=3.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
   at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(MetadataToken caCtorToken, MetadataImport& scope, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1& derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
   at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder`1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1 derivedAttributes)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
   at System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit)
   at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
   at System.Attribute.GetCustomAttribute(Assembly element, Type attributeType, Boolean inherit)
   at System.Reflection.CustomAttributeExtensions.GetCustomAttribute[T](Assembly element)
   at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartFactory.GetApplicationPartFactory(Assembly assembly)
   at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateDefaultParts(String entryAssemblyName)
   at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.GetApplicationPartManager(IServiceCollection services)
   at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.AddMvcCore(IServiceCollection services)
   at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddControllersCore(IServiceCollection services)
   at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddControllersWithViewsCore(IServiceCollection services)
   at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddControllersWithViews(IServiceCollection services)
   at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddMvc(IServiceCollection services)
   at Microsoft.AspNetCore.Identity.IdentityBuilderUIExtensions.AddRelatedParts(IdentityBuilder builder)
   at Microsoft.AspNetCore.Identity.IdentityBuilderUIExtensions.AddDefaultUI(IdentityBuilder builder)
   at Microsoft.Extensions.DependencyInjection.IdentityServiceCollectionUIExtensions.AddDefaultIdentity[TUser](IServiceCollection services, Action`1 configureOptions)

Workaround doesn't work as adding

<PackageReference Include="Microsoft.AspNetCore.Razor.Runtime" Version="3.1.1" />

Gives the following build error

 Unable to find package Microsoft.AspNetCore.Razor.Runtime with version (>= 3.1.1)
  error NU1102:   - Found 27 version(s) in nuget.org [ Nearest version: 2.2.0 ]
  error NU1102:   - Found 0 version(s) in Microsoft Visual Studio Offline Packages

All 33 comments

Oops, meant to lock the issue in aspnet/Announcements, not here.

Could not load file or assembly 'Microsoft.AspNetCore.Razor.Runtime, Version=3.1.1.0
馃槩

Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.Razor.Runtime, Version=3.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.AspNetCore.Razor.Runtime, Version=3.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
   at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(MetadataToken caCtorToken, MetadataImport& scope, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1& derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
   at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder`1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1 derivedAttributes)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
   at System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit)
   at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
   at System.Attribute.GetCustomAttribute(Assembly element, Type attributeType, Boolean inherit)
   at System.Reflection.CustomAttributeExtensions.GetCustomAttribute[T](Assembly element)
   at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartFactory.GetApplicationPartFactory(Assembly assembly)
   at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateDefaultParts(String entryAssemblyName)
   at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.GetApplicationPartManager(IServiceCollection services)
   at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.AddMvcCore(IServiceCollection services)
   at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddControllersCore(IServiceCollection services)
   at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddControllersWithViewsCore(IServiceCollection services)
   at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddControllersWithViews(IServiceCollection services)
   at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddMvc(IServiceCollection services)
   at Microsoft.AspNetCore.Identity.IdentityBuilderUIExtensions.AddRelatedParts(IdentityBuilder builder)
   at Microsoft.AspNetCore.Identity.IdentityBuilderUIExtensions.AddDefaultUI(IdentityBuilder builder)
   at Microsoft.Extensions.DependencyInjection.IdentityServiceCollectionUIExtensions.AddDefaultIdentity[TUser](IServiceCollection services, Action`1 configureOptions)

Workaround doesn't work as adding

<PackageReference Include="Microsoft.AspNetCore.Razor.Runtime" Version="3.1.1" />

Gives the following build error

 Unable to find package Microsoft.AspNetCore.Razor.Runtime with version (>= 3.1.1)
  error NU1102:   - Found 27 version(s) in nuget.org [ Nearest version: 2.2.0 ]
  error NU1102:   - Found 0 version(s) in Microsoft Visual Studio Offline Packages

Experiencing the same issue as @benaadams above. Nuget indicates that there isn't a 3.1.1.1 version of Microsoft.AspNetCore.Razor.Runtime, but that's the error I see in my own exception.

'Could not load file or assembly 'Microsoft.AspNetCore.Razor.Runtime, Version=3.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.'
   at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(MetadataToken caCtorToken, MetadataImport& scope, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1& derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
   at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder`1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1 derivedAttributes)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
   at System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit)
   at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
   at System.Attribute.GetCustomAttribute(Assembly element, Type attributeType, Boolean inherit)
   at System.Reflection.CustomAttributeExtensions.GetCustomAttribute[T](Assembly element)
   at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartFactory.GetApplicationPartFactory(Assembly assembly)
   at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateDefaultParts(String entryAssemblyName)
   at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.GetApplicationPartManager(IServiceCollection services)
   at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.AddMvcCore(IServiceCollection services)
   at MyApi.Startup.ConfigureServices(IServiceCollection services) in ...\MyApi\Startup.cs:line 61
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.<Invoke>g__Startup|0(IServiceCollection serviceCollection)
   at Microsoft.AspNetCore.Hosting.StartupLoader.ConfigureServicesDelegateBuilder`1.<>c__DisplayClass15_0.<BuildStartupServicesFilterPipeline>g__RunPipeline|0(IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.<Build>b__0(IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.StartupLoader.ConfigureServicesDelegateBuilder`1.<>c__DisplayClass14_0.<ConfigureServices>g__ConfigureServicesWithContainerConfiguration|0(IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)

This is breaking on a line during local debug within ConfigureServices with the following:

services.AddMvcCore().AddApiExplorer();

Per a related issue, I did indeed update Microsoft.AspNetCore.Authentication.AzureAD.UI to 3.1.1 when experiencing this issue. As they were mentioned in the other issue, we're running x64 here and we do not use Microsoft.AspNetCore.Identity.UI.

Same here. Just upgraded my app from 2.1 to 3.1 and getting this error.

@wtgodbe @JunTaoLuo it looks like we may have missed a case here. Can one of you take a look and see if there is a workaround here?

The issue may affect all of the *.UI packages so we'll need to update the announcement. As for the errors, I'm surprised it's missing M.A.Razor.Runtime since it is included in the 3.1.1 runtime. I'll try reproducing the issue and report back.

We are getting the same error after upgrading our app from 2.2 to 3.1:

Could not load file or assembly 'Microsoft.AspNetCore.Razor.Runtime, Version=3.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

We solved it locally by removing [Authenticate] attribute from our controllers. But Azure App Service instance (Windows, east2) is still giving this error.

I downgraded the version of Microsoft.AspNetCore.Authentication.AzureAD.UI from 3.1.1 to 3.1.0 and it is working now.

A similar issue is described here https://github.com/dotnet/aspnetcore/issues/18401#issue-551188057

@benaadams @iSeiryu did you install the latest 3.1.1 shared framework when you updated your *.UI packages to 3.1.1?

@JunTaoLuo No issues among my solution when I downgraded to 3.1.0, only an issue in 3.1.1.

@WhitWaldo does this repro if you upgrade both the AspNetCore runtime & Microsoft.AspNetCore.Authentication.AzureAD.UI to 3.1.1? Or only if you upgrade Microsoft.AspNetCore.Authentication.AzureAD.UI?

@Pilchie I believe we need to update this issue to state that you must update your AspNetCore runtime if you want to update your dependency on any of the affected packages, as otherwise there won't be an assembly available with the 3.1.1.0 version

@wtgodbe I had upgraded all AspNetCore packages to 3.1.1 (commented on this issue last night following this upgrade) and this morning downgraded them all to 3.1.0 (worked fine after the collective downgrade). I haven't tried just upgrading or downgrading the one package (M.A. A.AzureAD.UI).

@JunTaoLuo issue might be secondary transitive dependencies; so this is coming from a (local) library I include that has a FrameworkReference reference e.g.

<ItemGroup>
  <FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

And it uses the attribute [Microsoft.AspNetCore.Mvc.ModelBinding.BindNever]

At a guess this would be similar issue with Microsoft.AspNetCore.Authentication.AzureAD.UI as it would have its own reference; which would then have its reference etc

@WhitWaldo I believe you also need to download the 3.1.1 AspNetCore runtime, which you can do from here. The affected 3.1.1 packages won't work with the 3.1.0 runtime.

We had a lot of problems with this issue:

  • we involved MS support to help us to fix an issue related to an Azure App Service instance;
  • MS support guys told us they cannot do much about 2.2 and that we had to upgrade to 3.1;
  • we upgraded all of our projects in our solution from dotnet core 2.2 to 3.1;
  • we made it work locally (clean repo clone and system nuget packages wipe still work fine, no issues were found);
  • we deployed it to our existing App Service instance (Windows based);
  • it crashed instantly with a standard "HTTP Error 500.30 - ANCM In-Process Start Failure";
  • no logs indicated what the issue was;
  • we enabled stdout logs and finally it output that "Microsoft.AspNetCore.Razor.Runtime, Version=3.1.1.0" error (which was a big problem because it took a while to figure out how to turn it on as no one had permissions to enable it, including MS guys).

We've had this issue for a week until we finally found this page with a possible fix of downgrading AzureAD.UI package today. People were threatened to be fired over it (this is a HUGE project).
We don't have any control of which versions of dotnet core are available in our App Service instances. MS support said 3.1 was deployed to all of our Azure data centers.

D:\home>dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   2.2.109
 Commit:    586f23c400

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x86
 Base Path:   D:\Program Files (x86)\dotnet\sdk\2.2.109\

Host (useful for support):
  Version: 3.1.0
  Commit:  65f04fb6db

.NET Core SDKs installed:
  1.1.14 [D:\Program Files (x86)\dotnet\sdk]
  2.1.509 [D:\Program Files (x86)\dotnet\sdk]
  2.2.109 [D:\Program Files (x86)\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.13 [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.14 [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.7 [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.8 [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.13 [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.14 [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.7 [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.8 [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0 [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.1 [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.0 [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.16 [D:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.13 [D:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.9 [D:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.14 [D:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.8 [D:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.1 [D:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.0 [D:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]

To me it wasn't very clear that installing 3.1.1 packages from nuget requires having a 3.1.1 runtime installed, which is currently not available on azure app services and pipeline runners. Projects do compile on runners with 3.1.0 without a problem (as SCD and FDD), but they can not be run afterwards. It seems like this wasn't clear to others around here too so possibly it might be worth considering to state this clearer in the docs/announcement.

Additionally I think it would be great to provide docs for the workaround solutions to get this working in app services immediately with an example, i.e. like this:

To get your app running on Azure App Services, regardless of the runtimes that are available there, you can use a pipeline configuration like the following one. Please note that this has considerable drawbacks too. Most notably, you must take care of updating the runtime manually afterwards and you can't profit from all of the managed aspects of the service, that is patched automatically otherwise.

pool:
  vmImage: 'windows-latest'

variables:
  BuildConfiguration: 'Release'

steps:
# install newest available .net core sdk on pipeline runner
# it needs to be available on the runner to be made a part
# of a self contained deployment
- task: UseDotNet@2
  inputs:
    packageType: 'sdk'
    version: '3.x'

- task: NuGetToolInstaller@1

# built as SCD that includes it's required framework files
# this can always be deployed to i.e. azure app services,
# no matter which versions of runtimes are installed there
- task: DotNetCoreCLI@2
  inputs:
    command: 'publish'
    publishWebProjects: true
    projects: 'YourProject/YourProject.csproj'
    arguments: '-c $(BuildConfiguration) -r win10-x86 --self-contained true --output $(Build.ArtifactStagingDirectory)'

- task: PublishPipelineArtifact@1
  inputs:
    targetPath: '$(Build.ArtifactStagingDirectory)'
    artifact: 'drop'

@wtgodbe yes looks like its issue installed runtime being 3.1.0 and not 3.1.1

Can this dependency issue be trapped and indicated earlier in some manner?

e.g. why is NuGet allowing me to install libraries that will be incompatible. Is it because its depending on .NETCoreApp 3.1 and this is a break in minor version e.g. .NETCoreApp 3.1.1 which isn't a version of runtime tfm?

Or perhaps the frameworkreference in libraries needs to accept versions rather than being unversioned so it can be detected at compile time?

<FrameworkReference Include="Microsoft.AspNetCore.App" />

e.g. it should be

<FrameworkReference Include="Microsoft.AspNetCore.App" version="3.1.0" />

Which could then error saying it needs to be 3.1.1?

<FrameworkReference Include="Microsoft.AspNetCore.App" version="3.1.1" />

Removing Microsoft.AspNetCore.Identity.UI from the project solves the issue for me.

However, with 3.1.1 installed after upgrading packages .AddRazorRuntimeCompilation() now breaks (useful for dev inner loop); when you change a page:

System.TypeLoadException: Method 'CommonGetWellKnownType'
 in type 'Microsoft.CodeAnalysis.CSharp.CSharpCompilation'
 from assembly 'Microsoft.CodeAnalysis.CSharp, Version=3.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
 does not have an implementation.
   at Microsoft.CodeAnalysis.Razor.CompilationTagHelperFeature.GetDescriptors()
   at Microsoft.AspNetCore.Razor.Language.DefaultRazorTagHelperBinderPhase.ExecuteCore(RazorCodeDocument codeDocument)
   at Microsoft.AspNetCore.Razor.Language.RazorEnginePhaseBase.Execute(RazorCodeDocument codeDocument)
   at Microsoft.AspNetCore.Razor.Language.DefaultRazorEngine.Process(RazorCodeDocument document)
   at Microsoft.AspNetCore.Razor.Language.DefaultRazorProjectEngine.ProcessCore(RazorCodeDocument codeDocument)
   at Microsoft.AspNetCore.Razor.Language.RazorProjectEngine.Process(RazorProjectItem projectItem)
   at Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.RuntimeViewCompiler.CompileAndEmit(String relativePath)
   at Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.RuntimeViewCompiler.OnCacheMiss(String normalizedPath)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.DefaultPageLoader.LoadAsyncCore(PageActionDescriptor actionDescriptor)
   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageLoaderMatcherPolicy.ApplyAsyncAwaited(CandidateSet candidates, Task`1 actionDescriptorTask, Int32 index)
   at Microsoft.AspNetCore.Routing.Matching.DfaMatcher.SelectEndpointWithPoliciesAsync(HttpContext httpContext, IEndpointSelectorPolicy[] policies, CandidateSet candidateSet)
   at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.<Invoke>g__AwaitMatch|8_1(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task matchTask)

Which needs the following in the .csproj to resolve

<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="3.4.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.1" />

Can this dependency issue be trapped and indicated earlier in some manner?

e.g. why is NuGet allowing me to install libraries that will be incompatible. Is it because its depending on .NETCoreApp 3.1 and this is a break in minor version e.g. .NETCoreApp 3.1.1 which isn't a version of runtime tfm?

This is because we made a mistake in building some of these binaries, so they accidentally have a dependency on binaries in 3.1.1. We've addressed that for the upcoming 3.1.2. Instead of inventing features for NuGet or FrameworkReferences, let's just fix the bug so that things work as intended :wink:

However, with 3.1.1 installed after upgrading packages .AddRazorRuntimeCompilation() now breaks

馃槩. Thanks for letting us know. I'll work on updating the announcement today with some more scenarios.

Just switching azure app service to x64 did NOT resolve the problem for me FYI

reverding ad UI to 3.1.0 resolved it

To me it wasn't very clear that installing 3.1.1 packages from nuget requires having a 3.1.1 runtime installed

This normally wouldn't be the case, but the bug described by this issue has caused certain 3.1.1 packages to be incompatible with the 3.1.0 runtime, and vice versa. We have a fix for the issue that will ship with 3.1.2 in February

Just switching azure app service to x64 did NOT resolve the problem for me FYI

reverding ad UI to 3.1.0 resolved it

did not work for me. I was using Azure App Service on Linux with .NET Core 3.1 Runtime.
My error was related to the Razor version, thus the Linux container could not start
In order to make it work I had to update the Runtime in Configuration/General Settings to LTS (Long term support)
Locally I was using version 3.1.101

Edit: Seems that the container was still using version 3.0.0. Ended up SSH-ing in and manually installing runtime 3.1.1

Edit2: obviously it did not work, since the container was restarted 馃憥

Yes builder.AddAzureAD(options => configuration.Bind(name, options)); did this thing for me at exactly the ResolveTypeHandleInternal call commented above, running locally on x64 just after upgrading to VS 16.5.0 Preview 2.0. Both these solutions worked for me:

  • downgrading Microsoft.AspNetCore.Authentication.AzureAD.UI to 3.1.0 and
  • using Microsoft.AspNetCore.Authentication.AzureAD.UI 3.1.1 but upgrading to SDK 3.1.101.

First time in a while that I have visited dot.net to get an SDK for my dev box.

Even with SDK 3.1.101 I had to move back to 3.1.0 for AzureAD.UI package. Just an FYI.

There are two issues:

  1. You need to have the 3.1.1 runtime to use any 3.1.1 packages.
  2. For some packages, a dependency may fail to load. You can work around this by adding an explicit package reference to the 3.1.1 version of the package. For AzureAD.UI this is usually at least Microsoft.AspNetCore.DataProtection.Abstractions.

To me it wasn't very clear that installing 3.1.1 packages from nuget requires having a 3.1.1 runtime installed

This normally wouldn't be the case, but the bug described by this issue has caused certain 3.1.1 packages to be incompatible with the 3.1.0 runtime, and vice versa. We have a fix for the issue that will ship with 3.1.2 in February

Can y鈥檃ll prioritize getting 3.1.2 on Azure App Service please? We鈥檙e still waiting for 3.1.1 global rollout and SDK

please prioritize

Same issue on creating a new web app from template using visual studio 2019 version 16.4 :
" Could not load file or assembly 'Microsoft.AspNetCore.Razor.Runtime, Version=3.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified. "
solution is to use Version="3.1.0" as the following :
"Microsoft.AspNetCore.Http.Features" Version="3.1.0"
"Microsoft.AspNetCore.Identity" Version="2.2.0"
"Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.0"
"Microsoft.AspNetCore.Identity.UI" Version="3.1.0"
"Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.0"
"Microsoft.EntityFrameworkCore.Tools" Version="3.1.0">
"Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.0"

<RuntimeFrameworkVersion>3.1.1</RuntimeFrameworkVersion> fixed it for me.

This should be fixed in the 3.1.2 release that was published today (2020-02-18). Please file a new issue on https://github.com/dotnet/aspnetcore if you are still seeing issues.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ipinak picture ipinak  路  3Comments

rbanks54 picture rbanks54  路  3Comments

TanvirArjel picture TanvirArjel  路  3Comments

UweKeim picture UweKeim  路  3Comments

aurokk picture aurokk  路  3Comments