PropertyChanged event bug

Posts   
 
    
LLBLGen
User
Posts: 43
Joined: 10-Apr-2006
# Posted on: 09-Oct-2006 04:57:27   

When you throw Exception inside PropertyChanged event the Exception does not get thrown, is this a bug?

this is what i have...

    private void BindData()
    {
        this.TextBox1.DataBindings.Add("Text", ee,"LastName");
        this.TextBox2.DataBindings.Add("Text", ee,"FirstName");
        ee.PropertyChanged += new PropertyChangedEventHandler(ee_PropertyChanged);

    }

    private void ee_PropertyChanged(object sender, EventArgs e)
    {
        throw new Exception("Message Exception");
    }
Walaa avatar
Walaa
Support Team
Posts: 14951
Joined: 21-Aug-2005
# Posted on: 09-Oct-2006 08:48:47   

Does the PropertyChanged event handler ever receives the call? Put a breakpoint inside and see if it gets called.

Also please post all possible information, check the following thread: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7717

LLBLGen
User
Posts: 43
Joined: 10-Apr-2006
# Posted on: 09-Oct-2006 14:57:28   

I have the V2 (October 3rd Version) Runtime (2.0.0.0) Yes the event gets called , the exception was never thrown.

I am using Adapter, .NET 2.0, SQL Server 2005, WinForms.

In my example i am simply binding an employee entity information (Lastname,FirstName) to a WinForm text box...and want to throw exception during certain condition...but under PropertyChanged event handler the exception do not get thrown.

i have posted my exact code in my previous message.

Jessynoo avatar
Jessynoo
Support Team
Posts: 296
Joined: 19-Aug-2004
# Posted on: 09-Oct-2006 16:05:36   

Hi, it seems the only places where your exception can get caught from within the entitybase code is on deserialization/xmldeserialization methods. Now there may be other places where it gets caught. Maybe you should try a rebuild of the runtime libs in debug an step out from the handler to see where it gets lost.

Cheers

Edit: apparently, it could be "swollen" in the databinding routines. Now you can probably find other ways of passing the info. you can use events, direct call, or take advantage of the "SetEntityFieldError" method

LLBLGen
User
Posts: 43
Joined: 10-Apr-2006
# Posted on: 10-Oct-2006 14:46:20   

I have a Custom Exception handeling that gets thrown not only when there is a System or DB Exception but also when there are certain condition met.

One example:

When User changes the SSN but if the user do not have the permission to change the SSN the custom exception is thrown. All these permissions are Table based. The table defines wheather this user can change the SSN or not.

This is not a System or DB Exception but i need to throw my custom exception, is there anything i can do, that dont get sollown?

Jessynoo avatar
Jessynoo
Support Team
Posts: 296
Joined: 19-Aug-2004
# Posted on: 10-Oct-2006 16:50:32   

This is not about the type of exception, any exception would get caught in your case. Since this is by .Net native binding code rather than by LLBLGen, we can't do much.

Now, as I said, there are several ways to keep passing the info without throwing an exception. You should try them. Alternatively, you may try to change your code so that the UI does not mess with your exception (and you can check that in another context, the exception gets correctly bubbled)

Cheers