Razor Class Library project cannot be referenced by Blazor WASM project: The type or namespace name 'ApplicationPartAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Mvc.ApplicationParts' (are you missing an assembly reference?) #26724
Labels
area-blazor
Includes: Blazor, Razor Components
✔️ Resolution: Answered
Resolved because the question asked by the original author has been answered.
question
Status: Resolved
Describe the bug
I'm trying to migrate the blade project to NET 5.0 RC1, but after adding a reference to the Razor Class Library project to the WASM project, the compiler prompts an error:
obj\Debug\net5.0\XXXX\XXXX.MvcApplicationPartsAssemblyInfo.cs(14,54,14,78): error CS0234: The type or namespace name 'ApplicationPartAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Mvc.ApplicationParts' (are you missing an assembly reference?)
.When change the SDK Microsoft.NET.Sdk.BlazorWebAssembly to Microsoft.NET.Sdk.Web (similar to using NET Core 3.1), I can build the project success, but It's not generate as the Blazor WASM project. Then I found the solution is in issues 24171:
Add <GenerateMvcApplicationPartsAssemblyAttributes>false</GenerateMvcApplicationPartsAssemblyAttributes> to project props.
And It's helpful. The issue has been closed, and I think this may be a bug, please fix it, thanks a lot!
To Reproduce
Exceptions (if any)
Further technical details
dotnet --info
VS 2019 16.8.0 Preview 3.2
The text was updated successfully, but these errors were encountered: