ASP。Net错误类型与控件的类型不兼容

时间:2022-02-28 15:37:34

I have a web site i created using VS2012 web edition,

我有一个网站是我用VS2012版本创建的,

Running a VB.net asp web site,

运行一个VB.net asp网站,

In the VS2012 debug/release mode it compiles and everything works good, When i upload it to a server (Windows server 2008 R2) I get the following error:

在VS2012调试/发布模式下,它会编译,并且一切都运行良好,当我将它上传到服务器(Windows server 2008 R2)时,我得到以下错误:

The base class includes the field 'html', but its type (System.Web.UI.HtmlControls.HtmlElement) is not compatible with the type of control (System.Web.UI.HtmlControls.HtmlGenericControl).


Line 2:  
Line 3:  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Line 4:  <html id="html" xmlns="http://www.w3.org/1999/xhtml" dir="ltr" runat="server">
Line 5:  <head id="Head1" runat="server">
Line 6:    <title></title>

I looked a bit on the web and found this : VS 2010: Value of type 'System.Web.UI.HtmlControls.HtmlGenericControl' cannot be converted to 'System.Web.UI.HtmlControls.HtmlTableRow'

我在网上查了一下,发现:VS 2010: System.Web.UI.HtmlControls类型的值。不能将HtmlGenericControl转换为System.Web.UI.HtmlControls.HtmlTableRow'

Installed it but no help,

安装了但没有帮助,

The site i created was re-created from another vb.net project so i used a web.config with from the old one, maybe it has something to do with it, i have no "assembly" properties it this XML.

我创建的站点是从另一个vb.net项目重新创建的,所以我使用了web。用旧的配置,可能和它有关,我没有这个XML的“汇编”属性。

Other pages that are not related to that master page (that html tag is running on a master page...) work's fine.

其他与主页面不相关的页面(html标记在主页面上运行…)可以正常工作。

3 个解决方案

#1


6  

OK,

好吧,

So after trying a lot of stuff that didnt work i found a solution, i dont like this solution but it works,

所以在尝试了很多没用的东西之后我找到了一个解决方案,我不喜欢这个解决方案,但它确实有效,

I went to the page.designer.vb file, and then looked for the 'html' and 'Head1' properties that were generated there,

我找到page.designer.vb文件,然后查找生成的html和Head1属性,

In there i replaced their types to System.Web.UI.HtmlControls.HtmlGenericControl

在那里,我将它们的类型替换为System.Web.UI.HtmlControls.HtmlGenericControl

Afterwards, it worked.

后来,它工作。

Weird bug, nothing else (including the "hot fixes" that are mentioned in other posts helped.

奇怪的bug,没有其他东西(包括在其他帖子中提到的“热补丁”帮助了)。

Hope this would help some one out there .

希望这能帮助一些人。

#2


0  

Somehow the designer file and the markup file get out of sync, even if the types appear to match.

无论如何,设计器文件和标记文件会失去同步,即使类型看起来匹配。

I changed the ID attribute of the problematic control, saved, and rebuilt in the markup file. I then changed it back to the original ID, saved, and rebuilt.

我更改了问题控件的ID属性,保存并在标记文件中重新构建。然后我将它更改为原来的ID,保存并重建。

Problem goes away!

问题消失了!

#3


0  

Weird issue it is I am not sure if there is a proper solution for this but what worked for me was simply changing the Control ID. and then designer.cs file was changed and all worked good.

奇怪的是,我不确定是否有合适的解决方案,但我的工作只是改变控制,然后设计。cs文件被修改,一切运行良好。

#1


6  

OK,

好吧,

So after trying a lot of stuff that didnt work i found a solution, i dont like this solution but it works,

所以在尝试了很多没用的东西之后我找到了一个解决方案,我不喜欢这个解决方案,但它确实有效,

I went to the page.designer.vb file, and then looked for the 'html' and 'Head1' properties that were generated there,

我找到page.designer.vb文件,然后查找生成的html和Head1属性,

In there i replaced their types to System.Web.UI.HtmlControls.HtmlGenericControl

在那里,我将它们的类型替换为System.Web.UI.HtmlControls.HtmlGenericControl

Afterwards, it worked.

后来,它工作。

Weird bug, nothing else (including the "hot fixes" that are mentioned in other posts helped.

奇怪的bug,没有其他东西(包括在其他帖子中提到的“热补丁”帮助了)。

Hope this would help some one out there .

希望这能帮助一些人。

#2


0  

Somehow the designer file and the markup file get out of sync, even if the types appear to match.

无论如何,设计器文件和标记文件会失去同步,即使类型看起来匹配。

I changed the ID attribute of the problematic control, saved, and rebuilt in the markup file. I then changed it back to the original ID, saved, and rebuilt.

我更改了问题控件的ID属性,保存并在标记文件中重新构建。然后我将它更改为原来的ID,保存并重建。

Problem goes away!

问题消失了!

#3


0  

Weird issue it is I am not sure if there is a proper solution for this but what worked for me was simply changing the Control ID. and then designer.cs file was changed and all worked good.

奇怪的是,我不确定是否有合适的解决方案,但我的工作只是改变控制,然后设计。cs文件被修改,一切运行良好。