简体   繁体   English

IIS 7中具有EF 6.1.3的ASP.NET应用

[英]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: 我们只是设置了一个新的PCI兼容服务器,当我将asp.net应用程序部署到该服务器时,我收到以下错误消息:

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. 具有不变名称'System.Data.SqlClient'的ADO.NET提供程序未在计算机或应用程序配置文件中注册,或无法加载。 See the inner exception for details. 有关详细信息,请参见内部异常。

I double checked my config file, uninstalled EF and reinstalled it in all the projects. 我仔细检查了配置文件,卸载了EF,然后将其重新安装到所有项目中。 I see the DLL in the bin folder after deployment (we use CI with team city and octopus). 部署后,我在bin文件夹中看到DLL(我们将CI与team city和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. 当我将此应用程序部署到不兼容PCI的服务器时,它可以正常工作。 I'm out of ideas to what can cause it!! 我不知道是什么原因造成的!

web.config 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: 在machine.config文件中:

32-bit 32位

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

64-bit 64位

%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/> 定义了一个dbproviders部分,但紧接着又定义了一个类似<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!! 没有人手动编辑此文件!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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