VS.net 2003中的可怕错误 - 请确认 [英] Horrible bug in VS.net 2003 - please confirm

查看:48
本文介绍了VS.net 2003中的可怕错误 - 请确认的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请有人确认这不仅仅是我的系统出现此错误...

问题是VS.net无法正确存储大''long''值对于

控制属性..我猜测它的阈值实际上是否比
大于int.MaxValue。


重现步骤:


1.创建Windows控件库项目

2.创建一个新控件

3。添加一个''受保护的长'会员

4.为会员添加一个''public long''获取/设置访问者(让get

返回值,并将该值赋给成员)

5.创建一个Windows窗体项目(然后构建解决方案)

6.将控件添加到窗体

7.将控件上的属性设置为较大的长值

8.运行(确定一切正常)

9.查看属性时控制,价值不保留

亲perly。


我使用的大长值是632890064081923187.这实际上是我系统的

DateTime.UtcNow.Ticks值。虽然我正在编写与DateTime一起使用的

控件,但我也希望能够将它用于

任何长值,而不仅仅是DateTimes。我这样说是因为我有一种感觉

如果我使用DateTimes这个问题就不会显现出来。


你可以看到可能是什么发生在Windows窗体的InitializeComponent

类中...在我的系统上生成代码:


this.control1.LongValue =((long) (632890064081923187));


现在我不是百分百肯定,但在我看来,数值可能是

被解释为在它被投射到很长时间之前。


仅供参考我在VS 2005中没有尝试过这个,但这并不重要因为我需要

使用VS 2003.


任何人都可以确认这不仅仅是我的系统吗?有没有人知道

修复此问题?


谢谢!


-mdb

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

推荐答案

Michael Bray< mbray @ makedintodot_ctiusadcomwrote:
Michael Bray <mbray@makedintodot_ctiusadcomwrote:

>

this.control1.LongValue =((long)(632890064081923187));
>
this.control1.LongValue = ((long)(632890064081923187));



怎么样


this.control1.LongValue = 632890064081923187L;

-

Thomas T. Veldhouse

主要指纹:2DB9 813F F510 82C2 E1AE 34D0 D69D 1EDC D5EC AED1

What about:

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


琐碎无效。我不想在我的

构造函数或其他东西中设置它...并且在

中进行此更改初始化组件只会在我制作任何内容时被覆盖变化。

也许即使我重新编译。记住我正在谈论的代码是VS.net自动生成的代码。


-mdb

" Thomas T. Veldhouse" < ve ***** @ yahoo.com写道

新闻:rJ ************************** ****@giganews.com:
Trivial and ineffective. I don''t want to have to set this in my
constructor or something... and making this change in the
InitializeComponent 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******************************@giganews.com :

Michael Bray< mbray @ makedintodot_ctiusadcomwrote:
Michael Bray <mbray@makedintodot_ctiusadcomwrote:

> ;>
this.control1.LongValue =((长)(632890064081923187));
>>
this.control1.LongValue = ((long)(632890064081923187));



怎么样


this.control1.LongValue = 632890064081923187L;


What about:

this.control1.LongValue = 632890064081923187L;


Michael Bray< mbray @ makedintodot_ctiusadcomwrote:
Michael Bray <mbray@makedintodot_ctiusadcomwrote:

琐碎且无效。我不想在我的

构造函数或其他东西中设置它...并且在

中进行此更改初始化组件只会在我制作任何内容时被覆盖变化。

也许即使我重新编译。记住我正在谈论的代码是VS.net自动生成的代码。
Trivial and ineffective. I don''t want to have to set this in my
constructor or something... and making this change in the
InitializeComponent 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.



什么?我说你的语法错了:


使用:


this.control1.LongValue = 632890064081923187L;


而不是:


this.control1.LongValue =((long)(632890064081923187));


-

Thomas T. Veldhouse

主要指纹:2DB9 813F F510 82C2 E1AE 34D0 D69D 1EDC D5EC AED1

What? I am indicating your syntax was wrong:

use:

this.control1.LongValue = 632890064081923187L;

instead of:

this.control1.LongValue = ((long)(632890064081923187));

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


这篇关于VS.net 2003中的可怕错误 - 请确认的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆