VS2003转VS2005转换

编程入门 行业动态 更新时间:2024-10-28 20:27:22
本文介绍了VS2003转VS2005转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我正在将VS 2003项目转换为VS 2005项目(VB.NET类库)。 它给出了TypeOf和DirectCast语句中的错误。它在VS2003下完美运行。 公共共享子清除(ByVal ctl As HtmlControls.HtmlControl) 如果TypeOf ctl是DropDownList那么 DirectCast(ctl,DropDownList).Items.Clear() 结束如果 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> schrieb: "Samuel" <sa****@photoninfotech> 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 workingperfectly under VS2003.Public Shared Sub Clear(ByVal ctl As HtmlControls.HtmlControl) If TypeOf ctl Is DropDownList Then DirectCast(ctl, DropDownList).Items.Clear() End IfEnd Sub1) 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/> VB< URL:http:// classicvb / 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:dotnet.mvps/> V B <URL:classicvb/petition/>

" Samuel" < SA **** @ photoninfotech> schrieb "Samuel" <sa****@photoninfotech> 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> schrieb "Samuel" <sa****@photoninfotech> 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转换

本文发布于:2023-11-09 20:03:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573299.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!