Please, someone verify that this isn't just my system with this error...
The problem is that VS.net can't properly store large 'long' values for
control properties.. I'm guessing the threshold is actually if they are
larger than an int.MaxValue.
Steps to reproduce:
1. Create a Windows Control Library project
2. Create a new control
3. Add a 'protected long' member
4. Add a 'public long' get/set accessor for the member (make the get
return the value, and the set assign the value to the member)
5. Create a Windows Forms project (then build the solution)
6. Add the control to the form
7. Set the property on the control to a large long value
8. Run (ok everything works fine)
9. When you view the properties of the control, the value isn't preserved
properly.
The large long value I use is 632890064081923187. This is actually the
DateTime.UtcNow.Ticks value for my system. Although I am writing the
control to be used with DateTime's, I also want to be able to use it for
any long value, not just DateTimes. I say this because I have a feeling
that this problem doesn't manifest itself if I use DateTimes.
You can kind of see what might be happening in the InitializeComponent
class of the windows form... on my system it generates the code:
this.control1.LongValue = ((long)(632890064081923187));
Now I'm not 100% sure, but it seems to me that the numeric value might be
being interpreted as an int before it gets cast to a long.
FYI I haven't tried this with VS 2005, but it doesn't matter because I need
to use VS 2003.
Can anyone confirm that this isn't just my system? Does anyone know of a
fix for this?
Thanks!
-mdb