What are the challenges you face when working across database platforms? Take the survey
Options

Can't get postsharp working

spammenao252spammenao252 Posts: 10
edited July 13, 2014 10:12PM in SmartAssembly
According to http://www.sharpcrafters.com/blog/post/SmartAssembly-now-supports-PostSharp.aspx SA supports postsharp since v6.6.4 and your release notes confirm this. I selected the Support for Obfuscation option and a .pssym file is generated (not sure what to do with that anyway, I assumed SA handles it automatically), but my application still crashes when I use obfuscation.

What I'm trying to do at the moment is obfuscate a library referenced by the UI application (winforms.) Just to make sure I also selected enable obfuscation in the windorms app. Didn't help.

I also tried compiling the winforms app using the obfuscated library as a reference, rather than compiling with the original library referenced, and then swapping it with the obfuscated version. That didn't make it work either.

Postsharp version: v2.1.7.28
.Net version: v4.0

Comments

  • Options
    I now also tried using msbuild to see what that did, but still no dice.. library ends up obfuscated as expected but program still crashes with a 'The type initializer for ' ' threw an exception.' exception.

    The .csproj config:
    <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
      <UsingTask TaskName="SmartAssembly.MSBuild.Tasks.Build" AssemblyName="SmartAssembly.MSBuild.Tasks, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7f465a1c156d4d57" />
      <Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release' ">
        <SmartAssembly.MSBuild.Tasks.Build ProjectFile="C:\Users\Admin\Documents\Visual Studio 2010\Projects\SmartAssFuscate\SmartAssFuscate\bin\Release\SmartAssFuscate.saproj" />
      </Target>
    
  • Options
    I narrowed the problem down to this:
    [SomeAspect("SomeName", "SomeString", typeof(CSomeClass))]
    

    Getting rid of the typeof() 'fixes' the issue so I guess I'll do that and implement a workaround that doesn't make my app crash after obfuscation.

    Regardless, can someone please elaborate on how I can properly make PostSharp and SA work together? What do I do with afformentioned .pssym file? Is it auto-used when configuring MSBuild, or? And what happens then when we build using the regular SA application to obfuscate? Or are there additional steps required to use the files either way?
  • Options
    Thanks for your posts. I'm not too familiar with Postsharp I'm afraid- last time it cropped up in conversation here, the general consensus is that you process your assemblies with Postsharp first, then Smartassembly, which I guess you're doing.

    I did a quick search through our bugtracker for references to the pssym files but nothing came up, so I don't know if these are something we use or are just a side effect of activating the VS option and aren't needed by us - you may of course be hitting a problem that's not directly related to Postsharp. I did a search for issues surrounding the use of typeof, but nothing came up (although if removing it still works correctly then that's good for now).

    I'll try and find out if there's any extra steps needed for postsharp - as I understood, it should "just work", but i'll get some clarification.
    Systems Software Engineer

    Redgate Software

  • Options
    OK, further to my last post- we don't use the pssym files at all. Everything that SA requires is in the assembly.
    It also sounds like there may be a bug in some instances with Postsharp though, and our developers are liasing with the people at Sharpcrafters in relation to this - so it may be that an update to SA in the future will improve on the compatibility.
    Systems Software Engineer

    Redgate Software

  • Options
    Thanks for checking that out. I guess I'll keep implementing workarounds whenever I bump into issues using Poshsharp, for now ;)
  • Options
    Yeah, hopefully it'll improve though!
    Systems Software Engineer

    Redgate Software

  • Options
    manlyboymanlyboy Posts: 27 Bronze 2
    OK, further to my last post- we don't use the pssym files at all. Everything that SA requires is in the assembly.
    It also sounds like there may be a bug in some instances with Postsharp though, and our developers are liasing with the people at Sharpcrafters in relation to this - so it may be that an update to SA in the future will improve on the compatibility.

    Is there any update on this because I can't get sa to work with postsharp either!
Sign In or Register to comment.