加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-15 19:27:38 所属栏目:百科 来源:网络整理
导读:我们正在将一系列应用程序从旧服务器迁移到新服务器. 在我们的新DEV服务器中成功测试此应用程序,然后将代码提升到新的PROD服务器后,这将返回错误.在检查了这个应用程序中的数据库代码之后,我确定我们正在使用SQL Server而不是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>

Source File:
C:WindowsMicrosoft.NETFramework64v4.0.30319Configmachine.config
Line: 276
________________________________________ Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1069.1

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

System.Configuration.ConfigurationErrorsException: Unable to connect
to any of the specified MySQL hosts.
(C:WindowsMicrosoft.NETFramework64v4.0.30319Configmachine.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:WindowsMicrosoft.NETFramework64v4.0.30319Temporary ASP.NET
FilesdinglemeyersApplicationfaeebe625126d38eApp_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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读