| Severity | Error |
| Reported by | PostSharp |
| Message | Aspect "<AspectType>" implements "<FoundInterface>" instead of "<ExpectedInterface>": the two interfaces come from different assemblies. Check that the project and its references use a single version of PostSharp. |
Cause
At build time, PostSharp creates an instance of each aspect applied to the project and casts it to the IAspect interface of the PostSharp assembly that the compiler loaded. PostSharp reports LA0194 when this cast fails although the aspect implements an interface with the same full name, PostSharp.Aspects.IAspect: the interface that the aspect implements comes from another assembly, typically another version or another copy of PostSharp.dll.
The three placeholders are assembly-qualified names. <AspectType> is the aspect type, <FoundInterface> is the interface that it implements, and <ExpectedInterface> is the interface of the PostSharp assembly of the compiler. Compare the versions and the public key tokens of the last two to find the assembly that does not match.
This message depends on the PostSharp assemblies that the build references and loads, which a test cannot vary, so no example can show it.
Resolution
- Reference a single version of the PostSharp packages in all the projects of the solution, including the projects that define aspects, and rebuild them all. Central package management, with a
Directory.Packages.propsfile, keeps the versions aligned. - Remove direct references to a
PostSharp.dllfile (aReferenceitem with aHintPath) and reference thePostSharppackage instead. - When the aspect comes from a library, check which version of PostSharp the library references.
- Run
dotnet list package --include-transitiveto find the packages that bring another version of PostSharp.
See Also
Reference
Other Resources