問題狀況
@VS2013
開啟 SSDT 連資料庫時,跳出了以下訊息
@SSMS
編輯 Table 時出現例外,如下圖:
詳細訊息如下:
===================================
Exception has been thrown by the target of an invocation. (SQLEditors)
------------------------------
Program Location:
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance[T]()
at Microsoft.SqlServer.Management.DataTools.Providers.Common.CommonConnectionProperties`1..ctor()
at Microsoft.SqlServer.Management.DataTools.Providers.Common.CommonProviderObjectFactory`3.CreateObject(Type objType)
at Microsoft.SqlServer.Management.DataTools.Providers.SqlServer.SqlProviderObjectFactory.CreateObject(Type objType)
at Microsoft.SqlServer.Management.DataTools.DataServices.DataProvider.CreateObject(Guid dataSource, Type objType)
at Microsoft.SqlServer.Management.DataTools.DataServices.DataProvider.CreateConnectionProperties(Guid dataSource)
at Microsoft.SqlServer.Management.DataTools.DataServices.DataProviderManager.CreateConnectionProperties(Guid provider)
at Microsoft.SqlServer.Management.DataTools.Providers.SqlServer.SqlDataSourceSpecializer.DeriveDataSource(String connectionString)
at Microsoft.SqlServer.Management.DataTools.DataServices.DataProvider.DeriveDataSource(String connectionString)
at Microsoft.SqlServer.Management.DataTools.DataServices.DataConnection.SetConnectionStrings(String connectionString)
at Microsoft.SqlServer.Management.DataTools.DataServices.DataConnection..ctor(DataProvider provider, String connectionString, Boolean encryptedString)
at Microsoft.SqlServer.Management.DataTools.DataServices.DataConnectionFactory.CreateDataConnectionImpl(Guid provider, String connectionString, Boolean encryptedString)
at Microsoft.SqlServer.Management.Data.DataConnectionFactory.CreateDataConnection(Guid provider, String connectionString, Boolean encryptedString)
at Microsoft.SqlServer.Management.DataTools.DataServices.DataConnectionManager.CreateDataConnection(Guid provider, String connectionString, Boolean encryptedString)
at Microsoft.SqlServer.Management.Data.DataConnectionManager.GetDataConnection(Guid provider, String connectionString, Boolean encryptedString, Boolean update)
at Microsoft.SqlServer.Management.DataTools.DataServices.DataConnectionManager.Microsoft.SqlServer.Management.Data.Interop.IVsDataConnectionManager.GetDataConnection(Guid& guidProvider, String bstrConnectionString, Boolean fEncryptedString)
at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.VsDataDesignerNode.CreateDesigner()
at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.VsDataDesignerNode.Open()
at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.VirtualProject.CreateDesigner(Urn origUrn, DocumentType editorType, DocumentOptions aeOptions, IManagedConnection con, String fileName)
at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.VirtualProject.Microsoft.SqlServer.Management.UI.VSIntegration.Editors.ISqlVirtualProject.CreateDesigner(Urn origUrn, DocumentType editorType, DocumentOptions aeOptions, IManagedConnection con, String fileName)
at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.ISqlVirtualProject.CreateDesigner(Urn origUrn, DocumentType editorType, DocumentOptions aeOptions, IManagedConnection con, String fileName)
at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.VsDocumentMenuItem.CreateDesignerWindow(IManagedConnection mc, DocumentOptions options)
===================================
Unable to find the requested .Net Framework Data Provider. It may not be installed. (System.Data)
------------------------------
Program Location:
at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
at Microsoft.SqlServer.Management.ConnectionUI.AdoDotNetConnectionProperties..ctor(String providerName)
at Microsoft.SqlServer.Management.ConnectionUI.SqlConnectionProperties..ctor()
解決方法
找 .NET Framework 的 Machine.config
C:\Windows\Microsoft.NET\Framework\v4.0.30319\CONFIG\Machine.config
C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\Machine.config
用管理員權限開啟 Machine.config ,搜尋關鍵字 DbProviderFactories,確認是否有多餘的 DbProviderFactories,然後刪掉它,存檔
再次開啟 SSMS、VS2013 SSDT 就恢復正常。
文章出自:http://www.dotblogs.com.tw/yc421206/archive/2014/06/11/145502.aspx
若有謬誤,煩請告知,新手發帖請多包涵