读书人

ASP.Net网站中使用指针出现的异常求

发布时间: 2013-07-04 11:45:55 作者: rapoo

ASP.Net网站中使用指针出现的错误,求大神帮忙,具体问题如下
在网站中运行指针要在配置文件中加一下代码:
<system.codedom>

<compilers>

<!--允许运行不安全代码-->

<compiler language = "c#;cs;csharp" warningLevel="4" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" compilerOptions="/unsafe+" />

</compilers>

</system.codedom>
项目在本地运行正常,编译通过,而且指针的功能也能实现,但上传到网上后就报这个错误:
编译器警告消息: 警告: CS0108: “ASP.master1_master.Profile”隐藏了继承的成员“master1.Profile”。如果是有意隐藏,请使用关键字 new。

我们这个产品正在给用户试用,本来答应用户给做这个功能的,结果成这样。。。
有经验的帮忙看看!


[解决办法]
一般是用户权限问题,但也有例外的转折方法可以试一下,把涉及权限的代码交由HttpModule去执行

例如,我们webForm在aspx页面中没有权限获取到服务器硬件信息,但交由HttpModule后就可以执行

<httpModules>
<add type="Galsun.HH.FCX.Web.UI.HttpModule, Galsun.HH.FCX.Web.UI" name="HttpModule"/>
</httpModules>


using System;
using System.IO;
using System.Text.RegularExpressions;
using System.Threading;
using System.Web;
using System.Xml;
using Galsun.Common;
using Galsun.HH.FCX.Content;
using Galsun.HH.FCX.Mode;
using System.Data;
using System.Management;


namespace Galsun.HH.FCX.Web.UI
{
public class HttpModule : System.Web.IHttpModule
{
/// <summary>
/// 实现接口的Init方法
/// </summary>
/// <param name="context"></param>
public void Init(HttpApplication context)
{
GetHardID();
}
/// <summary>
/// 获取硬盘ID
/// </summary>
/// <returns>硬盘ID</returns>
public static string GetHardID()
{

string HDInfo = "";

ManagementClass cimobject1 = new ManagementClass("Win32_DiskDrive");
ManagementClass cimobject2 = new ManagementClass("Win32_Processor");
try
{



ManagementObjectCollection moc1 = cimobject1.GetInstances();

foreach (ManagementObject mo in moc1)
{

HDInfo += (string)mo.Properties["Model"].Value;
break;
}
ManagementObjectCollection moc2 = cimobject2.GetInstances();

foreach (ManagementObject mo in moc2)
{

HDInfo += (string)mo.Properties["Processorid"].Value;
break;
}
}
catch (Exception err)
{
HDInfo = err.ToString();
}
if (System.Web.HttpContext.Current.Application["HDInfo"] == null)
{
System.Web.HttpContext.Current.Application.Lock();
System.Web.HttpContext.Current.Application["HDInfo"] = HDInfo;
System.Web.HttpContext.Current.Application.UnLock();
}
return HDInfo;

}

public void Application_OnError(Object sender, EventArgs e)
{
HttpApplication application = (HttpApplication)sender;
HttpContext context = application.Context;
//if (context.Server.GetLastError().GetBaseException() is MyException)
{
//MyException ex = (MyException) context.Server.GetLastError().GetBaseException();


context.Response.Write("<html><body style=\"font-size:14px;\">");
context.Response.Write("GL.CMS Error:<br />");
context.Response.Write("<textarea name=\"errormessage\" style=\"width:80%; height:200px; word-break:break-all\">");
context.Response.Write(System.Web.HttpUtility.HtmlEncode(context.Server.GetLastError().ToString()));
context.Response.Write("</textarea>");
context.Response.Write("</body></html>");
context.Response.End();
}

}


/// <summary>
/// 实现接口的Dispose方法
/// </summary>
public void Dispose()
{

}
}
}

读书人网 >asp.net

热点推荐