Red Gate forums :: View topic - Can't get postsharp working
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SmartAssembly 6
SmartAssembly 6 forum

Can't get postsharp working

Search in SmartAssembly 6 forum
Post new topic   Reply to topic
Jump to:  
Author Message
spammenao252



Joined: 20 Jan 2013
Posts: 8

PostPosted: Sun Jan 20, 2013 11:45 pm    Post subject: Can't get postsharp working Reply with quote

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
Back to top
View user's profile Send private message
spammenao252



Joined: 20 Jan 2013
Posts: 8

PostPosted: Mon Jan 21, 2013 1:31 am    Post subject: Reply with quote

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:
   <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>
Back to top
View user's profile Send private message
spammenao252



Joined: 20 Jan 2013
Posts: 8

PostPosted: Mon Jan 21, 2013 3:32 pm    Post subject: Reply with quote

I narrowed the problem down to this:

Code:
[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?
Back to top
View user's profile Send private message
james.billings



Joined: 16 Jun 2010
Posts: 1119
Location: My desk.

PostPosted: Tue Jan 22, 2013 6:00 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
james.billings



Joined: 16 Jun 2010
Posts: 1119
Location: My desk.

PostPosted: Tue Jan 22, 2013 6:15 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
spammenao252



Joined: 20 Jan 2013
Posts: 8

PostPosted: Tue Jan 22, 2013 10:35 pm    Post subject: Reply with quote

Thanks for checking that out. I guess I'll keep implementing workarounds whenever I bump into issues using Poshsharp, for now Wink
Back to top
View user's profile Send private message
james.billings



Joined: 16 Jun 2010
Posts: 1119
Location: My desk.

PostPosted: Wed Jan 23, 2013 12:48 pm    Post subject: Reply with quote

Yeah, hopefully it'll improve though!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group