搞了3天了,请求帮助——CS0246: 找不到类型或命名空间名称“Manager_chkAdmin”
表现:在本地测试成功,
在服务器上出现错误提示:
==============================================================
“编译器错误信息: CS0246: 找不到类型或命名空间名称“Manager_chkAdmin”(是否缺少 using 指令或程序集引用?)
源错误:
行 112: protected void gvArticle_RowEditing(object sender, GridViewEditEventArgs e)
行 113: {
行 114: Manager_chkAdmin mca = (Manager_chkAdmin)this.LoadControl("chkAdmin.ascx");
行 115: mca.IsAdmin = 0;
行 116: mca.AdminPower = this.gvArticle.DataKeys[e.NewEditIndex].Values[1].ToString();
源文件: e:\WebSite\DigisizeSLSys\Manager\Article.aspx.cs 行: 114
”
'================================================
Article.aspx.cs 源代码:
'===============================================
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Manager_Article : System.Web.UI.Page
{
private int columnId = 0;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnAddArticle_Click(object sender, EventArgs e)
{
Manager_chkAdmin mca = (Manager_chkAdmin)this.LoadControl("chkAdmin.ascx");
mca.IsAdmin = 0;
mca.AdminPower = this.ddltColumn.SelectedValue;
mca.IsSite = 0;
this.Controls.Add(mca);
}
}
'=============================================================
chkAdmin.ascx.cs 源代码:
'=============================================================
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Manager_chkAdmin001 : System.Web.UI.UserControl
{
private int isAdmin = 0;
private int isSite = 0;
private string adminPower = "";
public int IsAdmin
{
set
{
this.isAdmin = value;
}
}
public int IsSite
{
set
{
this.isSite = value;
}
}
public string AdminPower
{
set
{
this.adminPower = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
string PowerStr = "";
string ColumnStr = "";
HttpCookie adminInfo = Request.Cookies["adminInfo"];
if (Session["adminId"] == null || Session["adminName"] == null)
{
if (adminInfo["adminId"] != null)
{
Session["adminId"] = adminInfo["adminId"];
Session["adminName"] = adminInfo["adminName"];
}
else
{
Response.Write(WebFunction.alertChk("登陆超时", 1));
Response.End();
}
}
SqlDataReader sdr = WebFunction.dataReader("select setting,ColumnSetting from [Master] where name='" + adminInfo["adminName"].ToString() + "' and Cookies='" + Session["adminId"].ToString() + "'");
if (sdr.Read())
{
PowerStr = sdr[0].ToString();
ColumnStr = sdr[1].ToString();
}
else
{
Response.Redirect("Default.aspx");
}
WebFunction.closeDataReader(ref sdr);
if (this.adminPower != "0")
{
if (isAdmin == 1)
{
if (PowerStr.IndexOf("," + adminPower + ",") < 0)
{
Response.Write(WebFunction.alertChk("权限不足", 0));
Response.End();
}
}
else
{
if (ColumnStr.IndexOf("," + adminPower + ",") < 0)
{
Response.Write(WebFunction.alertChk("权限不足", 0));
Response.End();
}
}
}
if (Application["siteName"] == null || Application["url"] == null)
{
sdr = WebFunction.dataReader("select siteName,url,isLogin,copyRight from [Config]");
if (sdr.Read())
{
Application["siteName"] = sdr[0].ToString();
Application["url"] = sdr[1].ToString();
Application["isLogin"] = sdr[2].ToString();
Application["copy"] = sdr[3].ToString();
}
else
{
Application["siteName"] = "全站管理系统";
Application["url"] = "http://www.abc.com";
Application["isLogin"] = "1";
Application["copy"] = "版权所有";
}
WebFunction.closeDataReader(ref sdr);
}
}
}
'============================================================== --------------------编程问答-------------------- 这个还真是有点麻烦, 看起来要在你的环境下才可以调试出来
--------------------编程问答-------------------- 弱弱的问一下问题, 你是2003呢, 还是2005呢, 是怎么发布程序的
msn smart-human@163.com --------------------编程问答-------------------- 在VS2005下的,没有发布。 --------------------编程问答-------------------- 对了,补充一下
chkAdmin.ascx.cs里面的Manager_chkAdmin001应为Manager_chkAdmin,这个是我尝试更改命名,提问前没改回来,不是错误 --------------------编程问答-------------------- Manager_chkAdmin mca = (Manager_chkAdmin)this.LoadControl("chkAdmin.ascx");
===================================================================
Manager_chkAdmin001 mca = (Manager_chkAdmin001)this.LoadControl("chkAdmin.ascx");
--------------------编程问答-------------------- UserControl 是否前台需要注册
没试过,说错勿怪 --------------------编程问答--------------------
不在同一项目的话,需要引用DLL... --------------------编程问答-------------------- 在服务器上手动注册一下dll文件,如果是03系统,注意不要把dll文件放在桌面上,随便放在一个盘符下 --------------------编程问答-------------------- up一下,,仍未解决,, --------------------编程问答-------------------- 如果服务器是2003的操作系统,你需要把你的组件在服务器上注册一下,而且组件不要放在桌面上,放在比如d盘下,再注册,试试吧 --------------------编程问答--------------------
假如没有发布,
确保所有的文件 .cs 都已经正确的上传 --------------------编程问答-------------------- 把chkAdmin.ascx.cs复制一份到app_code下看看,vs2005对于共有的类似乎只能放到app_code下才能公用样的 --------------------编程问答-------------------- google了一下,还真是app_code惹出来的毛病
参考资料:http://www.cnblogs.com/myzerg/archive/2007/01/05/613009.html --------------------编程问答-------------------- 你用的是Xp么 那你就把网站放到iis的跟目录下 让他成为默认网站就好了 --------------------编程问答-------------------- 确定你的IIS 没有配置错误码? --------------------编程问答-------------------- 我也同样问题,逻辑层BLL是否引用的提示,我也是本地正常,编译上传服务器后,iis发布后浏览就这样,我这还是正常了2年,突然就这样了,确定是添加了引用的,求解
补充:.NET技术 , ASP.NET