I have to abandon using PostSharp, because it won't work with obfuscated/merged assemblies. At least, I don't see any way to get it working (it crashes on app start, when assemblies are obfuscated)
I need to intercept some methods in my app (call special code instead of original methods - OnMethodInvocationAspect)
Any advice?

- 995
- 1
- 10
- 21
4 Answers
PostSharp somewhat supports ILMerge. See http://www.postsharp.org/blog/postsharp-and-ilmerge. But there are problems with obfuscated assemblies.
Since aspects are serialized at build time, they cannot be deserialized if the aspect type has been obfuscated. The solution is not to obfuscate any serializable type. Another solution is not to serialize aspects (see AspectConfigurationAttribute.SerializerType in PostSharp 2.0, and use the serializer MsilAspectSerializer).
There are problems when aspects are applied to generic methods and methods of generic types (the reason is that PostSharp uses reflection, based on method names, in this case, to work around bugs in the CLR).

- 6,405
- 6
- 28
- 69

- 6,759
- 2
- 24
- 31
NCop is a composite-aspect framework for the .NET platform inspired by Post Sharp
Sheep Aspect is an alternative open source AOP tool for the .NET platform inspired by AspectJ

- 8,972
- 3
- 33
- 41
-
NCop seems like an anti-pattern. Why would you decorate an interface with concrete class type for IoC style resolution? If I have multiple implementations of the interface, do I need to go and change the interface definition every time I add a new implementation? – Hemant Oct 13 '16 at 02:02
-
NCop is a concept library of composition, and not a IoC library (although it encapsulates the concept of IoC.) You only need to decorate the composite type with the concrete classes and not the role interfaces. Please refer to https://github.com/sagifogel/NCop/wiki/Mutliple-mixins – Sagi Oct 13 '16 at 18:59
Spring.NET has AOP features which are weaved at runtime so should work with obfuscated assemblies.
http://www.springframework.net/
Documentation:
http://www.springframework.net/doc-latest/reference/html/aop.html

- 2,500
- 1
- 20
- 24
Aspect-oriented programming is just a special case of program transformation. If you can apply program transformations using a tool, you can do AOP easily.
Our DMS Software Reengineering Toolkit is a program transformation engine that handles many real languages, including C, C++, Java, COBOL and even C#4.0.
See Aspect Oriented Programming using DMS for more details.

- 93,541
- 22
- 172
- 341