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

  • Home
  • SEARCH
  • 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 6621419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:15:42+00:00 2026-05-25T21:15:42+00:00

I have a property in a class that, when set, it will change some

  • 0

I have a property in a class that, when set, it will change some other properties’s values, any of which may raise an specific event for rollback (say RollbackEvent). If such event is fired then all changes made by the original property have been rolled back and now I need that property to stop on its tracks.

Throwing an exception is not an option (I think) ’cause there’ll be another assembly(s) consuming the code (actually is the other assembly who captures a second event in my code and, if it fails to handle the situation, it commands my code to rollback and that’s when the RollbackEvent is fired) for which no exception should be thrown.

Update

This is a general outline of my code, and AFAIK the code in the second Assembly should never realize an exception was thrown in the first one, but the after the “transaction” is rolled back (apparently) successfully the code on the second assembly stops executing.

Assembly 1

public class Someclass
{
    public String SomeField
    {
        get { return this._someField; }
        set 
        {
            try 
            {
                this.BackupSomeFields();
                this._someField = value;
                //Some other Properties are changed
                //One of which may (and will for the purposes of the question) throw a DocumentRolledbackException exception
            }
            catch (DocumentRolledbackException ex)
            {
                return;
            }
        }
    }

    public String SomeOtherField
    {
        get { return this._someOtherField; }
        set 
        {
            this._someOtherField = value;
            //Raise AN event (handled in Assembly 2)
        }
    }


    public void RollbackProcessTransaction()
    {
        //Rollback changes with the backup created by the SomeField property

        //Raise THE event
        DocumentRolledBack(this, new EventArgs());
    }


    private void MyBase_DocumentRolledBack(Object sender, EventArgs e)
    {
        //This method is called when the DocumentRolledBack event is fired in the RollbackProcessTransaction method.
        throw new DocumentRolledbackException(this);
    }

}

Assembly 2

public class SomeOtherClass
{
    private SomeClass obj;

    private HandleANEvent()
    {
        obj.RollbackProcessTransaction();
        //Code in this line on never gets executed! >.<
    }
}

Basically it’s all working good, when the exception is thrown in assembly 1 it gets captured by the property and such property then returns, but the code after the invocation of obj.RollbackProcessTransaction(); never gets executed… why?

P.S. I wrote all that code here in the editor ’cause I actually program in VB, so don’t take all the code there so literally, that’s just for you to get the idea.

  • 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-05-25T21:15:42+00:00Added an answer on May 25, 2026 at 9:15 pm

    Like this?

    public class Test
    {               
        public object Foo1 
        {
            try
            {           
               Foo2 = 1;
               Foo3 = 2;
               Foo4 = 3;
            }
            catch (RollbackException ex) { }
        }
    
        private void DoRollback()
        {
           throw new RollbackException();
        }
    
        public object Foo2 { get; set; }
        public object Foo3 { get; set; }
        public object Foo4 { get; set; }
    
        private class RollbackException : Exception
        {
        }
    }
    

    EDIT:

    public class SomeOtherClass
    {
        private SomeClass obj;
    
        public SomeOtherClass()
        {
          var backup = obj.Clone();
          try
          {
             obj.SomeField = "test";
          }
          catch (RollbackException ex)
          {
             obj = backup;
          }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Customer class that contains a property, MyProperty, which is of a
I have a property on a class that happens to be a Table<T> .
I have a property inside a class that is getting changed by something. The
I want to have a class property that allow for an expression to take
D2.0 classes have a __monitor class property that gives access to the class object's
I have a class that has a property that I need to stub. I
I have a class that defines a read-only property that effectively exposes a private
I have an entity class that has a property with an underlying db column
I have a Menu class that has a IQueryable property called WebPages. In the
I have a property within a class, that I need to iterate through all

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.