System.Configuration.ConfigurationErrorsException occurred .

本文关键字:occurred ConfigurationErrorsException Configuration System | 更新日期: 2023-09-27 17:53:00

目前,我正在尝试调试连接到oracle数据库的web应用程序。当我运行应用程序时,我收到以下错误:

System.Configuration.ConfigurationErrorsException occurred
  HResult=-2146232062
  Message=Error creating context 'spring.root': 
  Source=System.Configuration
  BareMessage=Error creating context 'spring.root': 
  Line=0
  StackTrace:
     at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
     at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
     at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
     at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
     at System.Web.HttpContext.GetSection(String sectionName)
     at System.Web.Configuration.HttpConfigurationSystem.GetSection(String sectionName)
     at System.Web.Configuration.HttpConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String configKey)
     at System.Configuration.ConfigurationManager.GetSection(String sectionName)
     at Spring.Util.ConfigurationUtils.GetSection(String sectionName)
     at Spring.Context.Support.ContextRegistry.InitializeContextIfNeeded()
     at Spring.Context.Support.ContextRegistry.GetContext()
     at Middleware.Data.Services.ServiceFactory.get_WellService() in C:'Dev'trunk'Middleware'Data'Services'ServiceFactory.cs:line 25
InnerException: Spring.Objects.Factory.ObjectCreationException
     HResult=-2146232832
     Message=Error creating object with name 'NHibernateSessionFactory' defined in 'assembly [Middleware.Data.DomainRepository, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5c61376b85e43767], resource [Middleware.Data.DomainRepository.Persistence.xml] line 15' : Initialization of object failed : 
     Source=Spring.Core
     ObjectName=NHibernateSessionFactory
     ResourceDescription=assembly [Middleware.Data.DomainRepository, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5c61376b85e43767], resource [Middleware.Data.DomainRepository.Persistence.xml] line 15
     StackTrace:
          at Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.InstantiateObject(String name, RootObjectDefinition definition, Object[] arguments, Boolean allowEagerCaching, Boolean suppressConfigure)
          at Spring.Objects.Factory.Support.AbstractObjectFactory.CreateAndCacheSingletonInstance(String objectName, RootObjectDefinition objectDefinition, Object[] arguments)
          at Spring.Objects.Factory.Support.AbstractObjectFactory.GetObjectInternal(String name, Type requiredType, Object[] arguments, Boolean suppressConfigure)
          at Spring.Objects.Factory.Support.AbstractObjectFactory.GetObject(String name)
          at Spring.Objects.Factory.Support.DefaultListableObjectFactory.GetObjectsOfType(Type type, Boolean includePrototypes, Boolean includeFactoryObjects)
          at Spring.Objects.Factory.ObjectFactoryUtils.ObjectsOfTypeIncludingAncestors(IListableObjectFactory factory, Type type, Boolean includePrototypes, Boolean includeFactoryObjects)
          at Spring.Dao.Support.PersistenceExceptionTranslationInterceptor.DetectPersistenceExceptionTranslators(IListableObjectFactory objectFactory)
          at Spring.Dao.Support.PersistenceExceptionTranslationInterceptor..ctor(IListableObjectFactory objectFactory)
          at Spring.Dao.Attributes.PersistenceExceptionTranslationAdvisor..ctor(IListableObjectFactory objectFactory, Type repositoryAttributeType)
          at Spring.Dao.Attributes.PersistenceExceptionTranslationPostProcessor.set_ObjectFactory(IObjectFactory value)
          at Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.ConfigureObject(String name, RootObjectDefinition definition, IObjectWrapper wrapper)
          at Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.InstantiateObject(String name, RootObjectDefinition definition, Object[] arguments, Boolean allowEagerCaching, Boolean suppressConfigure)
          at Spring.Objects.Factory.Support.AbstractObjectFactory.CreateAndCacheSingletonInstance(String objectName, RootObjectDefinition objectDefinition, Object[] arguments)
          at Spring.Objects.Factory.Support.AbstractObjectFactory.GetObjectInternal(String name, Type requiredType, Object[] arguments, Boolean suppressConfigure)
          at Spring.Objects.Factory.Support.AbstractObjectFactory.GetObject(String name)
          at Spring.Objects.Factory.Support.DefaultListableObjectFactory.GetObjectsOfType(Type type, Boolean includePrototypes, Boolean includeFactoryObjects)
          at Spring.Context.Support.AbstractApplicationContext.GetObjectsOfType(Type type, Boolean includePrototypes, Boolean includeFactoryObjects)
          at Spring.Context.Support.AbstractApplicationContext.RegisterObjectPostProcessors(IConfigurableListableObjectFactory objectFactory)
          at Spring.Context.Support.AbstractApplicationContext.Refresh()
          at Spring.Context.Support.XmlApplicationContext..ctor(XmlApplicationContextArgs args)
          at Spring.Context.Support.XmlApplicationContext..ctor(String name, Boolean caseSensitive, String[] configurationLocations)
          at _dynamic_Spring.Context.Support.XmlApplicationContext..ctor(Object[] )
          at Spring.Reflection.Dynamic.SafeConstructor.Invoke(Object[] arguments)
          at Spring.Context.Support.ContextHandler.RootContextInstantiator.InvokeContextConstructor(ConstructorInfo ctor)
          at Spring.Context.Support.ContextHandler.ContextInstantiator.InstantiateContext()
          at Spring.Context.Support.ContextHandler.InstantiateContext(IApplicationContext parentContext, Object configContext, String contextName, Type contextType, Boolean caseSensitive, String[] resources)
          at Spring.Context.Support.ContextHandler.Create(Object parent, Object configContext, XmlNode section)
     InnerException: Oracle.DataAccess.Client.OracleException
          HResult=-2147467259
          Message=""
          ErrorCode=-2147467259
          StackTrace:
               at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck, Int32 isRecoverable)
               at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src)
               at Oracle.DataAccess.Client.OracleConnection.Open()
               at Spring.Data.NHibernate.LocalSessionFactoryObject.DbProviderWrapper.GetConnection()
               at NHibernate.Tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.Prepare()
               at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.GetReservedWords(Dialect dialect, IConnectionHelper connectionHelper)
               at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.Update(ISessionFactory sessionFactory)
               at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners)
               at NHibernate.Cfg.Configuration.BuildSessionFactory()
               at Spring.Data.NHibernate.LocalSessionFactoryObject.NewSessionFactory(Configuration config)
               at Spring.Data.NHibernate.LocalSessionFactoryObject.AfterPropertiesSet()
               at Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.InvokeInitMethods(Object target, String name, IConfigurableObjectDefinition definition)
               at Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.ConfigureObject(String name, RootObjectDefinition definition, IObjectWrapper wrapper)
               at Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.InstantiateObject(String name, RootObjectDefinition definition, Object[] arguments, Boolean allowEagerCaching, Boolean suppressConfigure)
          InnerException: 

从查看最内部的内部异常,它看起来像我的应用程序是有困难连接到Oracle。以下是我的连接字符串,我已经使用sqlplus手动验证了它们是否正常工作。

  <add name="MyApp"
   connectionString="Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SID=orcl)));User Id=myID;Password=myPassword;"
   providerName="OracleODP-11-2.0" />
<add name="BlenderConnection"
    connectionString="Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SID=orcl)));User Id=ppdID;Password=ppdPassword;"
    providerName="Oracle.ManagedDataAccess.Client"/>
<add name="Oracle"
     connectionString="Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SID=orcl)));User Id=myID;Password=myPassword;"
     providerName="Oracle.ManagedDataAccess.Client"/>

有人有什么建议吗?TIA。

System.Configuration.ConfigurationErrorsException occurred .

我停止得到上述异常的方法是卸载TeamCity并从IIS管理器中删除我的应用程序的网站。

澄清一下,我不认为问题出在TeamCity上——问题是我运行了一个构建来部署我的应用程序,它将网站添加到IIS中,并在我试图调试网站时引起了某种冲突,从而在我的问题中产生了错误。

同样,问题的一部分是我收到了这个异常:

Exception Details: System.BadImageFormatException: Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.
BadImageFormatException: Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
[BadImageFormatException: Could not load file or assembly 'Oracle.DataAccess, Version=2.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0

为了解决上述问题,我安装了32位客户端,但错误地安装了oracle 12的客户端,实际上我需要oracle 11g 32位客户端:

ODAC121021Xcopy_32bit.zip

为了解决这个问题,我卸载了上面的程序,并确保从C:'Windows'assembly. dll中显式卸载了所有Oracle.DataAccess.dll 2.121项然后我安装了正确的Oracle 11g 32位客户端:

 ODTwithODAC1120320_32bit.zip

接下来,我更新了这个文件并运行它:

C:'app'oracle'product'11.2.0'dbhome_1'bin'selecthome.bat

然后我打开这个文件:

C:'oracle'configure.bat

要确保它正确地将2.121.2.0的所有值更改为2.112.3,并像这样运行文件:

C:'oracle>configure.bat all ORACLE_HOME true

一旦这个文件被执行,你所有的机器。在C:'Windows'Microsoft.NET'Framework'v2.0.50727' config 'machine中找到的配置文件。配置应该有Oracle的版本号。数据访问设置正确

但是,如果可以的话,我强烈建议您使用最近刚刚发布的托管。net客户端,而不是乱用上面的代码:

http://www.oracle.com/technetwork/topics/dotnet/index - 085163. - html

不幸的是,现在我必须处理未管理的客户端。