Security Exception : The application attempted to perform an operation not allowed by the security policy.

Last post 11-13-2009 8:58 AM by TATWORTH. 18 replies.

Sort Posts:

  • Security Exception : The application attempted to perform an operation not allowed by the security policy.

    11-07-2009, 4:05 PM
    • Member
      476 point Member
    • aliusmankhan
    • Member since 07-02-2008, 10:41 AM
    • Posts 396

    Dear friends

    I have hosted my website and i m getting this 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.

    Yes i know this is the prob of Application trust level, But can any one tell me the easiest way to change the application trust level? My hosting company is not helping me out... So what should i do...?

    Kind regards

    aliusmankhan

    aliusmankhan
    C#
    .NET 3.5
    Web.Dev
    AJAX
  • Re: Security Exception : The application attempted to perform an operation not allowed by the security policy.

    11-08-2009, 2:07 AM
  • Re: Security Exception : The application attempted to perform an operation not allowed by the security policy.

    11-08-2009, 5:29 AM
    • Member
      476 point Member
    • aliusmankhan
    • Member since 07-02-2008, 10:41 AM
    • Posts 396

    Mikesdotnetting:

    I am not getting any thing out of it, Can u please explain, below is the web_mediumtrust.config provided by my host

    <configuration>
    	<mscorlib>
    		<security>
    			<policy>
    				<PolicyLevel version="1">
    					<SecurityClasses>
    						<SecurityClass Name="AllMembershipCondition" Description="System.Security.Policy.AllMembershipCondition, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    						<SecurityClass Name="AspNetHostingPermission" Description="System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    						<SecurityClass Name="ConfigurationPermission" Description="System.Configuration.ConfigurationPermission, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
    						<SecurityClass Name="DnsPermission" Description="System.Net.DnsPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    						<SecurityClass Name="EnvironmentPermission" Description="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    						<SecurityClass Name="FileIOPermission" Description="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    						<SecurityClass Name="FirstMatchCodeGroup" Description="System.Security.Policy.FirstMatchCodeGroup, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    						<SecurityClass Name="IsolatedStorageFilePermission" Description="System.Security.Permissions.IsolatedStorageFilePermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    						<SecurityClass Name="NamedPermissionSet" Description="System.Security.NamedPermissionSet"/>
    						<SecurityClass Name="PrintingPermission" Description="System.Drawing.Printing.PrintingPermission, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
    						<SecurityClass Name="RegistryPermission" Description="System.Security.Permissions.RegistryPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    						<SecurityClass Name="SecurityPermission" Description="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    						<SecurityClass Name="SmtpPermission" Description="System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    						<SecurityClass Name="SocketPermission" Description="System.Net.SocketPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    						<SecurityClass Name="SqlClientPermission" Description="System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    						<SecurityClass Name="StrongNameMembershipCondition" Description="System.Security.Policy.StrongNameMembershipCondition, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    						<SecurityClass Name="UnionCodeGroup" Description="System.Security.Policy.UnionCodeGroup, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    						<SecurityClass Name="UrlMembershipCondition" Description="System.Security.Policy.UrlMembershipCondition, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    						<SecurityClass Name="WebPermission" Description="System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    						<SecurityClass Name="ZoneMembershipCondition" Description="System.Security.Policy.ZoneMembershipCondition, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    						<SecurityClass Name="OleDbPermission" Description="System.Data.OleDb.OleDbPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    						<SecurityClass Name="OdbcPermission" Description="System.Data.Odbc.OdbcPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    						<SecurityClass Name="OraclePermission" Description="System.Data.OracleClient.OraclePermission, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    						<SecurityClass Name="ReflectionPermission" Description="System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    
    					</SecurityClasses>
    					<NamedPermissionSets>
    						<PermissionSet
                                    class="NamedPermissionSet"
                                    version="1"
                                    Unrestricted="true"
                                    Name="FullTrust"
                                    Description="Allows full access to all resources"
                            />
    						<PermissionSet
                                    class="NamedPermissionSet"
                                    version="1"
                                    Name="Nothing"
                                    Description="Denies all resources, including the right to execute"
                            />
    						<PermissionSet
                                    class="NamedPermissionSet"
                                    version="1"
                                    Name="ASP.Net">
    							<IPermission
                                        class="AspNetHostingPermission"
                                        version="1"
                                        Level="High"
                                />
    							<IPermission
                                        class="ConfigurationPermission"
                                        version="1"
                                        Unrestricted="true"
                                />
    							<IPermission
                                        class="DnsPermission"
                                        version="1"
                                        Unrestricted="true"
                                />
    							<IPermission
                                        class="EnvironmentPermission"
                                        version="1"
                                        Unrestricted="true"
                                />
    							<IPermission
                                        class="FileIOPermission"
                                        version="1"
                                        Read="$AppDir$"
                                        Write="$AppDir$"
                                        Append="$AppDir$"
                                        PathDiscovery="$AppDir$"
                                />
    							<IPermission
                                        class="IsolatedStorageFilePermission"
                                        version="1"
                                        Unrestricted="true"
                                />
    							<IPermission
                                        class="PrintingPermission"
                                        version="1"
                                        Level="DefaultPrinting"
                                />
    							<IPermission
                                        class="RegistryPermission"
                                        version="1"
                                        Unrestricted="true"
                                />
    							<IPermission
                                        class="SecurityPermission"
                                        version="1"
                                        Flags="Assertion, Execution, ControlThread, ControlPrincipal, RemotingConfiguration"
                                />
    							<IPermission
                                        class="SmtpPermission"
                                        version="1"
                                        Access="Connect"
                                />
    							<IPermission
                                        class="SocketPermission"
                                        version="1"
                                        Unrestricted="true"
                                />
    							<IPermission
                                        class="SqlClientPermission"
                                        version="1"
                                        Unrestricted="true"
                                />
    							<IPermission
                                        class="WebPermission"
                                        version="1"
                                        Unrestricted="true"
                                />
    							<IPermission class="OleDbPermission"
    										version="1"
    								Unrestricted="true"
    							/>
    
    							<IPermission class="OdbcPermission"
    								version="1"
    								Unrestricted="true"
    							/>
    
    							<IPermission class="OraclePermission"
    								version="1"
    								Unrestricted="true"
    							/>
    
    							<IPermission
    								class="ReflectionPermission"
    								version="1"
    								Flags="RestrictedMemberAccess"
    							/>
    						</PermissionSet>
    					</NamedPermissionSets>
    					<CodeGroup
                                class="FirstMatchCodeGroup"
                                version="1"
                                PermissionSetName="Nothing">
    						<IMembershipCondition
                                    class="AllMembershipCondition"
                                    version="1"
                            />
    						<CodeGroup
                                    class="UnionCodeGroup"
                                    version="1"
                                    PermissionSetName="ASP.Net">
    							<IMembershipCondition
                                        class="UrlMembershipCondition"
                                        version="1"
                                        Url="$AppDirUrl$/*"
                                />
    						</CodeGroup>
    						<CodeGroup
                                    class="UnionCodeGroup"
                                    version="1"
                                    PermissionSetName="ASP.Net">
    							<IMembershipCondition
                                        class="UrlMembershipCondition"
                                        version="1"
                                        Url="$CodeGen$/*"
                                />
    						</CodeGroup>
    						<CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="Nothing">
    							<IMembershipCondition
                                    class="ZoneMembershipCondition"
                                    version="1"
                                    Zone="MyComputer" />
    							<CodeGroup
                                        class="UnionCodeGroup"
                                        version="1"
                                        PermissionSetName="FullTrust"
                                        Name="Microsoft_Strong_Name"
                                        Description="This code group grants code signed with the Microsoft strong name full trust. ">
    								<IMembershipCondition
                                            class="StrongNameMembershipCondition"
                                            version="1"
                                            PublicKeyBlob="002400000480000094000000060200000024000052534131000400000100010007D1FA57C4AED9F0A32E84AA0FAEFD0DE9E8FD6AEC8F87FB03766C834C99921EB23BE79AD9D5DCC1DD9AD236132102900B723CF980957FC4E177108FC607774F29E8320E92EA05ECE4E821C0A5EFE8F1645C4C0C93C1AB99285D622CAA652C1DFAD63D745D6F2DE5F17E5EAF0FC4963D261C8A12436518206DC093344D5AD293"
                                    />
    							</CodeGroup>
    							<CodeGroup
                                        class="UnionCodeGroup"
                                        version="1"
                                        PermissionSetName="FullTrust"
                                        Name="Ecma_Strong_Name"
                                        Description="This code group grants code signed with the ECMA strong name full trust. ">
    								<IMembershipCondition
                                            class="StrongNameMembershipCondition"
                                            version="1"
                                            PublicKeyBlob="00000000000000000400000000000000"
                                    />
    							</CodeGroup>
    						</CodeGroup>
    					</CodeGroup>
    				</PolicyLevel>
    			</policy>
    		</security>
    	</mscorlib>
    </configuration>


    aliusmankhan
    C#
    .NET 3.5
    Web.Dev
    AJAX
  • Re: Security Exception : The application attempted to perform an operation not allowed by the security policy.

    11-08-2009, 9:32 AM
    • Member
      476 point Member
    • aliusmankhan
    • Member since 07-02-2008, 10:41 AM
    • Posts 396

    Any one with the solution plz

    aliusmankhan
    C#
    .NET 3.5
    Web.Dev
    AJAX
  • Re: Security Exception : The application attempted to perform an operation not allowed by the security policy.

    11-08-2009, 1:34 PM
    • All-Star
      63,000 point All-Star
    • TATWORTH
    • Member since 02-04-2003, 1:34 PM
    • England
    • Posts 12,308
    • TrustedFriends-MVPs

    Did you have any further information about the exception? Can you track it back to what in your code was causing the problem?

    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: Security Exception : The application attempted to perform an operation not allowed by the security policy.

    11-08-2009, 11:18 PM
    • Member
      476 point Member
    • aliusmankhan
    • Member since 07-02-2008, 10:41 AM
    • Posts 396

    TATWORTH:

    Did you have any further information about the exception? Can you track it back to what in your code was causing the problem?


    actually i m using ActiveX GridView, Every page where i placed that GridView is giving same error, I just wanna know that, How can i change application trust level, Where my host has refused to change the system web.config to FULL, is there any other way i can use, Please help

    aliusmankhan
    C#
    .NET 3.5
    Web.Dev
    AJAX
  • Re: Security Exception : The application attempted to perform an operation not allowed by the security policy.

    11-09-2009, 2:24 AM

    aliusmankhan:
    actually i m using ActiveX GridView

    Could you explain more?  Why are you using that?


    Regards Mike
    [MVP - ASP/ASP.NET]
    My site    Please help - URGENT!!!    What ASP.NET can and can't do
  • Re: Security Exception : The application attempted to perform an operation not allowed by the security policy.

    11-09-2009, 3:10 AM
    • All-Star
      63,000 point All-Star
    • TATWORTH
    • Member since 02-04-2003, 1:34 PM
    • England
    • Posts 12,308
    • TrustedFriends-MVPs

    I suggest that you replace the ActiveX control with its ASP.NET equivalent.

    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: Security Exception : The application attempted to perform an operation not allowed by the security policy.

    11-11-2009, 4:58 AM
    Answer

    Hi,

    The error message indicates that your website doesn't have rights to access the resource on server.

    Commonly, the host server uses Medium trust level to restrict which resource types your application can access and which privileged operations it can perform.
     
    During development in local, the code access security is Full trust level and application can implement more works. For testing, you can run your website with Medium trust level in local. I think we will get the same issue.

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


    For more information, see http://msdn.microsoft.com/en-us/library/ms998326.aspx (Typically, Table 4: Default ASP.NET Policy Permissions and Trust Levels).

    You also can ask you Host Company to confirm whether they support Full trust website or find other host server that supports it.
     
    I look forward to receiving your test results.

    Thomas Sun
    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
  • Re: Security Exception : The application attempted to perform an operation not allowed by the security policy.

    11-11-2009, 5:54 AM
    • All-Star
      63,000 point All-Star
    • TATWORTH
    • Member since 02-04-2003, 1:34 PM
    • England
    • Posts 12,308
    • TrustedFriends-MVPs

    Thank you Thomas for the reference to http://msdn.microsoft.com/en-us/library/ms998326.aspx

    It stated: If your application calls unmanaged code, it must run with Full trust.

    Thus active X will not run in a medium trust web site (or application).


    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: Security Exception : The application attempted to perform an operation not allowed by the security policy.

    11-12-2009, 7:05 AM
    • Member
      476 point Member
    • aliusmankhan
    • Member since 07-02-2008, 10:41 AM
    • Posts 396

    Thomas Sun – MSFT:

    Hi,

    The error message indicates that your website doesn't have rights to access the resource on server.

    Commonly, the host server uses Medium trust level to restrict which resource types your application can access and which privileged operations it can perform.
     
    During development in local, the code access security is Full trust level and application can implement more works. For testing, you can run your website with Medium trust level in local. I think we will get the same issue.

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


    For more information, see http://msdn.microsoft.com/en-us/library/ms998326.aspx (Typically, Table 4: Default ASP.NET Policy Permissions and Trust Levels).

    You also can ask you Host Company to confirm whether they support Full trust website or find other host server that supports it.
     
    I look forward to receiving your test results.


    Yes i know all about it, but here i just wanna know that how can i give my application Full trust level progmatically, Where my host does not support Full trust level.

    Regards


    aliusmankhan
    C#
    .NET 3.5
    Web.Dev
    AJAX
  • Re: Security Exception : The application attempted to perform an operation not allowed by the security policy.

    11-12-2009, 7:05 AM
    • Member
      476 point Member
    • aliusmankhan
    • Member since 07-02-2008, 10:41 AM
    • Posts 396

    Mikesdotnetting:

    aliusmankhan:
    actually i m using ActiveX GridView

    Could you explain more?  Why are you using that?


    Because i was needed some facilities which the asp.net Grid was not giving.. I really cant get rid of it,

    aliusmankhan
    C#
    .NET 3.5
    Web.Dev
    AJAX
  • Re: Security Exception : The application attempted to perform an operation not allowed by the security policy.

    11-12-2009, 7:06 AM
    • Member
      476 point Member
    • aliusmankhan
    • Member since 07-02-2008, 10:41 AM
    • Posts 396

    TATWORTH:

    I suggest that you replace the ActiveX control with its ASP.NET equivalent.

    No i really cant get rid of that, Cuz i need them in my application to perform some very necessary functions , which is not possible with standard Grid.

    aliusmankhan
    C#
    .NET 3.5
    Web.Dev
    AJAX
  • Re: Security Exception : The application attempted to perform an operation not allowed by the security policy.

    11-12-2009, 7:06 AM
    • Member
      476 point Member
    • aliusmankhan
    • Member since 07-02-2008, 10:41 AM
    • Posts 396

    Thomas Sun – MSFT:

    Hi,

    The error message indicates that your website doesn't have rights to access the resource on server.

    Commonly, the host server uses Medium trust level to restrict which resource types your application can access and which privileged operations it can perform.
     
    During development in local, the code access security is Full trust level and application can implement more works. For testing, you can run your website with Medium trust level in local. I think we will get the same issue.

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


    For more information, see http://msdn.microsoft.com/en-us/library/ms998326.aspx (Typically, Table 4: Default ASP.NET Policy Permissions and Trust Levels).

    You also can ask you Host Company to confirm whether they support Full trust website or find other host server that supports it.
     
    I look forward to receiving your test results.


    Yes i know all about it, but here i just wanna know that how can i give my application Full trust level progmatically, Where my host does not support Full trust level.

    Regards


    aliusmankhan
    C#
    .NET 3.5
    Web.Dev
    AJAX
  • Re: Security Exception : The application attempted to perform an operation not allowed by the security policy.

    11-12-2009, 9:27 PM

    Hi,

    Thanks for your response.

    Since your host server doesn't allow Full truest level, they will lock it in machine level config file, and you cannot modify it in your web.config programmatically.


    Thanks.

    Thomas Sun
    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
Page 1 of 2 (19 items) 1 2 Next >