Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
815 views
in Technique[技术] by (71.8m points)

asp.net - The application attempted to perform an operation not allowed by the security policy

I have developed an Asp.net website in Visual Studio 2008 and it worked fine while using Vista OS but my workstation got upgraded to Windows 7 and I now get following error:

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.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

I get this error while running on my local machine from within Visual studio... I have already googled the error but nothing i found helps so far. I don't get the error when deployed on server, just on my local.

The website references .dll projects that I have created in the same solution. The error seems to occur when I try to instaniate an object contained within any one of these .dll projects.

This setting in Web.config did not help:

<trust level="Full" originUrl="" />

neither did this:

<securityPolicy>
    <trustLevel  name="Full" policyFile="internal" />
</securityPolicy>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This worked for me. in web.config add

<system.web>
   <trust level="Full" />
</system.web>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...