isubhan's Avatar


25 Apr, 2018 10:59 AM

I am new to PostSharp and trying it out for the first time.

I am trying to write code to add custom object in actual method which can be accessed in OnSuccess. How should I do this?

For Example
        public void TestAudit(int x, int y, int z)
            int a = x;
            int b = y;
            int c = z;

            Test obj = new Test() { Id = "12345", Name = "Irfon Subhan" };
           //How do I send this object to OnSuccess


According to the below discussion post we can use MethodExecutionArgs.Arguments to set but can you give me an example

Thank you


  1. Support Staff 1 Posted by PostSharp Techn... on 26 Apr, 2018 03:48 PM

    PostSharp Technologies's Avatar


    The code inside your method cannot pass anything directly into the aspect code. It's important to note that such approach would be against the principles of the aspect oriented programming model. You should try to design your code in such a way that it is not aware of the aspects applied to it.

    The OnMethodBoundaryAspect can access the method arguments, return value and the object instance on which the method is called. For more details about OnMethodBoundaryAspect please refer to this documentation page:

    You can also develop more advanced aspects that access properties and other members of the target type. You can find the documentation on this page:

    Please also note that we can provide only limited support to our community users on this forum. Please consider asking the question on StackOverflow and tag it with 'PostSharp' keyword ( or login into support forum with your commercial license.

    Best regards,

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac