Open sandboxFocusImprove this doc

PS0095: Host Configuration File Is Not Valid XML

Severity Error
Reported by PostSharp
Message Cannot read the assembly binding redirections of the configuration file: <Error>

Cause

When a project targets .NET Framework, PostSharp loads the assemblies of the project with the assembly binding redirections of the project. It reads them from the configuration file of its host process, which the build prepares from the following files:

  • the configuration file of the PostSharp compiler, in the PostSharp package;
  • the file that PostSharp generates from the app.config file of the project and from the binding redirections that MSBuild suggests, postsharp.app.config under the PostSharp folder of the intermediate output directory;
  • the files that the project adds to the PostSharpHostConfigurationFile item group, for example Web.config.

PostSharp reports PS0095 when the resulting configuration file, the configuration file of the compiler or postsharp.merged.app.config in the intermediate output directory, is not well-formed XML. <Error> is the reason given by the XML parser, and the location of the message is the file, with the line and the column of the problem. When the file is well-formed but has no /configuration/runtime/assemblyBinding element, PostSharp reports PS0097 instead.

This message depends on the configuration files of the build and of the PostSharp installation, which a test cannot corrupt, and on a .NET Framework project, so no example can show it.

Resolution

  1. Open the file named in the location of the message, at the line and the column it gives.
  2. When it is a file of your project, such as app.config or Web.config, correct the XML: a missing closing tag, an unescaped & or < in an attribute value, or a second root element are the usual causes.
  3. When it is a file under the PostSharp folder of the intermediate output directory (obj), delete this folder, or run a clean build, so that PostSharp generates the file again.
  4. When it is the configuration file of the PostSharp compiler in the PostSharp package, the package is corrupted: delete the folder of the postsharp package from the NuGet package cache (%UserProfile%\.nuget\packages\postsharp\<version>) and restore the packages of the solution again.

When you do not need the default binding redirections, you can also set the PostSharpDisableDefaultBindingRedirects MSBuild property to True, as Resolution of Assembly Binding Redirections describes.

See Also

Other Resources

Resolution of Assembly Binding Redirections
Well-Known MSBuild Properties