Edit level mismatch in Object while taking caption from Resource (Random Error)

Edit level mismatch in Object while taking caption from Resource (Random Error)

Old forum URL: forums.lhotka.net/forums/t/11522.aspx

Snehal posted on Thursday, August 09, 2012


i am getting random error while initialize an object. when am opening form some times its giving above error and some time not. While debugging i found error is coming in following place.

In DataPortal_Create i check for  ValidationRules.CheckRules()

On validation rules its goes to following function

Private Shared Function AccountExist(ByVal target As Consignment, ByVal e As Csla.Validation.RuleArgs) As Boolean

        Dim RetVal As Boolean

        If Account.Exists(target.AccountCode) Then
            RetVal = True
            RetVal = False
            e.Description = InfoCenter.GetDisplayTextFromResource("AccountisRequired")
        End If
        Return RetVal

    End Function

for above function it goes to false part and trying to get msg from resource. below is resource function.


Public Shared Function GetDisplayTextFromResource(ByVal Key As String) As String

        Dim loc As WPFLocalizeExtension.Extensions.LocTextExtension = Nothing
        Dim strRetVal As String = ""
        loc = New WPFLocalizeExtension.Extensions.LocTextExtension() ' "ResourceAssembly:resCommon:" & Key)
        loc.Assembly = "ResourceAssembly"
        loc.Dict = "resCommon"
        loc.Key = Key
        Return strRetVal

    End Function


I am getting over on bold line that "Edit level mismatch in Object". if i open same form again its not firing any error. can anybody help me...!!!



JonnyBee replied on Thursday, August 09, 2012

You should look closely at the Ioc container configuration (and possibly a singelton instance?) .

It would seem that the Ioc resolves into an already existing object that is likely to be active in databinding.
The exception is typically thrown from BeginEdit/CancelEdit/ApplyEdit and these methods are mostly called by DataBinding.

Copyright (c) Marimer LLC