This is a very unpleasant and bizarre problem, and I would appreciate any advice on how to fix it.
I have an object with a private variable:
private DateTime _maturityDate = DateTime.MaxValue;
It has the corresponding property:
public DateTime MaturityDate { get; set; }
I have a method that updates data in a database called UpdateInstrumentBase (). The property is set from the DateTimePicker control on a Windows form. It is installed through code, not through data binding:
((Instrument)instrumentBS.DataSource).MaturityDate = dateTimePicker9.Value;
This sets the value correctly:
(I cannot send images, so you have to trust me that it is)
However - and this is a really strange problem - when you insert an INSIDE object, this property is set. Even trying to display it in the nearest window or using console.writeline, you will get the following:
? _maturityDate {System.DateTime} Date: The expression cannot be evaluated because the thread stopped at the point where garbage collection is not possible, possibly because the code is optimized.
I tried to pass the date value as a string and then converted to DateTime as a workaround, but any access to ANY properties or the DateTime variable - not just this one - inside this object leads to this error. I searched high and low, but I'm not even sure if this error message is relevant or useful.
I am using the .NET Framework 3.5 SP1 in Visual Studio 2008 version 9.0.21022.8, if necessary.
I'm at a dead end. The object is quite complex, so I hesitate to publish everything, but if anyone has ideas, I will publish the corresponding code.
Thank you so much in advance!