Post-compilation unhandled error: Cannot find a method named '..' with signature ...

amiy's Avatar


04 Feb, 2018 06:35 AM

I'm using VS2015 (.NET 4.6.1) with Postsharp 5.0.43. We a a large solution with lots of projects.
We're using an external obfuscation tool.
We recently upgraded from Postsharp 4.3.21 to 5.0.43 because it has functionality we need (async support).
Since the upgrade, when compiling with this obfuscator, Postsharp's post compilation fails with this error:

C:\git\be\External\Postsharp\5.0.43\Tools\PostSharp.targets(314,5): error PS0099: Unhandled exception (postsharp-net40-x86-srv.exe release | .NET Framework 4.6.1): PostSharp.Sdk.CodeModel.BindingException: Cannot find a method named 'MapSortParameter' with signature '(System.Collections.Generic.ICollection`1<T><System.Data.IDataParameter>, ST.Dal.Sort) : void' in scope 'ST.Dal.Sql.Repository.BaseRepository`1<T>' (module = 'ST.Dal.Sql.dll').
C:\git\be\External\Postsharp\5.0.43\Tools\PostSharp.targets(314,5): error PS0099: at PostSharp.Sdk.CodeModel.Collections.MethodDefDeclarationCollection.GetMethod(String name, IMethodSignature signature, BindingOptions bindingOptions)
C:\git\be\External\Postsharp\5.0.43\Tools\PostSharp.targets(314,5): error PS0099: at PostSharp.Sdk.CodeModel.MethodRefDeclaration.GetMethodDefinition(BindingOptions bindingOptions)
C:\git\be\External\Postsharp\5.0.43\Tools\PostSharp.targets(314,5): error PS0099: at PostSharp.Sdk.Extensibility.Tasks.IndexGenericInstancesTask.Execute()
C:\git\be\External\Postsharp\5.0.43\Tools\PostSharp.targets(314,5): error PS0099: at PostSharp.Sdk.Extensibility.Project.ExecutePhase(String phase)
C:\git\be\External\Postsharp\5.0.43\Tools\PostSharp.targets(314,5): error PS0099: at PostSharp.Sdk.Extensibility.Project.Execute()
C:\git\be\External\Postsharp\5.0.43\Tools\PostSharp.targets(314,5): error PS0099: at PostSharp.Hosting.PostSharpObject.ExecuteProjects()
C:\git\be\External\Postsharp\5.0.43\Tools\PostSharp.targets(314,5): error PS0099: at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation).

dotPeek shows the obfuscation actually removes this method (MapSortParameter) for some reason, but code still calls it normally when needed.
I'm not sure why Postsharp fails on this missing method: it's not used for or by Postsharp's attributes in any way. It did not happen on the previous version we used.


  1. Support Staff 1 Posted by PostSharp Techn... on 06 Feb, 2018 01:27 PM

    PostSharp Technologies's Avatar


    would it be possible to extract and provide us a project which reproduces this issue, so we can diagnose the behavior?

    Best regards,

  2. 2 Posted by amiy on 14 Feb, 2018 10:33 AM

    amiy's Avatar

    A zip is attached.
    VS2015 solution,
    Using postsharp dlls from "external" folder.
    Also using an obfuscated dll from External folder.


  3. Support Staff 3 Posted by PostSharp Techn... on 15 Feb, 2018 03:52 PM

    PostSharp Technologies's Avatar


    I have managed to reproduce the issue. In case of the source code you have provided Postsharp is not able to find ST.Dal.Sql.Repository.BaseRepository`1.ctor constructor. Is that correct?

    (internal issue #15875)

    Thanks for reporting the issue.

    Best regards,

  4. 4 Posted by amiy on 26 Feb, 2018 08:54 AM

    amiy's Avatar

    Yes. That's correct.
    Can you update when this is fixed?


  5. Support Staff 5 Posted by PostSharp Techn... on 26 Feb, 2018 10:26 AM

    PostSharp Technologies's Avatar


    yes, we'll update you as soon as the bug fix has been released. We're closing the ticket for now as the bug has been internally filed as issue #15875.

    For more details on our support policies and prioritization of bug fixes, please visit

    Best regards,

  6. PostSharp Technologies closed this discussion on 26 Feb, 2018 10:26 AM.

  7. PostSharp Technologies re-opened this discussion on 27 Feb, 2018 04:15 PM

  8. Support Staff 6 Posted by PostSharp Techn... on 27 Feb, 2018 04:15 PM

    PostSharp Technologies's Avatar


    We've spent several hours diagnosing the issue and we came to the conclusion that the assembly does not comply to the MSIL specification. However we acknowledge that other tools can read the assembly, despite its non-conformance. (The problem is that the values of the MethodList column in the TableDef metadata table are incorrect, see ECMA-335 II.22.37).

    Obfuscation tools are designed to break decompilation tools like PostSharp and sometimes rely on implementation details of the Microsoft toolchain to break decompilers without breaking the toolchain itself.

    Given that this is the only case in 13 years of stable existence of this code stack and that we've already invested so many hours, we're going to close the issue as Won't Fix and kindly ask you to find a workaround. We suggest to try the following approaches:

    • Obfuscate your assemblies at the end of the build process, after PostSharp has run for all projects, or
    • "Wrap" the obfuscated assembly in a non-obfuscated assembly so that projects using PostSharp do not reference the obfuscated assemblies.

    Thank you for your understanding.


  9. Support Staff 7 Posted by PostSharp Techn... on 08 Mar, 2018 12:49 PM

    PostSharp Technologies's Avatar


    We are going to close this request as there have not been any further updates. Please feel free to reopen the discussion if you need more help.

    PostSharp Team

  10. PostSharp Technologies closed this discussion on 08 Mar, 2018 12:49 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac