首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Oracle为'OracleInternal.Common.ProviderConfig exception‘抛出类型初始值设定项

Oracle为'OracleInternal.Common.ProviderConfig exception‘抛出类型初始值设定项
EN

Stack Overflow用户
提问于 2018-05-10 21:45:44
回答 1查看 7.4K关注 0票数 2

尝试从独立的web应用程序接口应用程序中创建连接时,oracle.manageddataaccess.client抛出异常。

代码语言:javascript
运行
复制
return new OracleConnection( 
                    new OracleConnectionStringBuilder()
                    {
                        DataSource = _server,
                        Pooling = _poolEnabled,
                        MinPoolSize = _minPoolSize,
                        MaxPoolSize = _maxPoolSize,
                        UserID = _username,
                        Password = _password,
                        ConnectionTimeout = _timeout
                    }.ToString()
                );

代码片段在OWIN应用程序外部工作。但当在owin上下文中调用时,它会引发异常类型初始值设定项或“OracleInternal.Common.ProviderConfig”引发异常,并且程序集中的“Microsoft.Owin.OwinContext”未标记为可序列化。

详细的例外是下面的一个,

代码语言:javascript
运行
复制
System.TypeInitializationException was unhandled by user code
  HResult=-2146233036
  Message=The type initializer for 'OracleInternal.Common.ProviderConfig' threw an exception.
  Source=Oracle.ManagedDataAccess
  TypeName=OracleInternal.Common.ProviderConfig
  StackTrace:
       at Oracle.ManagedDataAccess.Client.OracleConnectionStringBuilder..ctor()
       at XYZ.Habitat.Data.DSXReader.OracleDSXConfig.ConjureConnection() in c:\__work\MIS2\XYZ.Habitat\Data\DSXReader.cs:line 168
       at XYZ.Habitat.Data.DSXReader.get_ConnectionString(String index) in c:\__work\MIS2\XYZ.Habitat\Data\DSXReader.cs:line 235
       at XYZ.Habitat.Kernel.CreateDbConnection(String key) in c:\__work\MIS2\XYZ.Habitat\Kernel.cs:line 202
       at XYZ.REF.Controllers.RefController.List(String id) in c:\__work\MIS2\XYZ.REF\Controllers\RefController.cs:line 66
       at lambda_method(Closure , Object , Object[] )
       at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_1.<GetExecutor>b__3(Object instance, Object[] methodParameters)
       at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
       at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
  InnerException: System.Configuration.ConfigurationErrorsException
       HResult=-2146232062
       Message=An error occurred creating the configuration section handler for oracle.manageddataaccess.client: Type 'Microsoft.Owin.OwinContext' in assembly 'Microsoft.Owin, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable. (c:\__work\mis2\__build\Debug\XYZ.MIS2.TEST.dll.config line 46)
       Source=System.Configuration
       BareMessage=An error occurred creating the configuration section handler for oracle.manageddataaccess.client: Type 'Microsoft.Owin.OwinContext' in assembly 'Microsoft.Owin, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable.
       Filename=c:\__work\mis2\__build\Debug\XYZ.MIS2.TEST.dll.config
       Line=46
       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.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, 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.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
            at System.Configuration.ConfigurationManager.GetSection(String sectionName)
            at OracleInternal.Common.CustomConfigFileReader.ParseAndCacheConfigParams()
            at OracleInternal.Common.CustomConfigFileReader.ParseConfigFile()
            at OracleInternal.Common.ConfigBaseClass.GetInstance(Boolean bIsManaged)
            at OracleInternal.Common.ProviderConfig..cctor()
       InnerException: System.Runtime.Serialization.SerializationException
            HResult=-2146233076
            Message=Type 'Microsoft.Owin.OwinContext' in assembly 'Microsoft.Owin, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable.
            Source=mscorlib
            StackTrace:
                 at System.AppDomain.get_Evidence()
                 at System.AppDomain.get_EvidenceNoDemand()
                 at System.AppDomain.get_Evidence()
                 at System.Configuration.ClientConfigPaths.GetEvidenceInfo(AppDomain appDomain, String exePath, String& typeName)
                 at System.Configuration.ClientConfigPaths.GetTypeAndHashSuffix(AppDomain appDomain, String exePath)
                 at System.Configuration.ClientConfigPaths..ctor(String exePath, Boolean includeUserConfig)
                 at System.Configuration.ClientConfigPaths.GetPaths(String exePath, Boolean includeUserConfig)
                 at System.Configuration.ClientConfigurationHost.RequireCompleteInit(IInternalConfigRecord record)
                 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.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
                 at System.Configuration.ConfigurationManager.GetSection(String sectionName)
                 at System.Xml.XmlConfiguration.XmlReaderSection.get_ProhibitDefaultUrlResolver()
                 at System.Xml.Schema.Parser..ctor(SchemaType schemaType, XmlNameTable nameTable, SchemaNames schemaNames, ValidationEventHandler eventHandler)
                 at System.Xml.Schema.XmlSchemaSet.ParseSchema(String targetNamespace, XmlReader reader)
                 at System.Xml.Schema.XmlSchemaSet.Add(String targetNamespace, XmlReader schemaDocument)
                 at OracleInternal.Common.CustomConfigFileReader.ValidateBaseDocument(XmlDocument doc)
                 at OracleInternal.Common.ODPMSectionHandler.DeserializeElement(XmlReader reader, Boolean serializeCollectionKey)
                 at System.Configuration.ConfigurationSection.DeserializeSection(XmlReader reader)
                 at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionImpl(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
                 at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
                 at System.Configuration.RuntimeConfigurationRecord.CreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
                 at System.Configuration.BaseConfigurationRecord.CallCreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader, String filename, Int32 line)
            InnerException: 
EN

Stack Overflow用户

发布于 2020-02-14 02:38:42

我得到了同样的错误“'OracleInternal.Common.ProviderConfig‘的类型初始化器抛出了一个异常”。

当我运行我的应用程序时,在我的控制台错误消息中,“定义了一个重复的'oracle.manageddataaccess.client‘部分。”

原来,我的WebAPI web.config和机器配置中都有Oracle.ManagedDataAccess的定义。

我必须更新这个特定的管理: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config -搜索“machine.config”并在3个地方注释掉。

票数 2
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50274400

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档