2016-05-06 36 views
-1

我們只是建立一個新的PCI兼容的服務器,當我部署我的asp.net應用它,我得到這個錯誤信息:ASP.NET應用程序7

與ADO.NET提供商不變的名稱「System.Data.SqlClient」未在計算機或應用程序配置文件中註冊,或者無法加載。詳情請參閱內部例外。

我再次檢查我的配置文件,卸載EF並重新安裝它在所有的項目。我在部署後看到bin文件夾中的DLL(我們使用CI和team city和octopus)。我在網上查了幾乎所有的帖子,以找到沒有成功的解決方案

當我將這個應用程序部署到非PCI兼容服務器時,它工作正常。我不知道什麼會導致它!

的web.config

<configSections> 
 
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/> 
 
    </configSections> 
 

 
<!-- Connection String --> 
 
<add name="BondedBuilderModel" connectionString="data source=SqlServer;initial catalog=mydb;integrated security=false;User Id=user; Password =pass;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient"/> 
 
     
 

 
<!-- Provider --> 
 
    <entityFramework> 
 
     <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"> 
 
      <parameters> 
 
       <parameter value="System.Data.SqlClient"/> 
 
      </parameters> 
 
     </defaultConnectionFactory> 
 
     <providers> 
 
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/> 
 
     </providers> 
 
    </entityFramework>

** **異常

The ADO.NET provider with invariant name 'System.Data.SqlClient' is either not registered in the machine or application config file, or could not be loaded. See the inner exception for details. 
 
    at System.Data.Entity.Infrastructure.DependencyResolution.DefaultProviderFactoryResolver.<GetService>b__0(ArgumentException e, String n) 
 
    at System.Data.Entity.Infrastructure.DependencyResolution.DefaultProviderFactoryResolver.GetService(Type type, Object key, Func`3 handleFailedLookup) 
 
    at System.Data.Entity.Infrastructure.DependencyResolution.DefaultProviderFactoryResolver.GetService(Type type, Object key) 
 
    at System.Data.Entity.Infrastructure.DependencyResolution.CachingDependencyResolver.<>c__DisplayClass1.<GetService>b__0(Tuple`2 k) 
 
    at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) 
 
    at System.Data.Entity.Infrastructure.DependencyResolution.CachingDependencyResolver.GetService(Type type, Object key) 
 
    at System.Data.Entity.Infrastructure.DependencyResolution.ResolverChain.<>c__DisplayClass3.<GetService>b__0(IDbDependencyResolver r) 
 
    at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext() 
 
    at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate) 
 
    at System.Data.Entity.Infrastructure.DependencyResolution.ResolverChain.GetService(Type type, Object key) 
 
    at System.Data.Entity.Infrastructure.DependencyResolution.RootDependencyResolver.GetService(Type type, Object key) 
 
    at System.Data.Entity.Infrastructure.DependencyResolution.ResolverChain.<>c__DisplayClass3.<GetService>b__0(IDbDependencyResolver r) 
 
    at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext() 
 
    at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate) 
 
    at System.Data.Entity.Infrastructure.DependencyResolution.ResolverChain.GetService(Type type, Object key) 
 
    at System.Data.Entity.Infrastructure.DependencyResolution.CompositeResolver`2.GetService(Type type, Object key) 
 
    at System.Data.Entity.Infrastructure.DependencyResolution.DbDependencyResolverExtensions.GetService[T](IDbDependencyResolver resolver, Object key) 
 
    at System.Data.Entity.Internal.LazyInternalConnection.CreateConnectionFromProviderName(String providerInvariantName) 
 
    at System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection) 
 
    at System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config) 
 
    at System.Data.Entity.Internal.LazyInternalConnection.Initialize() 
 
    at System.Data.Entity.Internal.LazyInternalConnection.get_ProviderName() 
 
    at System.Data.Entity.Internal.LazyInternalContext.get_ProviderName() 
 
    at System.Data.Entity.Internal.DefaultModelCacheKeyFactory.Create(DbContext context) 
 
    at System.Data.Entity.Internal.LazyInternalContext.InitializeContext() 
 
    at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) 
 
    at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() 
 
    at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() 
 
    at System.Data.Entity.Internal.Linq.InternalSet`1.ActOnSet(Action action, EntityState newState, Object entity, String methodName) 
 
    at System.Data.Entity.Internal.Linq.InternalSet`1.Add(Object entity) 
 
    at System.Data.Entity.DbSet`1.Add(TEntity entity) 
 
    at BondedBuilders.Data.LoggerData.LogError(String errorType, String errorMessage, String stackTrace) in c:\TeamCity\buildAgent\work\f206d6cc22a03ea8\source\web\BondedBuilders.Data\LoggerData.cs:line 31 
 
    at BondedBuilders.Data.LoggerData.LogError(Exception exception) in c:\TeamCity\buildAgent\work\f206d6cc22a03ea8\source\web\BondedBuilders.Data\LoggerData.cs:line 11 
 
    at BondedBuilders.WebClient.Templates.Main.HandleSystemError(Exception ex) in c:\TeamCity\buildAgent\work\f206d6cc22a03ea8\source\web\BondedBuilders.WebClient\Templates\Main.Master.cs:line 18 
 
    at BondedBuilders.WebClient.Default.ButtonContinue_Click(Object sender, EventArgs e) in c:\TeamCity\buildAgent\work\f206d6cc22a03ea8\source\web\BondedBuilders.WebClient\Default.aspx.cs:line 95 
 
    at System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) 
 
    at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) 
 
    at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) 
 
    at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) 
 
    at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) 
 
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

+0

「有關詳細信息,請參閱內部例外。」內部例外說什麼? –

+0

[Entity Framework ADO.NET Sql.Data.Client provider not found]可能的重複項(http://stackoverflow.com/questions/20111583/entity-framework-ado-net-sql-data-client-provider-not-發現) –

+0

我嘗試了關於該帖子的所有建議,沒有任何工作。正如你從註釋中注意到那個問題還沒有解決。 – mghz

回答

2

對於通過這個運行的任何人,終於想通了。
在machine.config文件:

32位

%windir%\Microsoft.NET\Framework\[version]\config\machine.config 

64位

%windir%\Microsoft.NET\Framework64\[version]\config\machine.config 

有限定的dbproviders截面,但它還有一個右後一個像這樣定義<DbProviderFactories/>

一旦第二個被刪除,應用程序開始工作,上面的錯誤停止顯示。
問題仍然是爲什麼機器配置中定義了兩個部分。沒有人手動編輯這個文件!

+0

好找!我有一個預感這個問題是在machine.config中,這就是爲什麼我在我的評論中如此關注以及爲什麼我建議進行比較。很高興你找到了它。 – Arman