错误创建控制VS2010母版 [英] Error Creating Control vs2010 MasterPage
问题描述
有人能解释这个问题?
错误创建控制 - 头
对象引用未设置到对象的实例。
<%@页标题=LANGUAGE =C#的MasterPageFile =〜/控制/ Master1.Master
AutoEventWireup =真codeBehind =GrupoUsuario.aspx.cs继承=GrupoUsuario%GT;< ASP:内容ID =内容1=服务器contentplaceholderid =头>
< / ASP:内容>
我觉得这是Visual Studio 2010中的设计视图中的错误。 I'not使用任何事件的操纵会话对象中的方法OnInt()。在PlaceHolderTopo是在web用户控件Topo.ascx的占位符。它的工作normaly。我没有内容占位内的任何code页面塔从母版页继承并得到这个错误。
下面是母版的code:
<%@主语言=C#AutoEventWireup =真codeBehind =PrincipalSeguranca.Master.cs继承=PrincipalSeguranca%GT;
<%@注册SRC =Topo.ascx变量名=地形标签preFIX =UC1%GT;
<%@注册SRC =MenuAdmin.ascx变量名=MenuAdmin标签preFIX =UC2%GT;
<%@注册SRC =Rodape.ascx变量名=Rodape标签preFIX =UC3%GT;!< DOCTYPE HTML PUBLIC - // W3C // DTD XHTML 1.0过渡// ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">< HTML的xmlns =http://www.w3.org/1999/xhtml>
<头=服务器>
<标题>&Sistema的LT; /标题>
< SCRIPT LANGUAGE =JScript的TYPE =文/ JavaScript的SRC =脚本/ Geral.js>< / SCRIPT>
<链接rel =快捷方式图标的href =../布局/ ICO / favicon.ico的TYPE =图像/ X-图标/>
<链接rel =stylesheet属性HREF =../布局/ CSS / Styles.css中类型=文/ CSS/>
<链接的href =../布局/ CSS / menu_tabbed.css的rel =stylesheet属性类型=文/ CSS/>
<链接rel =stylesheet属性HREF =../布局/ CSS / contents.css类型=文/ CSS/>
< /头><身体GT; <表ID =form1的ClientInstanceName =form1的=服务器>
< UC1:地形ID =Topo1=服务器/>
< DIV ID =CORPO>
< ASP:的ContentPlaceHolder ID =头=服务器>
< / ASP:&的ContentPlaceHolder GT;
< / DIV>
< DIV ID =rodape>
< UC3:Rodape ID =Rodape1=服务器/>
< / DIV>
< /表及GT;
< /身体GT;
< / HTML>
您必须在设计时你的 Rodape
控件中的错误。
当您在设计视图中打开网页,它会在Visual Studio的过程中您的自定义控件的一个实例。因为您的网站实际上并没有运行,则在控制code可能是其访问尚未初始化一些静态成员。
您应该对所有的调试菜单例外推出的Visual Studio的第二个副本,其调试器附加到的第一个副本,设置断点,并找到自己的错误。
Someone can explain this error?
Error Creating Control - head Object reference not set to an instance of an object.
<%@ Page Title="" Language="C#" MasterPageFile="~/Controls/Master1.Master"
AutoEventWireup="true" CodeBehind="GrupoUsuario.aspx.cs" Inherits="GrupoUsuario" %>
<asp:Content ID="Content1" runat="server" contentplaceholderid="head">
</asp:Content>
I Think this is a bug of visual studio 2010 in design view. I'not using any event to manipulate session object in the method OnInt(). The "PlaceHolderTopo" is an placeholder in the web user control Topo.ascx. It's work normaly. I Don't have any code inside the content place holder in the page tha inherits from the master page and get this error.
Below is the code of the masterpage:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="PrincipalSeguranca.Master.cs" Inherits="PrincipalSeguranca" %>
<%@ Register Src="Topo.ascx" TagName="Topo" TagPrefix="uc1" %>
<%@ Register src="MenuAdmin.ascx" TagName="MenuAdmin" TagPrefix="uc2" %>
<%@ Register src="Rodape.ascx" tagname="Rodape" tagprefix="uc3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Sistema</title>
<script language="jscript" type="text/javascript" src="Scripts/Geral.js"></script>
<link rel="shortcut icon" href="../layout/ico/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="../layout/css/styles.css" type="text/css" />
<link href="../layout/css/menu_tabbed.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="../layout/css/contents.css" type="text/css" />
</head>
<body>
<form id="form1" ClientInstanceName="form1" runat="server">
<uc1:Topo ID="Topo1" runat="server" />
<div id="corpo">
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</div>
<div id="rodape">
<uc3:Rodape ID="Rodape1" runat="server" />
</div>
</form>
</body>
</html>
You have a bug in your Rodape
control at design time.
When you open your page in Design view, it creates an instance of your custom control in Visual Studio's process. Since your website is not actually running, the code in your control is probably accessing some static member which hasn't been initialized.
You should launch a second copy of Visual Studio, attach its debugger to the first copy, set Break on All Exceptions from the Debug menu, and find your bug.
这篇关于错误创建控制VS2010母版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!