PostSharp.Sdk.CodeModel.AssemblyLoadException: Cannot find assembly 'mscorlib,

rdontireddy's Avatar


23 Jun, 2015 08:46 PM

I have update postsharp from v 4.1.3-alpha to v 4.1.15 there is no issue when i build on my local developer box, but when gated a build its failing on build server with the below error

Unhandled exception (, postsharp.4.0-x86.exe, CLR 4.0.30319.378758, Release): PostSharp.Sdk.CodeModel.AssemblyLoadException: Cannot find assembly 'mscorlib, version=, culture=neutral, publickeytoken=7cec85d7bea7798e'. [Public key mismatch]
I updated to the same version from v 4.1.6-alpha in different solution and build server could build it successfully.

Can any one help understanding why postsharp is looking for mscorlib v 2.0.5.o when all the projects in the solution is targeted to .Net v 4.5.1?
How can I resolve this issue?

  1. Support Staff 1 Posted by PostSharp Techn... on 24 Jun, 2015 09:30 PM

    PostSharp Technologies's Avatar


    mscorlib, v2.0.5.0 is a special version used by PCL. Therefore I would expect that you project somehow references PCL either directly or indirectly.

    Actually we had a related issue that was fixed in 4.1.7. C# compiler has a bug that causes assemblies that reference both PCL and normal class libraries to have two references to mscorlib, including v2.0.5.0. This caused similar issue as PostSharp needs to load exact version of the referenced assembly. Up to PostSharp 4.1.6 we did not have a build-in workaround for this case. Is it possible that you have some assembly redirections active that were meant to solve the issue?

    Also please try to delete Binding Maps directory under C:\ProgramData\PostSharp\BindingMaps. After that you may experience first build being quite slow as PostSharp will rebuild those maps.

    If aforementioned does not help, I would need some small reproduction.

    Kind regards,

  2. 2 Posted by spamwasyesterda... on 25 Jun, 2015 02:32 PM

    spamwasyesterday's Avatar

    I'm experiencing the same error after I upgraded from 3.1 to 4.1.15. We don't use any portable stuff and we don't build portable libraries.

    On my local development machine, there is a folder "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable" (with three folders v4.0, v4.5 and v4.6 in it). On the build agent (also windows 7), this folder is missing. But do we need that if we're only building .NET 4.5 based apps?

    I cleaned the Binding Maps directory and searched in my assemblies for Binding Redirects without any results.

    I attached the msbuild.log.

  3. Support Staff 3 Posted by PostSharp Techn... on 25 Jun, 2015 06:57 PM

    PostSharp Technologies's Avatar


    one of your references certainly depends on mscorlib, v2.0.5.0. You have two options:

    1) Install Microsoft Build Tools 2013 and Portable Library Reference Assemblies. PostSharp should have all it needs to compile correctly.
    2) Add assembly redirection to PostSharp host configuration file. Build properties of PostSharp are described here and assembly binding redirections here. I do not recommend this solution.

    PostSharp uses binding maps for correctly redirecting assemblies and types between reference framework (target framework of a referenced assembly), target framework (target framework of the currently transformed assembly) and native framework (framework under which PostSharp is running). To build the map correctly one needs to have access to reference assemblies of both frameworks (including references!).

    Up to PostSharp 4.0, binding maps for all supported frameworks were distributed as a part of PostSharp NuGet package. However, size of binding maps is cubic in number of supported frameworks (counting every single version!). Since we have more than doubled number of supported frameworks in 4.1 and Microsoft speeded up it's release cycle, we stopped distributing binding maps as a part of NuGet package and all maps are generated on the client. The result is that user needs to have more targeting packs installed.

    Hope this helps.

    Best regards,

  4. 4 Posted by Mark on 19 Sep, 2015 10:34 PM

    Mark's Avatar

    This comment was split into a new discussion: PostSharp.Sdk.CodeModel.AssemblyLoadException: Cannot find assembly 'mscorlib,

    I just started having this issue after a bunch of nuget packages were updated. PostSharp was updated from to

    Builds work fine locally, but not on the build server which has MS Build Tools 2013 and Portable Library Reference Assemblies installed.

    The Portable Library Reference Assemblies is just a .zip (I think). Do I put the contents somewhere?

  5. System closed this discussion on 13 Apr, 2016 10:34 AM.

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