Is the object reference magically untrue? STRANGE

EDIT: Ok, found the answer. The problem was creating constructor for objects affected by this error. It should make a deep copy of the prototype object, but in one place made a copy of the references in the array instead of copying whole elements to the newly created object. p>


In my C # application, I have a loop Parallel.For

. In this loop, I create some object and call some method on it. Each iteration of the loop has its own objects , so this is not a problem with one iterative destruction (somehow) of an object, so another iteration cannot use it.

Sometimes I get (in some non-first iteration of the loop) an exception indicating one field of my object to be zero. BUT, when installing the debugger on the line throwing this exception in Visual Studio C # 2010 when I hover over the line (pic rel)

EnvManager MyEnv = Owner.EnvManager;

      

The debugger says that the Owner.EnvManager object is fine (not null).

BUT, one line below, when comparing MyEnv (assigned before) to null, it is null!

DEBUGGER STOPPED ON THE EXCEPTION OF A FUEL LINE AT ALL THE TIME, I WILL NOT MISS THE SOFTWARE EXECUTION WHEN CHECKING IT.

Just one question: HOW?

pic showing the problem

+3


source to share





All Articles