lex.db icon indicating copy to clipboard operation
lex.db copied to clipboard

System.Reflection.TargetException after upgrading to v 1.2.6

Open bartlannoeye opened this issue 9 years ago • 3 comments

Everything was running fine in v 1.2.5, after upgrading to v 1.2.6 I started to receive following error:

An exception of type 'System.Reflection.TargetException' occurred in mscorlib.ni.dll but was not handled in user code

Additional information: Non-static method requires a target.

Some of the errors I could fix by changing following code:

db.DbInstance.Save(dbVATBookings.AsEnumerable());

to:

db.DbInstance.Save(dbVATBookings);

with dbVATBookings being a list. I'm still receiving it on saving a list of users though. I've tried saving both a IEnumerable and aList`, but the issue shows on both.

Here's the model we're failing to save:

public partial class User : ModelBase
{
    public string INSS { get; set; }
    public string PIN { get; set; }
    public string Firstname { get; set; }
    public string Lastname { get; set; }
    public string ImagePath { get; set; }
    public string MobilePhone { get; set; }
    public string LandlinePhone { get; set; }
    public string Email { get; set; }
    public string Facebook { get; set; }
    public string Nationality { get; set; }
    public string BirthLocation { get; set; }
    public int Gender { get; set; }
    public string Street { get; set; }
    public string StreetNumber { get; set; }
    public string BoxNumber { get; set; }
    public string Zip { get; set; }
    public string Municipality { get; set; }
    public string Country { get; set; }
    // [XmlIgnore] // tried this, no fix
    public Guid[] TokenGuid { get; set; }
    public int ClockingStatus { get; set; }
    public DateTimeOffset ClockingEventDate { get; set; }

    public Guid? UserProfileId { get; set; }

    private UserProfile _userProfile;
    [XmlIgnore] // to avoid DB Serialization
    public UserProfile UserProfile
    {
        get
        {
            //return this.UserProfileId.HasValue ? _userProfile ?? (_userProfile = LexDbService.GetInstance().Result.UserProfiles.LoadByKey(this.UserProfileId.Value)) : null;
            if (this.UserProfileId.HasValue)
            {
                _userProfile = LexDbService.GetInstance().UserProfiles.LoadByKey(this.UserProfileId.Value);
                if (!ReferenceEquals(_userProfile, null) && !_userProfile.IsDeleted)
                    return _userProfile;
            }

            return null;
        }
        set
        {
            _userProfile = value;
            this.SyncUserProfile();
        }
    }

    private void SyncUserProfile()
    {
        if (!ReferenceEquals(this.UserProfile, null))
            this.UserProfileId = this.UserProfile.Id;
    }

    public override object SortingField
    {
        get { return string.Concat(this.Firstname, this.Lastname); }
    }
}

public abstract class ModelBase : IModelBase
{
    public Guid Id { get; set; }
    public DateTime Timestamp { get; set; }
    [XmlIgnore]
    public ObjectState ObjectState { get; set; }
    public bool IsSynched { get; set; }
    public bool IsDeleted { get; set; }

    /// <summary>
    /// Indicate what field we want to sort on
    /// </summary>
    [XmlIgnore]
    public virtual object SortingField { get; set; }
}

bartlannoeye avatar Jan 10 '16 11:01 bartlannoeye

Hey @demigor, do you have an update on this?

bartlannoeye avatar Feb 01 '16 20:02 bartlannoeye

I have the same issue with Lists and Nullable types in version 1.2.6 (Non-static method requires a target). But everything works fine in vesion 1.2.5.

sylion avatar Mar 23 '16 15:03 sylion

@demigor I'm also seeing this issue (works 1.2.5, broken 1.2.6). Any thoughts on a possible timeline for a fix?

Thanks, Brian

briancaw avatar Oct 08 '16 19:10 briancaw