object reference not set to an instance of an object on SubmitChanges()

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
-marcelo-
Posts: 26
Joined: Wed 28 Jun 2017 12:35

object reference not set to an instance of an object on SubmitChanges()

Post by -marcelo- » Fri 28 Sep 2018 19:08

I´m using LinqConnect 4.4.727 for PostgreSql.
My code reads some entities (Clerk, in this case) from database, and the tries to delete one of them.
The code (as usual) is DataContext.Clerks.DeleteOnSubmit(this);
"This" is an instance read from the previous query.
When I execute DataContext.SubmitChanges() thru the following method (in a partial class file)

Code: Select all

 
        public bool SendChanges( out string why)
        {
            bool result = true;
            why = String.Empty;
            try {
                SubmitChanges();
            }
            catch (Exception e) {
                why = e.Message;
                if (e.InnerException != null)
                    why = String.Format("{0} - {1}", e.Message, e.InnerException.Message);
                result = false;
            }
            return result;
        } 
  
it returns false, and set the error string to the outer exception "object reference not set to an instance of an object". No more info regarding which object was null, etc
Of course, I can insert and update without trouble.
What could be going?
TIA

Shalex
Site Admin
Posts: 8425
Joined: Thu 14 Aug 2008 12:44

Re: object reference not set to an instance of an object on SubmitChanges()

Post by Shalex » Mon 01 Oct 2018 14:13

1. You are working with an outdated version (4.4.727 09-Apr-15): https://www.devart.com/linqconnect/revi ... story.html. Please upgrade to the newest one (or check the functionality of a public trial).

2. Iterate through the Errors collection of your datacontext: https://www.devart.com/linqconnect/docs ... rrors.html. Is there any additional information?

If this doesn't help, upload a simple test project for reproducing with the corresponding DDL/DML script to some file exchange server and send us a download link.

-marcelo-
Posts: 26
Joined: Wed 28 Jun 2017 12:35

Re: object reference not set to an instance of an object on SubmitChanges()

Post by -marcelo- » Thu 11 Oct 2018 15:28

Some days after, I got another annoying exception when updating an entity instance. It was
InnerException: System.InvalidOperationException
_HResult=-2146233079
_message=Notification from untracked entity received
HResult=-2146233079
IsTransient=false
Message=Notification from untracked entity received
Source=Devart.Data.Linq
StackTrace:
en Devart.Data.Linq.Engine.c4.b(Object A_0, PropertyChangingEventArgs A_1)
en PackingSecurityContext.Clerk.SendPropertyChanging() en e:\PackingHouse\PackingSecurity\PackingSecurity\Clerk.Generated.cs:línea 259
en PackingSecurityContext.Clerk.set_Nick(String value) en e:\PackingHouse\PackingSecurity\PackingSecurity\Clerk.Generated.cs:línea 114
Of course, the instance was tracked, because I always get them through a query or after an InsertOnSumbit().
Is this a question with my outdated version?
I just renewed my license to get the new versions. I´d expect these strange errors are gone.

Shalex
Site Admin
Posts: 8425
Joined: Thu 14 Aug 2008 12:44

Re: object reference not set to an instance of an object on SubmitChanges()

Post by Shalex » Tue 16 Oct 2018 07:59

-marcelo- wrote:I just renewed my license to get the new versions. I´d expect these strange errors are gone.
Please confirm that the errors are gone after the upgrade.

Post Reply