简体   繁体   English

中信任度的MySql数据实体EF6

[英]MySql Data Entity EF6 In Medium Trust

We currently are on a shared windows server through Hostgator. 当前,我们通过Hostgator在共享Windows服务器上。 They are forcing the shared servers to run in Medium Trust. 他们强迫共享服务器在中等信任中运行。 They have MySql.Data.DLL (6.9.7) in the GAC. 他们在GAC中具有MySql.Data.DLL(6.9.7)。 The issue is they don't have MySql.Data.Entity.EF6.DLL in the GAC, nor will they install it for me. 问题是他们在GAC中没有MySql.Data.Entity.EF6.DLL,也不会为我安装它。 So I tried referencing there MySql.Data dll from the gac and then referencing the MySql.Data.Entity.EF6.dll (6.9.9) from our project. 因此,我尝试从gac引用MySql.Data dll,然后从我们的项目中引用MySql.Data.Entity.EF6.dll(6.9.9)。 When I do this I get a security error. 当我这样做时,我会收到一个安全错误。 I am assuming this is due to the EF6 dll requiring full trust. 我假设这是由于EF6 dll需要完全信任。 Any solution to this? 有什么解决办法吗? Thanks 谢谢

Error: 错误:

{"Message":"An error has occurred.","ExceptionMessage":"Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.","ExceptionType":"System.Security.SecurityException","StackTrace":" at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)\\r\\n at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark)\\r\\n at System.Security.CodeAccessPermission.Demand()\\r\\n at System.Environment.GetEnvironmentVariable(String variable)\\r\\n at MySql.Data.MySqlClient.MySqlConnectAttrs.Is64BitOS()\\r\\n at MySql.Data.MySqlClient.MySqlConnectAttrs.get_Platform()"} {“消息”:“发生错误。”,“ ExceptionMessage”:“请求类型为'System.Security.Permissions.EnvironmentPermission,mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'的请求失败。“,” ExceptionType“:” System.Security.SecurityException“,” StackTrace“:”在System.Security.CodeAccessSecurityEngine.Check(对象需求,StackCrawlMark&stackMark,布尔值isPermSet)\\ r \\ n在System.Security.CodeAccessSecurityEngine.Check (CodeAccessPermission上限,StackCrawlMark和stackMark)\\ r \\ n在System.Security.CodeAccessPermission.Demand()\\ r \\ n在System.Environment.GetEnvironmentVariable(String变量)\\ r \\ n在MySql.Data.MySqlClient.MySqlConnectAttrs.Is64BitOS( )\\ r \\ n在MySql.Data.MySqlClient.MySqlConnectAttrs.get_Platform()“}

WebConfig: WebConfig:

<configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>

<entityFramework>
<providers>
    <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
    <remove invariant="MySql.Data.MySqlClient" />
    <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>

<dependentAssembly>
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" />
<bindingRedirect oldVersion="0.0.0.0-6.9.9.0" newVersion="6.9.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="MySql.Data.Entity.EF6" publicKeyToken="c5687fc88969c44d" />
<bindingRedirect oldVersion="0.0.0.0-6.9.9.0" newVersion="6.9.9.0" />
</dependentAssembly>

在此处输入图片说明

I do not know the Error which you mentioned.But i suggest you to read this page carefully https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework60.html 我不知道您提到的错误。但是我建议您仔细阅读此页面https://dev.mysql.com/doc/connector-net/zh/connector-net-entityframework60.html
Your WebConfig is not as below format 您的WebConfig不是以下格式

 <connectionStrings> <add name="MyContext" providerName="MySql.Data.MySqlClient" connectionString="server=localhost;port=3306;database=mycontext;uid=root;password=********"/> </connectionStrings> <entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6"> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/> <providers> <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6"/> <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/> </providers> </entityFramework> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM