VS2003转VS2005转换 [英] VS2003 to VS2005 Conversion

查看:79
本文介绍了VS2003转VS2005转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在将VS 2003项目转换为VS 2005项目(VB.NET类库)。



它给出了TypeOf和DirectCast语句中的错误。它在VS2003下完美运行。



公共共享子清除(ByVal ctl As HtmlControls.HtmlControl)


如果TypeOf ctl是DropDownList那么


DirectCast(ctl,DropDownList).Items.Clear()


结束如果
< br $>
End Sub



1)错误是''System.Web.UI.HtmlControls.HtmlControl''类型的表达式永远不能是类型''System.Web.UI.WebControls.DropDownList''。


2)类型''System.Web.UI.HtmlControls.HtmlControl''的值不能转换为''System.Web.UI.WebControls.DropDownList''



如何避免这些错误,我尝试更改Option Strict选项关闭。我无法更改代码,因为TypeOf和DirectCast语句在200多个地方使用。



谢谢&此致,


Sam


Hi All,



I am in the process of converting a VS 2003 project to VS 2005 project (VB.NET Class Library).



It gives the error in TypeOf and DirectCast statements. It was working perfectly under VS2003.



Public Shared Sub Clear(ByVal ctl As HtmlControls.HtmlControl)

If TypeOf ctl Is DropDownList Then

DirectCast(ctl, DropDownList).Items.Clear()

End If

End Sub



1) The error is Expression of type ''System.Web.UI.HtmlControls.HtmlControl'' can never be of type ''System.Web.UI.WebControls.DropDownList''.

2) Value of type ''System.Web.UI.HtmlControls.HtmlControl'' cannot be converted to ''System.Web.UI.WebControls.DropDownList''



How I can avoid these errors, I tried changing the Option Strict option to Off. I cannot change the code because the TypeOf and DirectCast statements are used in more than 200 places.



Thanks & Regards,

Sam



推荐答案

"塞缪尔" < SA **** @ photoninfotech.com> schrieb:
"Samuel" <sa****@photoninfotech.com> schrieb:
我正在将VS 2003项目转换为VS 2005项目(VB.NET类库)。

它给出了错误TypeOf和DirectCast语句。它完全在VS2003下工作。

Public Shared Sub Clear(ByVal ctl As HtmlControls.HtmlControl)
如果TypeOf ctl是DropDownList那么
DirectCast(ctl,DropDownList) ).Items.Clear()
结束如果
结束子

1)错误是表达类型
''System.Web.UI.HtmlControls.HtmlControl ''
永远不能是''System.Web.UI.WebControls.DropDownList''的类型。
I am in the process of converting a VS 2003 project to VS 2005 project
(VB.NET Class Library).

It gives the error in TypeOf and DirectCast statements. It was working
perfectly under VS2003.

Public Shared Sub Clear(ByVal ctl As HtmlControls.HtmlControl)
If TypeOf ctl Is DropDownList Then
DirectCast(ctl, DropDownList).Items.Clear()
End If
End Sub

1) The error is Expression of type
''System.Web.UI.HtmlControls.HtmlControl''
can never be of type ''System.Web.UI.WebControls.DropDownList''.




这是真的。 ''DropDownList''不会继承''HtmlControl'',甚至不会继承.NET 1.1中的
。您可能想使用''WebControls.WebControl''代替

''HtmlControls.HtmlControl''。


-

MS Herfried K. Wagner

MVP< URL:http://dotnet.mvps.org/>

VB< URL:http:// classicvb .org / petition />



Which is true. ''DropDownList'' does not inherit from ''HtmlControl'', not even
in .NET 1.1. You may want to use ''WebControls.WebControl'' instead of
''HtmlControls.HtmlControl''.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


" Samuel" < SA **** @ photoninfotech.com> schrieb
"Samuel" <sa****@photoninfotech.com> schrieb
大家好,

我正在将VS 2003项目转换为VS 2005
项目(VB.NET类库)。

它在TypeOf和DirectCast语句中给出错误。它在VS2003下完美运行。

Public Shared Sub Clear(ByVal ctl As HtmlControls.HtmlControl)

如果TypeOf ctl是DropDownList那么

DirectCast(ctl,DropDownList).Items.Clear()

结束如果

结束子

1)错误是表达式类型
''System.Web.UI.HtmlControls.HtmlControl''永远不能是类型
''System.Web.UI.WebControls.DropDownList''。

2 )'System.Web.UI.HtmlControls.HtmlControl'类型的值不能转换为''System.Web.UI.WebControls.DropDownList''

我怎么能避免这些错误,我尝试将Option Strict
选项更改为Off。我无法更改代码,因为TypeOf和
DirectCast语句在200多个地方使用。
Hi All,

I am in the process of converting a VS 2003 project to VS 2005
project (VB.NET Class Library).

It gives the error in TypeOf and DirectCast statements. It was
working perfectly under VS2003.

Public Shared Sub Clear(ByVal ctl As HtmlControls.HtmlControl)

If TypeOf ctl Is DropDownList Then

DirectCast(ctl, DropDownList).Items.Clear()

End If

End Sub

1) The error is Expression of type
''System.Web.UI.HtmlControls.HtmlControl'' can never be of type
''System.Web.UI.WebControls.DropDownList''.

2) Value of type ''System.Web.UI.HtmlControls.HtmlControl'' cannot
be converted to ''System.Web.UI.WebControls.DropDownList''

How I can avoid these errors, I tried changing the Option Strict
option to Off. I cannot change the code because the TypeOf and
DirectCast statements are used in more than 200 places.




DropDownList不是从HtmlControl派生的,因此你不能投这个

的方式。为什么你认为你可以? HtmlControl没有Items

属性。从HtmlControl派生的类是


System.Web.UI.HtmlControls.HtmlContainerControl

System.Web.UI.HtmlControls.HtmlImage

System.Web.UI.HtmlControls.HtmlInputControl


ctl可以指向其中一个对象,但是/ never /指向DropDownList对象。


Armin



DropDownList is not derived from HtmlControl, thus you can not cast this
way. Why do you think you can? A HtmlControl does not have an Items
property. The classes derived from HtmlControl are

System.Web.UI.HtmlControls.HtmlContainerControl
System.Web.UI.HtmlControls.HtmlImage
System.Web.UI.HtmlControls.HtmlInputControl

ctl can point to one of these objects, but /never/ to a DropDownList object.

Armin


但它在VS2003中运行。是否可以使代码在

VS2005中工作?


" Armin Zingler" < AZ ******* @ freenet.de>在消息中写道

news:%2 **************** @ TK2MSFTNGP09.phx.gbl ...
But it was working in VS2003. Is it possible to make the code to work in
VS2005 ?

"Armin Zingler" <az*******@freenet.de> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
"塞缪尔" < SA **** @ photoninfotech.com> schrieb
"Samuel" <sa****@photoninfotech.com> schrieb
大家好,

我正在将VS 2003项目转换为VS 2005
项目(VB.NET类库)。

它在TypeOf和DirectCast语句中给出错误。它在VS2003下完美运行。

Public Shared Sub Clear(ByVal ctl As HtmlControls.HtmlControl)

如果TypeOf ctl是DropDownList那么

DirectCast(ctl,DropDownList).Items.Clear()

结束如果

结束子

1)错误是表达式类型
''System.Web.UI.HtmlControls.HtmlControl''永远不能是类型
''System.Web.UI.WebControls.DropDownList''。

2 )'System.Web.UI.HtmlControls.HtmlControl'类型的值不能转换为''System.Web.UI.WebControls.DropDownList''

我怎么能避免这些错误,我尝试将Option Strict
选项更改为Off。我无法更改代码,因为TypeOf和
DirectCast语句在200多个地方使用。
Hi All,

I am in the process of converting a VS 2003 project to VS 2005
project (VB.NET Class Library).

It gives the error in TypeOf and DirectCast statements. It was
working perfectly under VS2003.

Public Shared Sub Clear(ByVal ctl As HtmlControls.HtmlControl)

If TypeOf ctl Is DropDownList Then

DirectCast(ctl, DropDownList).Items.Clear()

End If

End Sub

1) The error is Expression of type
''System.Web.UI.HtmlControls.HtmlControl'' can never be of type
''System.Web.UI.WebControls.DropDownList''.

2) Value of type ''System.Web.UI.HtmlControls.HtmlControl'' cannot
be converted to ''System.Web.UI.WebControls.DropDownList''

How I can avoid these errors, I tried changing the Option Strict
option to Off. I cannot change the code because the TypeOf and
DirectCast statements are used in more than 200 places.



DropDownList不是从HtmlControl派生的,因此你无法转换它。方式。为什么你认为你可以? HtmlControl没有Items
属性。从HtmlControl派生的类是

System.Web.UI.HtmlControls.HtmlContainerControl
System.Web.UI.HtmlControls.HtmlImage
System.Web.UI.HtmlControls.HtmlInputControl

ctl可以指向其中一个对象,但是/ never /到一个DropDownList
对象。

Armin



DropDownList is not derived from HtmlControl, thus you can not cast this
way. Why do you think you can? A HtmlControl does not have an Items
property. The classes derived from HtmlControl are

System.Web.UI.HtmlControls.HtmlContainerControl
System.Web.UI.HtmlControls.HtmlImage
System.Web.UI.HtmlControls.HtmlInputControl

ctl can point to one of these objects, but /never/ to a DropDownList
object.

Armin



这篇关于VS2003转VS2005转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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