| Severity | Error |
| Reported by | PostSharp |
| Message | Task "<TaskName>": cannot instantiate the implementation type: <Exception> |
Cause
PostSharp builds a project by running tasks, which plug-ins add. For each task that the project needs, PostSharp creates an instance of the class that implements it: with the factory that the plug-in registers, or, for a TaskType element of an XML configuration file, with the public parameterless constructor of the type that its Implementation attribute names.
PostSharp reports PS0014, and stops building the project, when creating this instance throws an exception, for example:
- The constructor of the task, or the factory of the plug-in, throws an exception, often because the plug-in cannot load one of its dependencies.
- The implementation type is abstract, or has no public parameterless constructor.
<TaskName> is the name of the task. <Exception> is the exception, with its type, its message and its stack trace.
This message depends on a plug-in of PostSharp, which the samples of this documentation cannot build, so no example can show it.
Resolution
- Read the exception in the message. When it is a
FileNotFoundExceptionor aFileLoadException, a dependency of the plug-in is missing or has the wrong version: restore the packages, and check that every PostSharp package of the project has the same version. - When the plug-in comes from a third party, report the exception to its author, with the version of PostSharp.
- When you develop the plug-in, make the implementation type a public, non-abstract class with a public parameterless constructor, and debug its constructor. To attach a debugger to PostSharp when it starts, build with the
PostSharpAttachDebuggerMSBuild property set toTrue, as Debugging Build-Time Logic describes.
See Also
Other Resources