PostSharp 2023.0 / / Post­Sharp Documentation / Deployment and Configuration / Deployment / Requirements and Compatibility / Compatibility with Blazor

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.

Custom Linker Configuration

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:

  <BlazorLinkerDescriptor Include="LinkerConfig.xml" />

Then copy the following content to the new XML configuration file:

  <assembly fullname="netstandard">
    <type fullname="*">

For more detailed information about the linker configuration please refer to the Blazor documentation: Configure the Linker for ASP.NET Core Blazor.

See Also