Unhandled exception (4.3.33.0, postsharp-net40-x86-srv.exe, CLR 4.0.30319.461310, Release): PostSharp.Sdk.CodeModel.AssemblyLoadException: Cannot load assembly C:projectsrc\packages\structuremap.4.2.0.402\lib\net40\StructureMap.dll. [Public

barathk913's Avatar

barathk913

23 Apr, 2018 08:07 AM

i am using visual studio 2017. when i tried to install postsharp 4.3.33 for my web based application i am getting an compile time error. my application contains 11 components. out of 11 components 10 got succeed with post sharp and 1 got failed due to below exception. please help me on this ASAP.

Unhandled exception (4.3.33.0, postsharp-net40-x86-srv.exe, CLR 4.0.30319.461310, Release): PostSharp.Sdk.CodeModel.AssemblyLoadException: Cannot load assembly C:\src\packages\structuremap.4.2.0.402\lib\net40\StructureMap.dll. [Public key mismatch]

  1. Support Staff 1 Posted by PostSharp Techn... on 23 Apr, 2018 04:21 PM

    PostSharp Technologies's Avatar

    Hello,

    Could please check if there is an assembly binding log in the MSBuild output? The log can be helpful in diagnosing the issue.

    Also, 4.3.33 is an old build of PostSharp. Could you try to upgrade to the the latest 4.3 build (4.3.43) or try the 5.0 version?

    -alex

  2. 2 Posted by barathk913 on 30 Apr, 2018 06:43 AM

    barathk913's Avatar

    Hi Alex,

    As Suggested, i have updated the postsharp version to 5.0.50. now i am getting the below error related to postsharp. i am unable to figure it out. please help me on this.

    Severity Code Description Project File Line Suppression State
    Error Unhandled exception (postsharp-net40-x86-srv.exe release | .NET Framework 4.7.1): PostSharp.Sdk.CodeModel.BindingException: Cannot get the reflection object for 'StructureMap.dll'.
       at ^Mzw3\.bgGgRlJ.^cCM832sT[??0](Object _0, BindingOptions _1, ^d1u4kZd5aJLe _2)
       at PostSharp.Sdk.CodeModel.Domain.^Q77Ni+3v(AssemblyEnvelope _0, BindingOptions _1)
       at PostSharp.Sdk.CodeModel.AssemblyRefDeclaration.GetSystemAssembly(BindingOptions options)
       at ^XJbqCOExOmCj.^NRQTI+sj(INamedType _0, BindingOptions _1)
       at PostSharp.Sdk.CodeModel.TypeRefDeclaration.^VorA+nDk(BindingOptions _0)
       at ^Mzw3\.bgGgRlJ.^cCM832sT[??0](Object _0, BindingOptions _1, ^d1u4kZd5aJLe _2)
       at PostSharp.Sdk.CodeModel.TypeRefDeclaration.GetSystemType(Type[] genericTypeArguments, Type[] genericMethodArguments, BindingOptions options)
       at ^XJbqCOExOmCj.^6pB/qWH+(IMethod _0, Type& _1, Type[] _2, Type[] _3, Type[] _4, BindingOptions _5)
       at ^XJbqCOExOmCj.^4IrPP9eT(Object _0, IMethod _1, Type[] _2, Type[] _3, BindingOptions _4)
       at PostSharp.Sdk.CodeModel.MethodDefDeclaration.^NqB3CEvX(BindingOptions _0)
       at ^Mzw3\.bgGgRlJ.^cCM832sT[??0](Object _0, BindingOptions _1, ^d1u4kZd5aJLe _2)
       at PostSharp.Sdk.CodeModel.MethodDefDeclaration.GetSystemMethod(Type[] genericTypeArguments, Type[] genericMethodArguments, BindingOptions bindingOptions)
       at PostSharp.Sdk.CodeModel.MethodDefDeclaration.^xHA5o+hH(Type[] _0, Type[] _1, BindingOptions _2)
       at PostSharp.Sdk.CodeModel.MetadataDeclaration.^UDRJYqgBJZ7t(Type[] _0, Type[] _1, BindingOptions _2)
       at PostSharp.Sdk.AspectWeaver.AspectWeaverInstance..ctor(AspectWeaver aspectWeaver, AspectInstanceInfo aspectInstanceInfo)
       at PostSharp.Sdk.AspectWeaver.AspectWeavers.MethodLevelAspectWeaverInstance..ctor(MethodLevelAspectWeaver aspectWeaver, AspectInstanceInfo aspectInstanceInfo)
       at ^wy1eTA/ccvw/.CreateAspectWeaverInstance(AspectInstanceInfo _0)
       at PostSharp.Sdk.AspectWeaver.AspectWeaverTask.^lp9i7ZhC(InstructionWriter _0, AspectInstanceInfo _1, StructuredDeclarationDictionary`1 _2)
       at PostSharp.Sdk.AspectWeaver.AspectWeaverTask.^gJhZb6Cg.^KzeTZ0pV(IMetadataDeclaration _0, AspectInstanceInfo _1)
       at PostSharp.Sdk.AspectInfrastructure.StructuredDeclarationDictionary`1.^lNgKC+Z4(IMetadataDeclaration _0, Func`3 _1)
       at PostSharp.Sdk.AspectInfrastructure.StructuredDeclarationDictionary`1.^v4\.zwEyH.^8/pSq47Q(IMetadataDeclaration _0)
       at PostSharp.Sdk.AspectInfrastructure.StructuredDeclarationDictionary`1.^d+wOzSPF(IMetadataDeclaration _0, Func`2 _1)
       at PostSharp.Sdk.AspectInfrastructure.StructuredDeclarationDictionary`1.^+g+TCqVg(TypeDefDeclaration _0, Func`2 _1, Set`1 _2)
       at PostSharp.Sdk.AspectInfrastructure.StructuredDeclarationDictionary`1.^fJqG(Func`2 _0)
       at PostSharp.Sdk.AspectInfrastructure.StructuredDeclarationDictionary`1.^fJqG(Func`3 _0)
       at PostSharp.Sdk.AspectWeaver.AspectWeaverTask.Execute()
       at PostSharp.Sdk.Extensibility.Project.ExecutePhase(String phase)
       at PostSharp.Sdk.Extensibility.Project.Execute()
       at PostSharp.Hosting.PostSharpObject.ExecuteProjects()
       at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation). project.Web

  3. Support Staff 3 Posted by PostSharp Techn... on 30 Apr, 2018 03:20 PM

    PostSharp Technologies's Avatar

    Hello,

    we didn't manage to reproduce your issue yet, unfortunately. Would it be possible to provide us a (sample) project reproducing your issue?

    You can also try the latest preview of PostSharp 5.1 as we have reworked the assembly loading feature which is probably causing your issue.

    Best regards,
    -tony

  4. 4 Posted by barathk913 on 04 May, 2018 12:29 PM

    barathk913's Avatar

    Hi,

    As Suggested, i have updated the postsharp version to 5.1.9 preview. after updated i am getting different error related to postsharp as below

    Severity Code Description Project File Line Suppression State
    Error The "PostSharp.MSBuild.PostSharp30CopyBindingRedirects" task could not be loaded from the assembly D:\new\project\ConsoleApplication1\SPDLib\\PostSharp.MSBuild.v5.1.9.Release.dll. Could not load file or assembly 'file:///D:\new\project\ConsoleApplication1\SPDLib\PostSharp.MSBuild.v5.1.9.Release.dll' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. ConsoleApplication1

  5. Support Staff 5 Posted by PostSharp Techn... on 04 May, 2018 01:22 PM

    PostSharp Technologies's Avatar

    Hello,

    this shows that your installation of PostSharp in your project is corrupted. Could you please share with us you project configuration files (*.csproj, *.psproj, postsharp.config, packages.config, ...) so we can have a look?

    As I've mentioned before - the best would be if you could share with us a complete project reproducing your issue.

    Best regards,
    -tony

  6. 6 Posted by barathk913 on 08 May, 2018 11:45 AM

    barathk913's Avatar

    Hi,

    please find the attached sample project which replicates the issue.

    please let me know the updates once you got any solution on this.

  7. Support Staff 7 Posted by PostSharp Techn... on 09 May, 2018 10:49 AM

    PostSharp Technologies's Avatar

    Hello,

    you should reference PostSharp package through NuGet, currently the csproj file references SPDLib\PostSharp.targets, which cannot work as there are no build tools etc. This is not a supported use case. Please remove the import from the project file and install PostSharp package instead.

    If this doesn't work for you, please describe your use case in more detail.

    Best regards,
    Daniel

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? 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