Godaddy上IIS7 ASP.net 2.0 Mysql資料庫存在的問題

來源:互聯網
上載者:User

大多數涉及到Mysql操作的頁面均拋出以下異常:

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: Request for the
permission of type 'System.Security.Permissions.SecurityPermission,
mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' failed.

Source Error:

[No relevant source lines]

Source File: App_Web_bbkojzme.6.cs    Line: 0

Stack Trace:

[SecurityException: Request for the permission of type
'System.Security.Permissions.SecurityPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
failed.]
  System.Reflection.MethodBase.PerformSecurityCheck(Object obj,
RuntimeMethodHandle method, IntPtr parent, UInt32 invocationFlags) +0
  System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
+470
  System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr,
Binder binder, Object[] args, CultureInfo culture, Object[]
activationAttributes) +1051
  System.Activator.CreateInstance(Type type, BindingFlags
bindingAttr, Binder binder, Object[] args, CultureInfo culture,
Object[] activationAttributes) +111
  System.Resources.ResourceManager.CreateResourceSet(Stream store,
Assembly assembly) +357
  System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo
culture, Boolean createIfNotExists, Boolean tryParents) +471
  System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo
culture, Boolean createIfNotExists, Boolean tryParents) +583
  System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo
culture, Boolean createIfNotExists, Boolean tryParents) +583
  System.Resources.ResourceManager.GetString(String name, CultureInfo
culture) +74
  MySql.Data.MySqlClient.Resources.get_PerfMonCategoryName() +40
  MySql.Data.MySqlClient.PerformanceMonitor..ctor(MySqlConnection
connection) +43
  MySql.Data.MySqlClient.MySqlConnection.Open() +434
  System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection
connection, ConnectionState& originalState) +31
  System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +112
  System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +287
  System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +92
  System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments
arguments) +1297
  System.Web.UI.DataSourceView.Select(DataSourceSelectArguments
arguments, DataSourceViewSelectCallback callback) +19
  System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142
  System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73
  System.Web.UI.WebControls.GridView.DataBind() +4
  System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
  System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +72
  System.Web.UI.Control.EnsureChildControls() +87
  System.Web.UI.Control.PreRenderRecursiveInternal() +44
  System.Web.UI.Control.PreRenderRecursiveInternal() +171
  System.Web.UI.Control.PreRenderRecursiveInternal() +171
  System.Web.UI.Control.PreRenderRecursiveInternal() +171
  System.Web.UI.Control.PreRenderRecursiveInternal() +171
  System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+6785
  System.Web.UI.Page.ProcessRequest(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+242
  System.Web.UI.Page.ProcessRequest() +80
  System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
  System.Web.UI.Page.ProcessRequest(HttpContext context) +49
  ASP.news_aspx.ProcessRequest(HttpContext context) in App_Web_bbkojzme.6.cs:0
  System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+181
  System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously) +75

Version Information: Microsoft .NET Framework Version:2.0.50727.4214;
ASP.NET Version:2.0.50727.4209


解決方案:

去http://dev.mysql.com/downloads/mirror.php?id=393503下載VS2008用mysql
connector/net 6.0.7,在本機安裝好之後,將安裝目錄下得MySql.Data.dll檔案上傳到godaddy伺服器的bin目錄下。

修改web.config檔案:

<system.data>   <DbProviderFactories>     <clear/>     <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.0.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />   </DbProviderFactories> </system.data>

將web.config檔案上傳到godaddy伺服器上。

參考了http://blog.csdn.net/Reasoncool/article/details/6226920。


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.