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 8457703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:52:38+00:00 2026-06-10T12:52:38+00:00

I have the following: private int order; public int Order { get { return

  • 0

I have the following:

    private int order;
    public int Order {
        get { return order; }
        set {
            if ((value < 0) || (value > 99)) {
                throw new Exception(string.Format("{0} must be between 0 and 99", value.ToString()));
            } else {
                order = value;
            }
        }
    }

This is called here:

            try {
                property.SetValue(reference, convertedValue, null);
            } catch (Exception e) {
                var a = e;
            }

When I set a value of 50 everything works okay. When I set the value to 123 and step through with the debug it goes to the property.SetValue line and then next thing is it gives me this and points to the end of the “} else {” code block in the first code snippet.

System.Exception was unhandled by user code
  HResult=-2146233088
  Message=123 must be between 0 and 99
  Source=Test.Storage
  StackTrace:
       at Storage.Models.Reference.set_Order(Int32 value) in C:\Code K\139- Aug  23\Common\Storage\Models\Reference.cs:line 22
  InnerException: 

Can someone explain why the exception is not handled? I can’t understand why it would not be caught with the try loop that surrounds property.SetValue. I have a debug point on var a = e; but it doesn’t go there.

  • 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-10T12:52:40+00:00Added an answer on June 10, 2026 at 12:52 pm

    The problem lies with the Visual Studio Debugger which, by default, enables the “Enable Just My Code” option. In your situation you are not handling your code, but the reflection code is kicking in.

    If you were to run the application directly from Windows Explorer you will see that there’s nothing wrong and the exception is correctly handled.

    More information can be found at http://msdn.microsoft.com/en-us/library/038tzxdw%28v=vs.100%29.aspx and a similar post with a more detailed answer can be found at https://stackoverflow.com/a/2831236/146205.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code in my class: private int order; public int Order
I have following class public class ButtonChange { private int _buttonState; public void SetButtonState(int
I have the following class: class Patient { public: Patient(int x); ~Patient(); private: int*
I have the following struct private struct sData{ public int volume; public System.Timers.Timer aliveTimer;
I have the following code: private String foo; public void setFoo(String bar) { foo
I have the following class: private class NodeTemp { public string Content; public NodeTemp
I have the following class: template <typename T> class matrix { private: int _n;
I have the following code: private void _DoValidate(object sender, DoWorkEventArgs e) { this.BeginInvoke(new MethodInvoker(()
I have the following function private Integer calculateWeeklyValue(String p_Value, String Frequency) { if (p_Value.length()
Given the following code : public class Game { private Map<String,Coordinate> m_myHashMap; ... //

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.