本文介绍了MySql.Data在GAC中,仍然是SecurityException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个值得信赖的局部环境MySql.Data一个问题。
我已经添加MySql.Data到GAC(从mysql.com网站与MSI安装它)。正如你可以在这里看到:

I have a problem with MySql.Data in a partial trusted environment.I've added MySql.Data to the GAC (by installing it with the MSI from the mysql.com site). As you can see here:

>gacutil /l | grep -i mysql
  MySql.Data, Version=6.5.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d,
 processorArchitecture=MSIL
  MySql.Data.CF, Version=6.5.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c4
4d, processorArchitecture=MSIL
  MySql.Data.Entity, Version=6.5.4.0, Culture=neutral, PublicKeyToken=c5687fc889
69c44d, processorArchitecture=MSIL
  MySql.Web, Version=6.5.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d,
processorArchitecture=MSIL

>



我有以下内容添加到我的web.config:

I've add the following to my web.config:

<configuration>
    <system.web>
      <trust level="Vevida"/>
      <compilation debug="true" targetFramework="4.0">
        <assemblies>
          <add assembly="MySql.Data, Version=6.5.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
        </assemblies>
      </compilation>
    </system.web>
</configuration>



不过,我仍然得到以下异常:
异常详细信息: System.Security.SecurityException:申请类型的权限'MySql.Data.MySqlClient.MySqlClientPermission,MySql.Data,版本= 6.5.4.0,文化=中性公钥= c5687fc88969c44d'失败

当我尝试打开一个连接它抛出。

It is thrown when I try to open a connection.

我不知道我可以检查更多。
根据MySQL的文档,我至少需要以下权限:
System.Net.SocketPermission,System.Security.Permissions.ReflectionPermission,System.Net.DnsPermission和System.Security.Permissions.SecurityPermission

I'm not sure what I can check more.According to the MySql documentation, I need at least the following permissions:System.Net.SocketPermission, System.Security.Permissions.ReflectionPermission, System.Net.DnsPermission, and System.Security.Permissions.SecurityPermission

在我的信任级别我这些:

In my trust level I these:

<IPermission
    class="SocketPermission"
    version="1"
    Unrestricted="true">
</IPermission>
<IPermission
    class="ReflectionPermission"
    version="1"
    Flags="RestrictedMemberAccess"/>
<IPermission
    class="DnsPermission"
    version="1"
Unrestricted="true"/>
<IPermission
    class="SecurityPermission"
    version="1"
    Flags="Execution,ControlPrincipal,ControlThread,SerializationFormatter"/>



据我可以在文档中看到的,这就够了。还试图设置的SecurityPermission和性ReflectionPermission不受限制,这并没有帮助。

As far as I can see in the documentation, this is enough. Also tried to set the SecurityPermission and ReflectionPermission to unrestricted, this didn't help.

你有什么想法?

推荐答案

MySqlClientPermission必须被加入到培养基中的信任的配置作为SecurityClass和IPermission。我web_mediumtrust.config除了为:

MySqlClientPermission has to be added to the medium trust config as SecurityClass and IPermission. My web_mediumtrust.config addition is:

<SecurityClass Name="MySqlClientPermission"
  Description="MySql.Data.MySqlClient.MySqlClientPermission,
  MySql.Data, Version=6.5.4.0, Culture=neutral,
  PublicKeyToken=c5687fc88969c44d"
/>

<IPermission class="MySqlClientPermission" version="1">
  <add connectionString="Server=;Database=;User=;Password=;Port=;Pooling=;"
    restrictions=""
    KeyRestrictionBehavior="PreventUsage" />
</IPermission>



由于还贴的

这篇关于MySql.Data在GAC中,仍然是SecurityException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 14:53