dotConnect for MySQL Documentation
In This Topic
    Configuring Trust Level for Web Applications
    In This Topic

    The following permissions are required by dotConnect for MySQL as partially trusted code (this is actual for web projects):

    Since dotConnect for MySQL uses standard Microsoft .NET licensing, it additionally requires RegistryPermission. And though SecurityPermission is granted by default when using medium trust level, the set of flags for the SecurityPermission must be extended. You need to add the following flags: Assertion, SkipVerification, UnmanagedCode, and SerializationFormatter.

    You can configure the trust level for your application in the following ways:

    First, you can modify the .NET Framework configuration file for the medium trust level. Open the web_mediumtrust.config file, that is located in the Windows\Microsoft.NET\Framework\<version>\Config\ folder, where <version> is the version of the target .NET Framework.

    Add the following lines to the SecuityClasses tag:

    <SecurityClass Name="RegistryPermission" Description="System.Security.Permissions.RegistryPermission, mscorlib, Version=4.0.0.0, Culture=neutral,PublicKeyToken=b77a5c561934e089"/>
    <SecurityClass Name="SocketPermission" Description="System.Net.SocketPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    

    Add the corresponding IPermissions elements to the PermissionSet tag with the Name attribute equal to "ASP.Net":

    <PermissionSet class="NamedPermissionSet" version="1" Name="ASP.Net">
    	<IPermission
    			class="RegistryPermission" 
    			version="1" 
    			Unrestricted="true" 
    	/>
    	<IPermission
    			class="SocketPermission" 
    			version="1" 
    			Unrestricted="true" 
    	/>
    

    However, since the access to this file may be restricted on target computer, you may define your custom trust level. For this, add the following lines to the system.web tag at the beginning of your application web.config file:

    <configuration>
    	<system.web>
    		<securityPolicy>
          			<trustLevel name="Custom" policyFile="web_customtrust.config" />
    		</securityPolicy>
    		<trust level="Custom" originUrl="" /> 
    
    This trustLevel tag here introduces the new "Custom" trust level, defined in the web_customtrust.config (that is located in the same directory as the web.config file). The trust tag sets the current trust level to "Custom".

    Create the web_customtrust.config file (just copy the content of your web_mediumtrust.config to it and make the changes, described above). You will need to deploy this file with your application.