Can't get postsharp working

.NET obfuscator and automated error reporting

Moderators: Luke Jefferson, melvyn.harbour, dom.smith

Can't get postsharp working

Postby spammenao252 » Sun Jan 20, 2013 11:45 pm

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
spammenao252
 
Posts: 8
Joined: Sun Jan 20, 2013 11:39 pm

Postby spammenao252 » Mon Jan 21, 2013 1:31 am

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:

Code: Select all
   <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>
spammenao252
 
Posts: 8
Joined: Sun Jan 20, 2013 11:39 pm

Postby spammenao252 » Mon Jan 21, 2013 3:32 pm

I narrowed the problem down to this:

Code: Select all
[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?
spammenao252
 
Posts: 8
Joined: Sun Jan 20, 2013 11:39 pm

Postby james.billings » Tue Jan 22, 2013 6:00 pm

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.
james.billings
 
Posts: 1144
Joined: Wed Jun 16, 2010 11:10 am
Location: My desk.

Postby james.billings » Tue Jan 22, 2013 6:15 pm

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.
james.billings
 
Posts: 1144
Joined: Wed Jun 16, 2010 11:10 am
Location: My desk.

Postby spammenao252 » Tue Jan 22, 2013 10:35 pm

Thanks for checking that out. I guess I'll keep implementing workarounds whenever I bump into issues using Poshsharp, for now ;)
spammenao252
 
Posts: 8
Joined: Sun Jan 20, 2013 11:39 pm

Postby james.billings » Wed Jan 23, 2013 12:48 pm

Yeah, hopefully it'll improve though!
james.billings
 
Posts: 1144
Joined: Wed Jun 16, 2010 11:10 am
Location: My desk.

Re:

Postby manlyboy » Mon Jul 14, 2014 3:12 am

james.billings wrote: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!
manlyboy
 
Posts: 16
Joined: Tue Apr 17, 2012 9:08 am


Return to SmartAssembly 6

Who is online

Users browsing this forum: No registered users and 1 guest