| Severity | Warning |
| Reported by | PostSharp |
| Message | Cannot resolve the source code location of <Declaration>: <Exception> |
Cause
PostSharp works on the compiled assembly, not on the source code. When it reports a message about a declaration, such as a method or a type, it looks for the file and the line of the declaration in the PDB file and in the source files of the project, so that the message points to your code.
PostSharp reports PS0266 when this lookup throws an unexpected exception. <Declaration> is the declaration that the other message is about, and <Exception> is the exception, or its message. PostSharp then reports the other message without a source location, and sends the exception to its telemetry when telemetry is enabled.
The message reveals a bug of PostSharp, so no example can show it.
Resolution
The build is not affected by PS0266 itself: resolve the other message, which names the declaration even without a location.
To help fix the bug, report it to the support of PostSharp with the text of PS0266, which includes the exception, and, if possible, a trace of the MessageLocationResolver category, captured with the PostSharpTrace MSBuild property as Well-Known MSBuild Properties describes. Update PostSharp to the latest version of your release, which may already contain the fix.
See Also
Other Resources