该应用程序试图执行不是由安全策略不允许的操作 [英] The application attempted to perform an operation not allowed by the security policy

查看:898
本文介绍了该应用程序试图执行不是由安全策略不允许的操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了在Visual Studio 2008的Asp.net网站,它工作得很好,而使用Vista操作系统,但我的工作站已升级到Windows 7,我现在得到以下错误:


  

安全例外说明:该应用程序试图执行
  操作不是由安全策略不允许的。要授予此
  应用程序所需的权限,请联系您的系统
  管理员或更改应用程序的信任级别
  配置文件。


  
  

异常详细信息:System.Security.SecurityException:请求
  权限类型的System.Web.AspNetHostingPermission,系统,
  版本= 2.0.0.0,文化=中性公钥= b77a5c561934e089'
  失败了。


我在Visual Studio中我的本地机器上运行时得到这个错误......我已经一派错误,但没有我发现有助于至今。在服务器上部署的时候我没有得到错误,只是我的地方。

该网站引用.dll文件,我在同一个解决方案已创建的项目。该错误似乎发生时,我尝试instaniate包含这些.dll项目中的任何一个中的一个对象。

本设置在Web.config中没有帮助:

 <信任级别=全originUrl =/>

也没有这样的:

 <&SECURITYPOLICY GT;
    < trustLevel NAME =全policyFile =内部/>
< / SECURITYPOLICY>


解决方案

解决方案

(1)创建使用Internet Information Services(IIS)中的相应的域的应用程序池。登录到远程桌面和打开IIS管理器。展开树应用程序池。右键单击并选择新建|应用程序池,并给予必要的细节。

(2)的下一个步骤是将新创建的应用程序池下的域。为了执行此操作,展开树标记的网站,然后在它默认Web站点。选择您的域名,右键单击它并选择属性菜单项。选择下拉框标记应用程序池,并选择新创建的应用程序池名称。

请注意:如果你已经安装在他们的服务器上,可以自动执行使用某些流行的主机控制面板上述步骤

(3)添加code以下行Machine.config文件。该文件所在的文件夹下 - 根驱动器名称:\\ WINDOWS \\ Microsoft.NET \\框架\\ V1.1.4322 \\ CONFIG

 <位置路径=yourdomain.com有的allowOverride =真>
   <&的System.Web GT;
     <信任级别=全originUrl =/>
   < /system.web>
< /地点>

(一)如果您需要在服务器和访问远程桌面管理权限,以解决上述问题。您应该联系您的托管服务提供商,如果你没有访问该服务器。

(B)与该问题发生相应的域名替换yourdomain.com。

警告:machine.config文件的修改不正确会引起问题的服务器上的ASP.NET服务

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>

解决方案

RESOLUTION

(1) Create an application pool for the appropriate domain using Internet Information Services (IIS). Login to the remote desktop and open IIS Manager. Expand the tree Application Pools. Right click and select New | Application Pool and give the required particulars.

(2) The next step is to place the domain under the newly created application pool. In order to perform this action, expand the tree labeled Web Sites and then Default Web Site under it. Select your domain name, right click on it and choose Properties menu item. Select the drop down box labeled Application pool and choose the newly created application pool name.

Note: You can automatically perform the above mentioned steps using certain popular hosting control panels if you have installed them on the server.

(3) Add the following lines of code to machine.config file. This file can be located under the folder - Root Drive Name:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\CONFIG

<location path="yourdomain.com" allowOverride="true">
   <system.web>
     <trust level="Full" originUrl=""/>
   </system.web>
</location>

(A) You should require administrative rights to the server and access to remote desktop to resolve the above issue. You should contact your hosting service provider if you don’t have access to the server.

(B) Replace yourdomain.com with the appropriate domain name in which the problem is occurring.

Warning: Incorrect modification of machine.config file will cause problems to the ASP.NET service on the server.

这篇关于该应用程序试图执行不是由安全策略不允许的操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆