我做了一个ASP.NET WEB应用程序,项目名是 montest ,作了一个用户控件 head.ascx ,和一个页面 index.aspx .将head.ascx 嵌入 index.aspxhead.ascx 头代码:
<%@ Control Language="c#" AutoEventWireup="false" Codebehind="head.ascx.cs" Inherits="montest.head" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
index.aspx 代码为:<%@ Page language="c#" Codebehind="index.aspx.cs" AutoEventWireup="false" %>
<%@ Register TagPrefix="sc" TagName="head" Src="head.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>index</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<sc:head id="head" runat="server"></sc:head>
</form>
</body>
</HTML>
本地运行没错,把整个项目上传到网上空间,运行就报错:分析器错误信息: 未能加载类型“montest.head”。源错误: 
行 1:  <%@ Control Language="c#" AutoEventWireup="false" Codebehind="head.ascx.cs" Inherits="montest.head" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%> 源文件: wwwroot\montest\head.ascx    行: 1 请各位高手指点,谢谢!

解决方案 »

  1.   

    bin目录上传没有,上传DLL的时候如果已经存在要覆盖上传
      

  2.   

    what is in head.ascx.cs? do you have montest.head class in it? make sure the case matches too, since C# is case-sensitive
      

  3.   

    head.ascx.cs  代码 仅仅包含一个按钮单击事件:namespace montest
    {
    using System;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls; /// <summary>
    /// head 的摘要说明。
    /// </summary>
    public class head : System.Web.UI.UserControl
    {
    protected System.Web.UI.WebControls.Button Button1;
    protected System.Web.UI.WebControls.Label Label1; private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    } #region Web 窗体设计器生成的代码
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器
    /// 修改此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    this.Button1.Click += new System.EventHandler(this.Button1_Click);
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion private void Button1_Click(object sender, System.EventArgs e)
    {
    this.Label1.Text = "The button is down! ";
    }
    }
    }
      

  4.   

    try to change CodeBehind to src (don't do this in production, use it here for a test), for examplehead.ascx
    <%@ Control Language="c#" AutoEventWireup="false" src="head.ascx.cs" Inherits="montest.head" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
    <asp:Button id="Button1" runat="server" />
    <asp:Label id="Label1" runat="server" />if it works, it means head.ascx.cs is not part of the project or you can use ILDASM.exe to check if montest.head is in the assembly
      

  5.   

    问题解决 head.ascx.cs is not part of the project  感谢各位,特别是  saucer(思归) 大侠