简体   繁体   中英

ASP.NET app with EF 6.1.3 in IIS 7

We just setup a new PCI compliant server and when I deploy my asp.net app to it I get this errors message:

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.

I double checked my config file, uninstalled EF and reinstalled it in all the projects. I see the DLL in the bin folder after deployment (we use CI with team city and octopus). I checked almost all the post online for solutions to no success.

When I deploy this app to a non PCI compliant server it works fine. I'm out of ideas to what can cause it!!

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> 

** Exception **

 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) 

For anyone running through this, finally figured it out.
In the machine.config file:

32-bit

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

64-bit

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

There was a dbproviders section defined but right after it there was another one defined like this <DbProviderFactories/>

As soon as this second one was deleted the app started to work and the error above stopped showing up.
The question remains why would the machine config have both sections defined. No one manually edited this file!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM