System.Configuration.ConfigurationErrorsException 发生创建上下文错误 'spring.root' -- InnerException:Client.OracleException
System.Configuration.ConfigurationErrorsException occurred Error creating context 'spring.root' -- InnerException: Client.OracleException
目前,我正在尝试调试连接到 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.
我停止获得上述异常的方法是卸载 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 中明确卸载所有 Oracle.DataAccess.dll 2.121 项。然后我安装了正确的 Oracle 11g 32 位客户端:
ODTwithODAC1120320_32bit.zip
接下来,我更新了这个文件 运行 它:
C:\app\oracle\product.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.config 等位置找到的所有 machine.config 文件都应该具有Oracle.DataAccess 的版本号设置正确。
但是,与其乱搞上述内容,我强烈建议您使用最近发布的托管 .NET 客户端,如果可以的话:
http://www.oracle.com/technetwork/topics/dotnet/index-085163.html
不幸的是,现在我必须使用非托管客户端。
目前,我正在尝试调试连接到 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.
我停止获得上述异常的方法是卸载 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 中明确卸载所有 Oracle.DataAccess.dll 2.121 项。然后我安装了正确的 Oracle 11g 32 位客户端:
ODTwithODAC1120320_32bit.zip
接下来,我更新了这个文件 运行 它:
C:\app\oracle\product.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.config 等位置找到的所有 machine.config 文件都应该具有Oracle.DataAccess 的版本号设置正确。
但是,与其乱搞上述内容,我强烈建议您使用最近发布的托管 .NET 客户端,如果可以的话:
http://www.oracle.com/technetwork/topics/dotnet/index-085163.html
不幸的是,现在我必须使用非托管客户端。