大家帮忙看看是不是少了添加某个命名空间?
我在一个网页中添加了一个calendar控件和一个label控件
将calendar命名为calSource将label命名为lblDate 在网页的pageload 事件中添加如下代码lblDate.Text=this.calSource.TodaysDate;
运行一下,出现异常:
“/Calendar”应用程序中的服务器错误。
--------------------------------------------
编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。
编译器错误信息: CS0234: 类型或命名空间名称“Global”在类或命名空间“System.Web.UI.WebControls.Calendar”中不存在(是否缺少程序集引用?)
源错误:
行 26:
行 27: [System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()]
行 28: public class Global_asax : Calendar.Global {
行 29:
行 30: private static bool __initialized = false;
源文件: c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\calendar\89966ca2\25eb6427\cxf2hu2v.0.cs 行: 28
显示详细的编译器输出:
C:\WINDOWS\System32> "c:\windows\microsoft.net\framework\v1.1.4322\csc.exe " /t:library /utf8output /R: "c:\windows\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll " /R: "c:\windows\microsoft.net\framework\v1.1.4322\temporary asp.net files\calendar\89966ca2\25eb6427\assembly\dl2\2aa94027\a83dbe66_2cd7c701\calendar.dll " /R: "c:\windows\assembly\gac\system.web.services\1.0.5000.0__b03f5f7f11d50a3a\system.web.services.dll " /R: "c:\windows\assembly\gac\system.xml\1.0.5000.0__b77a5c561934e089\system.xml.dll " /R: "c:\windows\assembly\gac\system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll " /R: "c:\windows\microsoft.net\framework\v1.1.4322\mscorlib.dll " /R: "c:\windows\assembly\gac\system.web.mobile\1.0.5000.0__b03f5f7f11d50a3a\system.web.mobile.dll " /R: "c:\windows\assembly\gac\system.data\1.0.5000.0__b77a5c561934e089\system.data.dll " /R: "c:\windows\assembly\gac\system.enterpriseservices\1.0.5000.0__b03f5f7f11d50a3a\system.enterpriseservices.dll " /R: "c:\windows\assembly\gac\system.web\1.0.5000.0__b03f5f7f11d50a3a\system.web.dll " /out: "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\calendar\89966ca2\25eb6427\cxf2hu2v.dll " /D:DEBUG /debug+ /optimize- /warnaserror /w:1 "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\calendar\89966ca2\25eb6427\cxf2hu2v.0.cs "
Microsoft (R) Visual C# .NET 编译器版本 7.10.3052.4
用于 Microsoft (R) .NET Framework 版本 1.1.4322
版权所有 (C) Microsoft Corporation 2001-2002。保留所有权利。
c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\calendar\89966ca2\25eb6427\cxf2hu2v.0.cs(28,41): error CS0234: 类型或命名空间名称“Global”在类或命名空间“System.Web.UI.WebControls.Calendar”中不存在(是否缺少程序集引用?)
显示完整的编译源:
行 1: //------------------------------------------
行 2: // <autogenerated>
行 3: // This code was generated by a tool.
行 4: // Runtime Version: 1.1.4322.573
行 5: //
行 6: // Changes to this file may cause incorrect behavior and will be lost if
行 7: // the code is regenerated.
行 8: // </autogenerated>
行 9: //------------------------------------------
行 10:
行 11: namespace ASP {
行 12: using System;
行 13: using System.Collections;
行 14: using System.Collections.Specialized;
行 15: using System.Configuration;
行 16: using System.Text;
行 17: using System.Text.RegularExpressions;
行 18: using System.Web;
行 19: using System.Web.Caching;
行 20: using System.Web.SessionState;
行 21: using System.Web.Security;
行 22: using System.Web.UI;
行 23: using System.Web.UI.WebControls;
行 24: using System.Web.UI.HtmlControls;
行 25:
行 26:
行 27: [System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()]
行 28: public class Global_asax : Calendar.Global {
行 29:
行 30: private static bool __initialized = false;
行 31:
行 32: public Global_asax() {
行 33: if ((ASP.Global_asax.__initialized == false)) {
行 34: ASP.Global_asax.__initialized = true;
行 35: }
行 36: }
行 37: }
行 38: }
行 39:
--------------------------------------------
版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573
谁知道这是什么问题?
相似的问题还出现在另一个网页里
例如:建立网页添加一个panel控件,在panel里设置用户登陆控件。当用户身份正确时,panel的visable变成false显示其他内容。
运行时也是类似异常
谢谢大建
[解决办法]
你的命名空间或者类名起成了 Calendar,和类库的类冲突了,换个名字
[解决办法]
将public class Global_asax : Calendar.Global {
这句后面的Calendar.Global 改成全路径看看行不行
System.Web.UI.WebControls.Calendar.Global
[解决办法]
你的命名空间或者类名起成了 Calendar,和类库的类冲突了,换个名字
同意 amandag(高歌)
private PointF GetFocusScales()
{
PointF point = new PointF();
int width = this.ClientRectangle.Width, height = this.ClientRectangle.Height;
if (width <= 200)
{
point.X = 0.75f;
}
else if (width > 200 && width <= 400)
{
point.X = 0.85f;
}
else if (width > 400 && width <= 800)
{
point.X = 0.92f;
}
else
{
point.X = 0.96f;
}
if (height < 50)
{
point.Y = 0.15f;
}
else if (height > 50 && height <= 100)
{
point.Y = 0.55f;
}
else if (height > 100 && height <= 200)
{
point.Y = 0.75f;
}
else if (height > 200 && height <= 400)
{
point.Y = 0.85f;
}
else if (height > 400)
{
point.Y = 0.92f;
}
return point;
}