Compatibility with Blazor
PostSharp supports Blazor as a runtime platform only via .NET Standard. You can use PostSharp in your .NET Standard libraries and then reference these libraries in your Blazor application project. Adding PostSharp directly to a Blazor application project is not supported.
For a complete list of PostSharp packages that support Blazor please refer to Requirements and Compatibility.
By default all Blazor applications use a linker in the Release build configuration. The purpose of the linker is to discard unused code and reduce the size of the application. Linking is based on static analysis and it cannot correctly detect all the code used by PostSharp. To prevent the linker from removing the required code you need a custom linker configuration in your project.
To add a custom linker configuration to your Blazor application project, add a new XML file to the project and specify the file as an MSBuild item in the project file:
<ItemGroup> <BlazorLinkerDescriptor Include="LinkerConfig.xml" /> </ItemGroup>
Then copy the following content to the new XML configuration file:
<linker> <assembly fullname="netstandard"> <type fullname="*"> </type> </assembly> </linker>
For more detailed information about the linker configuration please refer to the Blazor documentation: Configure the Linker for ASP.NET Core Blazor.