| Severity | Error |
| Reported by | PostSharp |
| Message | Cannot find the plug-in assembly or configuration file "<FileName>". |
Cause
A Using element of a configuration file, such as postsharp.config, imports another configuration file or a plug-in into the project. See Configuration File Schema Reference. PostSharp reports PS0010, and stops building the project, when it cannot find the file that the File attribute names:
- When the name has no path, PostSharp searches the file in the directories of its search path, which include the plug-in directories, the directories of the references of the project, and the directories of the
SearchPathelements and of thePostSharpSearchPathMSBuild property.<FileName>is the name as theFileattribute gives it. - When the name has a relative or an absolute path, PostSharp looks only at this path, relative to the directory of the configuration file, and
<FileName>is the full path that it tried.
PostSharp also reports PS0010 when a plug-in or a configuration file that the build passes to PostSharp does not exist.
In the following example, postsharp.config imports LoggingProfile.config, but the file in its directory is LoggingProfiles.config.
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.postsharp.org/1.0/configuration">
<!-- The file name is misspelled: the file is LoggingProfiles.config. -->
<Using File="LoggingProfile.config" />
</Project>
using System;
using PostSharp.Aspects;
using PostSharp.Serialization;
namespace Errors.PS0010_Error;
[PSerializable]
public class LogAttribute : OnMethodBoundaryAspect
{
public override void OnEntry( MethodExecutionArgs args )
{
Console.WriteLine( $"Entering {args.Method.Name}." );
}
}
public class OrderService
{
[Log]
public void PlaceOrder( string product )
{
Console.WriteLine( $"Order placed for {product}." );
}
}
public static class Program
{
public static void Main()
{
new OrderService().PlaceOrder( "Coffee" );
}
}
error PS0010: postsharp.config(4,4): Cannot find the plug-in assembly or configuration file "LoggingProfile.config".
Resolution
- Check the spelling of the file name, and that the file is where the full path in the message says.
- To import a configuration file of your source tree, give its path relative to the configuration file that contains the
Usingelement, for example.\LoggingProfiles.configor..\Shared\LoggingProfiles.config, so that PostSharp does not depend on the search path to find it. - To import a plug-in by its name, add its directory to the search path with a
SearchPathelement or with thePostSharpSearchPathMSBuild property. See Well-Known MSBuild Properties. - When the file was removed on purpose, remove the
Usingelement, or give it aCondition.
In the following example, the Using element gives the correct name of the file, with a path relative to postsharp.config, and the project builds.
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.postsharp.org/1.0/configuration">
<!-- The file name is correct, and the path is relative to the directory of this file. -->
<Using File=".\LoggingProfiles.config" />
</Project>
using System;
using PostSharp.Aspects;
using PostSharp.Serialization;
namespace Errors.PS0010_Fixed;
[PSerializable]
public class LogAttribute : OnMethodBoundaryAspect
{
public override void OnEntry( MethodExecutionArgs args )
{
Console.WriteLine( $"Entering {args.Method.Name}." );
}
}
public class OrderService
{
[Log]
public void PlaceOrder( string product )
{
Console.WriteLine( $"Order placed for {product}." );
}
}
public static class Program
{
public static void Main()
{
new OrderService().PlaceOrder( "Coffee" );
}
}
Entering PlaceOrder.
Order placed for Coffee.
See Also
Other Resources
Configuring Projects Using postsharp.config
Configuration File Schema Reference
Well-Known MSBuild Properties