ASP.Net:MySQL 错误 SecurityException:System.Security.Permissions.SecurityPermission

标签 asp.net mysql visual-studio-2012 permissions securityexception

我收到以下错误消息:

Server Error in '/' Application.

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: System.Security.Permissions.SecurityPermission

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: System.Security.Permissions.SecurityPermission]
   MySql.Data.MySqlClient.MySqlClientFactory..cctor() +23

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

MySQL:mysql-connector-net-6.7.4

仅当从共享网络托管环境运行时才会出现此问题。该网站在本地运作良好。我知道我的共享托管环境使用的 .Net 连接器的版本,因为这是我解决的另一个问题,并且我正在与托管提供商进行沟通。

这个错误很有趣。我可以转到默认页面,没有问题,这是第一次。然后我打开一个弹出对话框,它会抛出另一个错误消息框。

调用的目标抛出了异常。

以上就是一切,除了确定按钮。

我可以调出第一个弹出窗口,一个登录对话框。该对话框不调用 MySQL。我打开第二个对话框,一个注册对话框,然后抛出“Exception has been thrown...”消息框。之后,我无法返回登录对话框,因为我收到“异常有...”消息框。如果我按 F5 刷新浏览器(IE 或 Chrome),我会收到上面的错误。上面的错误说明MySQL和一些权限。

我怀疑“Exception has been thrown...”错误是同一个MySQL的结果,只是页面有内存。关闭浏览器窗口并再次启动浏览器窗口无济于事,尽管在 Chrome 上可以正常工作,只是浏览器窗口确实必须完全关闭。

我在共享主机环境中,所以我基本上无法访问任何东西,所以我无法访问任何日志,至少我能想到。

可能相关也可能不相关的最后一个想法。昨天和前几天,我的开发工作是在装有 Windows 7 Professional 和 Visual Studio 2012 Professional(所有最新服务包和更新)的系统上完成的,而今天我在我的另一台计算机上工作,这是一个装有 Windows 8 Professional 的系统和 Visual Studio 2012 Ultimate(操作系统和 VS 上的所有最新服务包和更新)。我正在阅读其他一些关于使用 VS2012 Ultimate 的人遇到的不相关问题的帖子,所以我不确定这与它有什么关系,但这从昨天到今天发生了变化。

是的,我从服务器上删除了所有内容并重新上传了所有内容。我首先做了一个干净的解决方案,构建了版本,然后发布了。我仍然收到同样的错误。

有什么想法吗?

最佳答案

默认情况下,大多数主机使用“中”信任级别。您可以如下更改您的 web.config 以获得完全信任:

<configuration> 
  <system.web> 
    <trust level="Full" /> 
  </system.web> 
</configuration>

关于ASP.Net:MySQL 错误 SecurityException:System.Security.Permissions.SecurityPermission,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17869814/

相关文章:

c# - Enter 对提交不起作用,ASP.NET 页面刷新并且不搜索

表单 runat=server 中的 Javascript 验证

asp.net - IIS7.0中如何使静态Html页面通过HttpModule?

visual-studio-2012 - Windows 应用商店应用程序中的启动画面

c# - 如何从 IOwinRequest 获取上传文件的集合?

sql - MySQL 中的自然排序

如果表 1 中的*所有*行不存在,则 MySQL 查询从表 2 中选择行

mysql - SQL Buddy 中的“是/否”条目使用什么数据库字段类型?

c# - Selenium - Visual Studios- C# - 所有(chrome、firefox 和 internet explorer)网络驱动程序无法启动驱动程序服务

java - 如何使用 TFS 和变量功能替换 .config 文件中的值?