[WebToolsE2E][ARM64]Failed to run .exe file with error "System.AccessViolationException: Attempted to read or write protected memory" from publish folder after publishing .NET 8.0 project against self-contained with single file #54899
Open command prompt->Create a folder named as "Web01" with command mkdir Web01
Navigate Web01 folder ->Create ASP.NET Core Web App(Razor Pages) with command dotnet new razor -f net8.0
Run the project with command dotnet build
Publish to folder against self-contained with single file with command dotnet publish -c Release -r win-arm64 --self-contained true -p:PublishSingleFile=true
Double click the .exe file from publish path "...\Web01\bin\Release\net8.0\win-arm64\publish\" when finish running publish command.
Note:
The issue also reproduce from VS with UI.
The issue only reproduce on NET 8.0, cannot reproduce on Net6.0/7.0
The issue also reproduce on February servicing SDK 8.0 and April Servicing 8.0, so it is not a regression issue.
The issue only reproduce on Net 8.0 publish to folder against self-contained with single file, cannot reproduce publish to folder against self-contained.
This issue cannot reproduce on x64 machines, only reproduce on arm64 machines.
ACTUAL
Failed to run .exe file as following
Error messages:
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Microsoft.AspNetCore.Mvc.ApplicationModels.AuthorizationApplicationModelProvider.OnProvidersExecuting(Microsoft.AspNetCore.Mvc.ApplicationModels.ApplicationModelProviderContext)
at Microsoft.AspNetCore.Mvc.ApplicationModels.ApplicationModelFactory.CreateApplicationModel(System.Collections.Generic.IEnumerable1<System.Reflection.TypeInfo>) at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.GetDescriptors() at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.OnProvidersExecuting(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptorProviderContext) at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.UpdateCollection() at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.Initialize() at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.GetChangeToken() at Microsoft.Extensions.Primitives.ChangeToken+ChangeTokenRegistration1[[System.Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]..ctor(System.Func1<Microsoft.Extensions.Primitives.IChangeToken>, System.Action1<System.Canon>, System.__Canon)
at Microsoft.Extensions.Primitives.ChangeToken.OnChange(System.Func`1, System.Action)
at Microsoft.AspNetCore.Mvc.Routing.ActionEndpointDataSourceBase.Subscribe()
at Microsoft.AspNetCore.Builder.RazorPagesEndpointRouteBuilderExtensions.GetOrCreateDataSource(Microsoft.AspNetCore.Routing.IEndpointRouteBuilder)
at Microsoft.AspNetCore.Builder.RazorPagesEndpointRouteBuilderExtensions.MapRazorPages(Microsoft.AspNetCore.Routing.IEndpointRouteBuilder)
at Program.$(System.String[])
Is there an existing issue for this?
Describe the bug
Azure DevOps work item: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2014650
Testcases Affected This issue was found via Exploratory Testing, no test case was affected.
Platform
INSTALL STEPS
Repro Steps
mkdir Web01
dotnet new razor -f net8.0
dotnet build
dotnet publish -c Release -r win-arm64 --self-contained true -p:PublishSingleFile=true
ACTUAL Failed to run .exe file as following
Error messages: Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at Microsoft.AspNetCore.Mvc.ApplicationModels.AuthorizationApplicationModelProvider.OnProvidersExecuting(Microsoft.AspNetCore.Mvc.ApplicationModels.ApplicationModelProviderContext) at Microsoft.AspNetCore.Mvc.ApplicationModels.ApplicationModelFactory.CreateApplicationModel(System.Collections.Generic.IEnumerable, System.Action)
at Microsoft.AspNetCore.Mvc.Routing.ActionEndpointDataSourceBase.Subscribe()
at Microsoft.AspNetCore.Builder.RazorPagesEndpointRouteBuilderExtensions.GetOrCreateDataSource(Microsoft.AspNetCore.Routing.IEndpointRouteBuilder)
at Microsoft.AspNetCore.Builder.RazorPagesEndpointRouteBuilderExtensions.MapRazorPages(Microsoft.AspNetCore.Routing.IEndpointRouteBuilder)
at Program.$(System.String[])
1<System.Reflection.TypeInfo>) at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.GetDescriptors() at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.OnProvidersExecuting(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptorProviderContext) at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.UpdateCollection() at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.Initialize() at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.GetChangeToken() at Microsoft.Extensions.Primitives.ChangeToken+ChangeTokenRegistration
1[[System.Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]..ctor(System.Func1<Microsoft.Extensions.Primitives.IChangeToken>, System.Action
1<System.Canon>, System.__Canon) at Microsoft.Extensions.Primitives.ChangeToken.OnChange(System.Func`1EXPECTED .exe file should run successfully.
Expected Behavior
No response
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
No response
Anything else?
No response