MySQL在打开连接时抛出异常

时间:2016-10-23 11:13:49

标签: c# mysql asp.net exception web-hosting

我在托管网站上收到以下异常,但它已经运行多年了。我搜索了异常的互联网,并在web.config中添加了以下内容

 <trust level="Medium"/>

<trust level="Full"/>

但未解决我的问题。

版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.6.1085.0

我的连接字符串如下:

<add name="conMysql" connectionString="server=localhost;database=db1;uid=myuser;password=pass;Charset=utf8;" />

以下是“例外”页面:

&#13;
&#13;
<html><head>
        <title>Security Exception</title>
        <meta name="viewport" content="width=device-width">
        <style>
         body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} 
         p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
         b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
         H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
         H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
         pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt}
         .marker {font-weight: bold; color: black;text-decoration: none;}
         .version {color: gray;}
         .error {margin-bottom: 10px;}
         .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
         @media screen and (max-width: 639px) {
          pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; }
         }
         @media screen and (max-width: 479px) {
          pre { width: 280px; }
         }
        </style>
    </head>

    <body bgcolor="white">

            <span><h1>Server Error in '/' Application.<hr width="100%" size="1" color="silver"></h1>

            <h2> <i>Security Exception</i> </h2></span>

            <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">

            <b> Description: </b>The application attempted to perform an operation not allowed by the security policy. &nbsp;To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
            <br><br>

            <b> Exception Details: </b>System.Security.SecurityException: Request for the permission of type 'System.Net.SocketPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.<br><br>

            <b>Source Error:</b> <br><br>

            <table width="100%" bgcolor="#ffffcc">
               <tbody><tr>
                  <td>
                      <code>

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.</code>

                  </td>
               </tr>
            </tbody></table>

            <br>

            <b>Stack Trace:</b> <br><br>

            <table width="100%" bgcolor="#ffffcc">
               <tbody><tr>
                  <td>
                      <code><pre>
[SecurityException: Request for the permission of type 'System.Net.SocketPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
   System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark&amp; stackMark, Boolean isPermSet) +0
   System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark&amp; stackMark) +34
   System.Security.CodeAccessPermission.Demand() +46
   System.Net.Sockets.Socket.CheckCacheRemote(EndPoint&amp; remoteEP, Boolean isOverwrite) +168
   System.Net.Sockets.Socket.BeginConnectEx(EndPoint remoteEP, Boolean flowContext, AsyncCallback callback, Object state) +6607720
   System.Net.Sockets.Socket.BeginConnect(EndPoint remoteEP, AsyncCallback callback, Object state) +233
   MySql.Data.Common.StreamCreator.CreateSocketStream(IPAddress ip, Boolean unix) +165
   MySql.Data.Common.StreamCreator.GetStream(UInt32 timeout) +347
   MySql.Data.MySqlClient.NativeDriver.Open() +171
</pre></code>

                  </td>
               </tr>
            </tbody></table>

            <br>

            <hr width="100%" size="1" color="silver">

            <b>Version Information:</b>&nbsp;Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1085.0

            </font>

    

</body></html>
&#13;
&#13;
&#13;

这是删除html的例外情况。

安全例外

描述:应用程序尝试执行安全策略不允许的操作。要授予此应用程序所需的权限,请与系统管理员联系或更改配置文件中应用程序的信任级别。

异常详细信息:System.Security.SecurityException:请求类型为&#39; System.Net.SocketPermission,System,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089&#39;失败。

来源错误:              在执行当前Web请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息。

堆栈追踪:

         [SecurityException: Request for the permission of type 'System.Net.SocketPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
   System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark&amp; stackMark, Boolean isPermSet) +0
   System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark&amp; stackMark) +34
   System.Security.CodeAccessPermission.Demand() +46
   System.Net.Sockets.Socket.CheckCacheRemote(EndPoint&amp; remoteEP, Boolean isOverwrite) +168
   System.Net.Sockets.Socket.BeginConnectEx(EndPoint remoteEP, Boolean flowContext, AsyncCallback callback, Object state) +6607720
   System.Net.Sockets.Socket.BeginConnect(EndPoint remoteEP, AsyncCallback callback, Object state) +233
   MySql.Data.Common.StreamCreator.CreateSocketStream(IPAddress ip, Boolean unix) +165
   MySql.Data.Common.StreamCreator.GetStream(UInt32 timeout) +347
   MySql.Data.MySqlClient.NativeDriver.Open() +171

0 个答案:

没有答案