好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

c# – 获取错误:“无法连接到任何指定的MySQL主机.”在不使用MySQL的应用程序中

我们正在将一系列应用程序从旧服务器迁移到新服务器.

在我们的新DEV服务器中成功测试此应用程序,然后将代码提升到新的PROD服务器后,这将返回错误.在检查了这个应用程序中的数据库代码之后,我确定我们正在使用SQL Server而不是MySQL …我有点疑惑为什么会发生这种情况.任何想法或建议?

编辑:我有一个服务器的管理员从本地机器查看此错误,这是真正被返回的,特别是与服务器上的machine.config上列出的站点地图提供程序有关…

Server Error in ‘/DinglemeyersApplication’ Application.

Configuration Error

Description: An error occurred during the processing of a

configuration file required to service this request. Please review the

specific error details below and modify your configuration file

appropriately.

Parser Error Message: Unable to connect to any of the specified MySQL

hosts.

Source Error:

Line 274:    <siteMap> 
 Line 275:      <providers> 
 Line 276:        <add name="MySqlSiteMapProvider"  type="MySql.Web.SiteMap.MySqlSiteMapProvider, MySql.Web,
 Version=6.9.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"
 connectionStringName="LocalMySqlServer" applicationName="/" /> 
 Line 277:      </providers> 
 Line 278:    </siteMap>

深入挖掘文件系统日志,我发现完整的堆栈跟踪如下:

System.Configuration.ConfigurationErrorsException: Unable to connect

to any of the specified MySQL hosts.

(C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config

line 276) —> MySql.Data.MySqlClient.MySqlException: Unable to

connect to any of the specified MySQL hosts. at

MySql.Data.MySqlClient.NativeDriver.Open() at

MySql.Data.MySqlClient.Driver.Open() at

MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder

settings) at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()

at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver() at

MySql.Data.MySqlClient.MySqlPool.GetConnection() at

MySql.Data.MySqlClient.MySqlConnection.Open() at

MySql.Web.Common.SchemaManager.GetSchemaVersion(String

connectionString) at

MySql.Web.Common.SchemaManager.CheckSchema(String connectionString,

NameValueCollection config) at

System.Web.Configuration.ProvidersHelper.InstantiateProvider(ProviderSettings

providerSettings, Type providerType) — End of inner exception

stack trace — at

System.Web.Configuration.ProvidersHelper.InstantiateProvider(ProviderSettings

providerSettings, Type providerType) at

System.Web.Configuration.ProvidersHelper.InstantiateProviders(ProviderSettingsCollection

configProviders, ProviderCollection providers, Type providerType)

at System.Web.Configuration.SiteMapSection.get_ProvidersInternal()

at System.Web.SiteMap.Initialize() at

System.Web.UI.WebControls.SiteMapDataSource.get_Provider() at

System.Web.UI.WebControls.SiteMapDataSource.GetHierarchicalView(String

viewPath) at

System.Web.UI.WebControls.HierarchicalDataBoundControl.GetData(String

viewPath) at System.Web.UI.WebControls.Menu.DataBindItem(MenuItem

item) at System.Web.UI.WebControls.Menu.PerformDataBinding() at

System.Web.UI.WebControls.HierarchicalDataBoundControl.PerformSelect()

at System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound()

at System.Web.UI.WebControls.Menu.EnsureDataBound() at

System.Web.UI.WebControls.Menu.OnPreRender(EventArgs e) at

System.Web.UI.Control.PreRenderRecursiveInternal() at

System.Web.UI.Control.PreRenderRecursiveInternal() at

System.Web.UI.Control.PreRenderRecursiveInternal() at

System.Web.UI.Control.PreRenderRecursiveInternal() at

System.Web.UI.Control.PreRenderRecursiveInternal() at

System.Web.UI.Page.ProcessRequestMain(Boolean

includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

at System.Web.UI.Page.ProcessRequest(Boolean

includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

at System.Web.UI.Page.ProcessRequest() at

System.Web.UI.Page.ProcessRequest(HttpContext context) at

ASP.default_aspx.ProcessRequest(HttpContext context) in

c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET

Files\dinglemeyersApplication\faeebe62\5126d38e\App_Web_fi2tylhk.5.cs:line 0

at

System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()

at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,

Boolean& completedSynchronously)

我已经使用StackOverflow帖子中描述的方法解决了这个问题:

ASP.NET Cannot Find MySQL Host Even Though I’m Not Using MySQL

以前,此应用程序没有在web.config中定义任何站点地图.进入我的web.config并添加一个站点地图节点,然后添加一个< remove name =“MySqlSiteMapProvider”>这似乎解决了这个问题.我将在迁移后继续测试应用程序,但现在它正在运行!

在我的web.config中:

<system.web>
 ...
  <siteMap>
    <providers>   
        <remove name="MySqlSiteMapProvider" />
    </providers>
  </siteMap>
</system.web>

查看更多关于c# – 获取错误:“无法连接到任何指定的MySQL主机.”在不使用MySQL的应用程序中的详细内容...

  阅读:41次