Reference to an object magically disaprears? STRANGE

117 views Asked by At

EDIT: Okay, found the answer. Problem was in constructor creating objects that were subject to this bug. It should be doing a deep copy of a prototype object, but in one place was doing copy of references in an array instead of copying whole elements to newly created object.


In my C# application I have a Parallel.For loop. In this loop I am creating some object, and calling some method on it. Every loop iteration has its own objects, so it is not a problem with one iteration destroying (somehow) object so other iteration can't use it.

I get sometimes (in some not-first iteration of loop) an exception telling one field of my object is null. BUT, when setting debugger on line throwing this exception in Visual Studio C# 2010 when I hover mouse over line (pic rel)

EnvManager MyEnv = Owner.EnvManager;

debugger says that Owner.EnvManager object is OK (not null).

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

DEBUGGER IS STOPPED ON EXCEPTION THROWING LINE WHOLE TIME, I AM NOT MOVING PROGRAM EXECUTION WHILE CHECKING IT.

Just one question: HOW?

pic showing the problem

0

There are 0 answers