473,626 Members | 3,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Horrible bug in VS.net 2003 - please confirm

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 632890064081923 187. 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 InitializeCompo nent
class of the windows form... on my system it generates the code:

this.control1.L ongValue = ((long)(6328900 64081923187));

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
Jul 20 '06 #1
14 1243
Michael Bray <mbray@makedint odot_ctiusadcom wrote:
>
this.control1.L ongValue = ((long)(6328900 64081923187));
What about:

this.control1.L ongValue = 632890064081923 187L;
--
Thomas T. Veldhouse
Key Fingerprint: 2DB9 813F F510 82C2 E1AE 34D0 D69D 1EDC D5EC AED1

Jul 20 '06 #2
Trivial and ineffective. I don't want to have to set this in my
constructor or something... and making this change in the
InitializeCompo nent will only be overwritten when I make any changes.
Maybe even when I recompile. Remember the code I'm talking about is the
auto-generated code made by VS.net.

-mdb

"Thomas T. Veldhouse" <ve*****@yahoo. comwrote in
news:rJ******** *************** *******@giganew s.com:
Michael Bray <mbray@makedint odot_ctiusadcom wrote:
>>
this.control1. LongValue = ((long)(6328900 64081923187));

What about:

this.control1.L ongValue = 632890064081923 187L;
Jul 20 '06 #3
Michael Bray <mbray@makedint odot_ctiusadcom wrote:
Trivial and ineffective. I don't want to have to set this in my
constructor or something... and making this change in the
InitializeCompo nent will only be overwritten when I make any changes.
Maybe even when I recompile. Remember the code I'm talking about is the
auto-generated code made by VS.net.
What? I am indicating your syntax was wrong:

use:

this.control1.L ongValue = 632890064081923 187L;

instead of:

this.control1.L ongValue = ((long)(6328900 64081923187));

--
Thomas T. Veldhouse
Key Fingerprint: 2DB9 813F F510 82C2 E1AE 34D0 D69D 1EDC D5EC AED1

Jul 20 '06 #4
Michael Bray <mbray@makedint odot_ctiusadcom wrote:
Trivial and ineffective. I don't want to have to set this in my
constructor or something... and making this change in the
InitializeCompo nent will only be overwritten when I make any changes.
Maybe even when I recompile. Remember the code I'm talking about is the
auto-generated code made by VS.net.
Ignore my last post, I didn't realize your long value is actually your system
clock ticks.

--
Thomas T. Veldhouse
Key Fingerprint: 2DB9 813F F510 82C2 E1AE 34D0 D69D 1EDC D5EC AED1

Jul 20 '06 #5
I'll ignore it, but not because it's system clock ticks. I'll ignore it
because I didn't write that code - it is auto-generated by VS.net. :)

-mdb

"Thomas T. Veldhouse" <ve*****@yahoo. comwrote in
news:L6******** *************** *******@giganew s.com:
Michael Bray <mbray@makedint odot_ctiusadcom wrote:
>Trivial and ineffective. I don't want to have to set this in my
constructor or something... and making this change in the
InitializeComp onent will only be overwritten when I make any changes.
Maybe even when I recompile. Remember the code I'm talking about is
the auto-generated code made by VS.net.

Ignore my last post, I didn't realize your long value is actually your
system clock ticks.
Jul 20 '06 #6

Michael Bray wrote:
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.
<snip>
You can kind of see what might be happening in the InitializeCompo nent
class of the windows form... on my system it generates the code:

this.control1.L ongValue = ((long)(6328900 64081923187));

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.
Always test before posting! <Evil grin>

I tried exactly what you suggested, and my VS2003 Designer generates
exactly the same code.

However, I also dropped a TextBox on my UserControl and had it display
the contents of the private field; the text box showed
632890064081923 187, exactly as it should have.

I'll leave it to someone who understands the dark interior workings of
C# to explain why the above code results in a long literal, not an int
literal. Nonetheless, it appears to cause no problems: everything works
out the way you would expect (expect at the macro level, that is).

Jul 20 '06 #7
Michael Bray <mbray@makedint odot_ctiusadcom wrote:
I'll ignore it, but not because it's system clock ticks. I'll ignore it
because I didn't write that code - it is auto-generated by VS.net. :)
In which case I would report it and indicate its "horriblene ss" when you do
;-)

--
Thomas T. Veldhouse
Key Fingerprint: 2DB9 813F F510 82C2 E1AE 34D0 D69D 1EDC D5EC AED1

Jul 20 '06 #8
"Bruce Wood" <br*******@cana da.comwrote in
news:11******** **************@ m79g2000cwm.goo glegroups.com:
Always test before posting! <Evil grin>

I tried exactly what you suggested, and my VS2003 Designer generates
exactly the same code.

However, I also dropped a TextBox on my UserControl and had it display
the contents of the private field; the text box showed
632890064081923 187, exactly as it should have.

I'll leave it to someone who understands the dark interior workings of
C# to explain why the above code results in a long literal, not an int
literal. Nonetheless, it appears to cause no problems: everything
works out the way you would expect (expect at the macro level, that
is).

Oh man I've been testing for hours... I see the problem every time. Let
me give more details...

On my usercontrol, I paint the value in the OnPaint. Sometimes, even
though the 'bad' value shows up in the designer where the control is on the
form, when I run the form it shows the correct value.

But then, if I change some things around in the control, such as the
location or size of the control, then the value sticks to the bad value and
that's what I see when I run the form.

The critical part for me is that after I've dropped the control on the
form, and then I run the program (and the control paints the correct
value), when I look at the value in the designer next, it has the 'bad'
value. Did you look at the designer value or just the value in the
textBox? Did you play with the control at all? I would guess that if you
play for a bit then it will show.

I'll even make a video of it happening and I can show you... I'll post code
even. I'll make another post when they are ready.

-mdb
Jul 20 '06 #9
Michael Bray <mbray@makeDInt oDot_ctiusaDcom wrote in
news:Xn******** *************** *****@207.46.24 8.16:
I'll even make a video of it happening and I can show you... I'll post
code even. I'll make another post when they are ready.
OK... I made a screen-cap movie of what's happening. You can download the
movie (22MB) and the source code (a few K) with the following links:

http://users.ctinet.net/mbray/BadControlMovie.zip
http://users.ctinet.net/mbray/DumbTest.zip

Extract DumbTest.zip to a directory, and open the solution file in DumbTest
subFolder. Use the movie to see exactly what I am doing.

-mdb
Jul 20 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

140
7814
by: Oliver Brausch | last post by:
Hello, have you ever heard about this MS-visual c compiler bug? look at the small prog: static int x=0; int bit32() { return ++x; }
9
2296
by: Marc Miller | last post by:
Hi all, I have 2 dev. machines, the 1st is Win 2000 with .NET 7.0 and the 2nd is XP Pro with .NET 2003. My Web Server is Win 2000 Server with IIS 5.0. I can create a new project on my test server from the 1st machine, but I receive an 'HTTP/1.1 500 Internal Server error" from my Web Server. My userid/password are the same on all 3 machines.
2
5276
by: Praveen | last post by:
Hi All, I have made a webservice in C# and it works fine in my machine. I ran into a crazy problem when I wanted to deploy it in windows 2003 server. I have run "aspnet_regiis.exe -i" to make sure that the extensions for .asmx file etc are in place. I am getting http 404 when I give the url for the asmx file. the http error code is wrong because I am dead sure that the file is there. could you please let me know what else needs to be...
10
3350
by: JonathanOrlev | last post by:
Hello everybody, I wrote this comment in another message of mine, but decided to post it again as a standalone message. I think that Microsoft's Office 2003 help system is horrible, probably the worst I ever seen. I almost cannot find anything I need, including things I
0
8268
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8707
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8641
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8366
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8510
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4202
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1812
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.