This is a very frustrating and bizarre issue and I would appreciate any advice on how to resolve it.
I have an object with a private variable:
private DateTime _maturityDate = DateTime.MaxValue;
It has a corresponding property:
public DateTime MaturityDate { get; set; }
I have a method which updates the data in the database called UpdateInstrumentBase(). The property is set from a DateTimePicker control on a Windows form. It is set via code, not via data binding:
((Instrument)instrumentBS.DataSource).MaturityDate = dateTimePicker9.Value;
This correctly sets the value:
(I can't post images so you will have to trust me that it does)
However - and this is the truly bizarre problem - when you step INSIDE the object, this is what the property is set to. Even trying to output it in the immediate window or by using a console.writeline results in the following:
? _maturityDate {System.DateTime} Date: Cannot evaluate expression because a thread is stopped at a point where garbage collection is impossible, possibly because the code is optimized.
I've tried passing the date value in as a string, then converting to DateTime as a workaround but any access to ANY DateTime property or variable - not just this one - inside this object results in this error. I've searched high and low but I'm not even sure if this error message is relevant or useful.
I'm using .NET Framework 3.5 SP1 in Visual Studio 2008 version 9.0.21022.8 if that's relevant.
I'm stumped. The object is quite complex so I'm hesitant to post the entire thing, but if anyone has any ideas I will post the relevant code.
Huge and gracious thanks in advance!