Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7743253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:29:09+00:00 2026-06-01T09:29:09+00:00

I created my own behavior as follows: public class BoundaryExceptionHandlingBehavior : IInterceptionBehavior { public

  • 0

I created my own behavior as follows:

public class BoundaryExceptionHandlingBehavior : IInterceptionBehavior
{


public IEnumerable<Type> GetRequiredInterfaces()
{
  return Type.EmptyTypes;
}

public IMethodReturn Invoke(IMethodInvocation input, GetNextInterceptionBehaviorDelegate getNext)
{
  try
  {
    return getNext()(input, getNext);
  }
  catch (Exception ex)
  {
    return null; //this would be something else...
  }
}

public bool WillExecute
{
  get { return true; }
}

}

I have it setup correctly so that my behavior gets hit as expected. However, if any exception happens in whatever getNext() does, it doesn’t hit my catch block. Can anyone clarify why? I’m not really looking to solve the problem as there’s many ways to deal with exceptions, it’s more that I don’t understand what’s going on, and I’d like to.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:29:10+00:00Added an answer on June 1, 2026 at 9:29 am

    You can’t catch any exception, if an Exception occurs it will be part of the Exception property of IMethodReturn.

    Like so:

    public IMethodReturn Invoke(IMethodInvocation input,
                    GetNextInterceptionBehaviorDelegate getNext)
    {
       IMethodReturn ret = getNext()(input, getNext);
       if(ret.Exception != null)
       {//the method you intercepted caused an exception
        //check if it is really a method
        if (input.MethodBase.MemberType == MemberTypes.Method)
        {
           MethodInfo method = (MethodInfo)input.MethodBase;
           if (method.ReturnType == typeof(void))
           {//you should only return null if the method you intercept returns void
              return null;
           }
           //if the method is supposed to return a value type (like int) 
           //returning null causes an exception
        }
       }
      return ret;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created my own Attached Property like this: public static class LabelExtension {
I've created my own signup form and creating the user using the Membership class.
I created my own big integer class, and big fraction class (which stores the
I've trouble with actionListener. I created own simple dialog, which has only two JButtons
I created my own custom date picker consisting of an ASP TextBox, Button, and
I've created my own application in VB.NET that saves its documents into a file
I have created my own Tree implementation for various reasons and have come up
I've created my own WCF service and I've successfully been able to talk to
I've created my own little c# compiler using the tutorial on MSDN, and it's
I have created my own customized lots of architecture including n-tier layers for different

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.