9 comments on “Applying aspects to 3rd party assemblies using PostSharp

  1. Gleb, you can use this approach for MVC assemblies, yes. Obfuscated assemblies will most likely not work depending on what you’re trying to do. Sometimes the meta data is far too scrambled to be useful and PostSharp will error out. Please give it a try though.

  2. This looks exactly like what I want to do. I tried it out using this exact example (PostSharp is now at version 2.1.5.1), but it doesn’t work. The aspect and aspect provider classes build, and the CIL executable runs without apparent problem.

    The resulting code contains an ExampleClass.z__Aspects class, but it’s empty. And the disassembled methods don’t contain any aspecting code whatsoever.

    Any idea what might be going wrong here?

    I may be missing a parameter or two, but the CIL executable doesn’t seem to be documented, at least to the degree where the parameter options are enumerated.

    Josh

    • Mystery solved. I ended up passing an object derived from IAspect (which is empty) instead of IOnMethodBoundaryAspect.
      It works quite nicely. Thanks very much.

  3. Pingback: planetgeek.ch » Unleash your code with PostSharp

  4. Hi when i am running your code i am getting following error as

    MyProviders.TraceAspectProvider’ does not implement interface member ‘PostSharp.Aspects.IAspectProvider.ProvideAspects(object)’. ‘MyProviders.TraceAspectProvider.ProvideAspects(object)’ cannot implement ‘PostSharp.Aspects.IAspectProvider.ProvideAspects(object)’ because it does not have the matching return type of ‘System.Collections.Generic.IEnumerable’.

    Do not know how to proceed….

    Waiting for your response

  5. Using the generic type ‘System.Collections.Generic.List’ requires 1 type arguments

    This error is also i am getting

  6. Pingback: Inject Aspect to a method using PostSharp IAspectProvider

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s