| Severity | Fatal |
| Reported by | PostSharp |
| Message | Cannot read the binding redirection of the assembly "<Assembly>" in the host configuration file: <Reason> |
Cause
PostSharp executes the assemblies of your project at build time, so it must follow the same assembly binding redirections as your application, as Resolution of Assembly Binding Redirections describes. For a project that targets .NET Framework, the build merges the dependentAssembly elements of the binding redirections generated from your project (the postsharp.app.config file in the PostSharp subfolder of the intermediate output folder, for example obj\Debug\net48\PostSharp) and of the files of the PostSharpHostConfigurationFile property into the configuration file of the PostSharp process. PostSharp then reads each dependentAssembly element of this file.
PostSharp reports PS0096, and stops, when it cannot read one of these elements. <Assembly> is the name attribute of the assemblyIdentity element, and <Reason> is the error, for example:
- The
oldVersionornewVersionattribute of thebindingRedirectelement is not a version number such as1.0.0.0, for example2.*or a version with more than four parts. - The
oldVersionattribute contains more than one-: it must be a version or a range of two versions, such as0.0.0.0-4.2.0.0. In this case,<Reason>is the text of an internal assertion. - The
processorArchitectureattribute of theassemblyIdentityelement is not a processor architecture, such asmsil,x86oramd64.
Projects that target .NET Core, .NET 5 and later, or .NET Standard do not use this configuration. This message depends on the configuration files of a .NET Framework project, so no example can show it.
Resolution
Find the
dependentAssemblyelement of<Assembly>in theapp.configorweb.configfile of the project, or in the file that thePostSharpHostConfigurationFileproperty names. Thepostsharp.app.configandpostsharp.merged.app.configfiles of thePostSharpsubfolder of the intermediate output folder show the configuration that PostSharp actually reads.Correct the
oldVersion,newVersionorprocessorArchitectureattribute, for example:<dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" /> </dependentAssembly>Rebuild the project. When the element is generated by NuGet or by the automatic binding redirections of MSBuild, delete the
objfolder first, so that the generated files are created again.
See Also
Other Resources
Resolution of Assembly Binding Redirections
Well-Known MSBuild Properties