1

Im using VS 2010 MVC3, I set up the web.config to connect to my remote database. When I debug its runs ok, registers, logs in fine. But when I upload it to the host i get 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.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
MySql.Data.MySqlClient.MySqlConnectionStringBuilder.CreatePermissionSet() +0 MySql.Data.MySqlClient.MySqlConnectionStringBuilder.DemandPermissions() +38 MySql.Data.MySqlClient.MySqlConnection.PermissionDemand() +94 MySql.Data.MySqlClient.MySqlConnection.Open() +196
MySql.Web.Common.SchemaManager.GetSchemaVersion(String connectionString) +65
MySql.Web.Common.SchemaManager.CheckSchema(String connectionString, NameValueCollection config) +39
MySql.Web.Security.MySQLRoleProvider.Initialize(String name, NameValueCollection config) +462
System.Web.Configuration.ProvidersHelper.InstantiateProvider(ProviderSettings providerSettings, Type providerType) +419

Im using MySQL Connector Net 6.5.4

4

2 回答 2

0

这是很多人遇到的常见问题。那是因为您以完全信任级别构建您的网站。这允许您通过 IIS 完成几乎所有操作。但是很多托管公司只允许中等信任级别。所以您需要重新编码必要的中信任级别下的项目的一部分。

打开 ;

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config

文件夹并打开 webconfig 文件,并更改行;

<trust level="Full" originUrl="" />

<trust level="Medium" originUrl="" />

老实说,我对进一步的步骤和您的程序集没有深入的了解。所以我可以提供很多帮助。

于 2013-08-19T14:01:35.387 回答
0

我的朋友也有同样的问题。他管理它在 MySql 连接字符串中添加以下设置:

includesecurityasserts=true
于 2020-09-22T16:06:52.847 回答