读书人

:打开自己开发的页面出了个错

发布时间: 2012-03-20 14:01:11 作者: rapoo

求助:打开自己开发的页面出了个错
错误代码:
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Source Error:


[No relevant source lines]


Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\34979e7d\6062e188\App_Web_hello-world.aspx_-1369996375.chl_0aud.0.cs Line: 0

Stack Trace:


[SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.PermissionSet.Demand() +83
System.Data.Common.DbConnectionOptions.DemandPermission() +40
System.Data.SqlClient.SqlConnection.PermissionDemand() +44
System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection) +20
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +117
System.Data.SqlClient.SqlConnection.Open() +122
hallo_world._Default.connectSQL() +71
hallo_world._Default.Page_Load(Object sender, EventArgs e) +964
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6785
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +242
System.Web.UI.Page.ProcessRequest() +80
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.HELLO_WORLD_ASPX__1369996375.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\34979e7d\6062e188\App_Web_hello-world.aspx_-1369996375.chl_0aud.0.cs:0
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75


之前发布的这张页面没有出错,数据库连接也没出问题,后来忘记做了一步什么就出现了unexpected error,这是改了webconfig以后看到的错误信息.

之前有在sql里把原先用的database给rename了一下,是不是这个原因

[解决办法]
默认MOSS里的自定义代码是没有访问数据库的权限的.
解决方案:
1)用Web app项目而不是web site,然后把dll部署到GAC
2)修改web.config中的<trust level="Full"/>

读书人网 >行业软件

热点推荐