【问题标题】:ODP.NET IIS 7.5 WEB API errorODP.NET IIS 7.5 WEB API 错误
【发布时间】:2013-09-27 22:12:13
【问题描述】:

我刚刚将我的 ASP.NET 4.0 C# 网站从 IIS 6 迁移到通过 nuget Oracle Managed 和 ODP.NET Managed 包安装到我的项目的 IIS 7.5。尝试访问我的 ASP.NET WEB API 时出现此错误。我该如何解决这个问题?谢谢

<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>
The 'ObjectContent`1' type failed to serialize the response body for content type 'application/xml; charset=utf-8'.
</ExceptionMessage>
<ExceptionType>System.InvalidOperationException</ExceptionType>
<StackTrace/>
<InnerException>
<Message>An error has occurred.</Message>
<ExceptionMessage>
Exception has been thrown by the target of an invocation.
</ExceptionMessage>
<ExceptionType>System.Reflection.TargetInvocationException</ExceptionType>
<StackTrace>
at System.RuntimeFieldHandle.GetValue(RtFieldInfo field, Object instance, RuntimeType fieldType, RuntimeType declaringType, Boolean& domainInitialized) at System.Reflection.RtFieldInfo.InternalGetValue(Object obj, Boolean doVisibilityCheck, Boolean doCheckConsistency) at System.Reflection.RtFieldInfo.GetValue(Object obj) at System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow) at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) at System.Data.EntityClient.EntityConnection.GetFactory(String providerString) at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString) at System.Data.EntityClient.EntityConnection..ctor(String connectionString) 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.CreateObjectContextFromConnectionModel() 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.GetEnumerator() at System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator() at WriteArrayOfADDRESSTYPEToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , CollectionDataContract ) at System.Runtime.Serialization.CollectionDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context) at System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle) at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeAndVerifyType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, Boolean verifyKnownType, RuntimeTypeHandle declaredTypeHandle, Type declaredType) at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiTypeAtTopLevel(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle originalDeclaredTypeHandle, Type graphType) at System.Runtime.Serialization.DataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) at System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) at System.Runtime.Serialization.DataContractSerializer.WriteObject(XmlWriter writer, Object graph) at System.Net.Http.Formatting.XmlMediaTypeFormatter.<>c__DisplayClass7.<WriteToStreamAsync>b__6() at System.Threading.Tasks.TaskHelpers.RunSynchronously(Action action, CancellationToken token)
</StackTrace>
<InnerException>
<Message>An error has occurred.</Message>
<ExceptionMessage>
The type initializer for 'Oracle.DataAccess.Client.OracleClientFactory' threw an exception.
</ExceptionMessage>
<ExceptionType>System.TypeInitializationException</ExceptionType>
<StackTrace/>
<InnerException>
<Message>An error has occurred.</Message>
<ExceptionMessage>
The provider is not compatible with the version of Oracle client
</ExceptionMessage>
<ExceptionType>Oracle.DataAccess.Client.OracleException</ExceptionType>
<StackTrace>
at Oracle.DataAccess.Client.OracleInit.Initialize() at Oracle.DataAccess.Client.OracleClientFactory..cctor()
</StackTrace>
</InnerException>
</InnerException>
</InnerException>
</Error>

【问题讨论】:

    标签: c# asp.net asp.net-web-api iis-7.5 odp.net


    【解决方案1】:

    与问题陈述相反,应用程序似乎正在使用非托管客户端(命名空间 Oracle.DataAccess.Client)而不是托管客户端(命名空间 Oracle.ManagedDataAccess.Client),并且它与计算机上安装的 Oracle 客户端不兼容。

    【讨论】:

    • 你认为是因为新服务器没有安装ODAC吗?
    • 服务器管理员确认服务器上安装了 ODAC 32bit。我还让他为我网站的应用程序池启用 32 位。有什么想法吗?
    • 您可以尝试在服务器上部署 ODAC 64 位 Xcopy 部署包并配置应用程序以使用它。由于我不知道应用程序的结构如何,因此我无法提供太多建议。就个人而言,如果应用程序不依赖于仅在非托管客户端中可用的功能,我会切换到托管客户端并将 DLL 与您的应用程序一起部署。根据服务器的配置方式,您的管理员可能必须授予您的应用程序足够的权限以执行通过网络通信的代码。
    猜你喜欢
    • 2011-05-16
    • 2017-02-24
    • 2015-10-18
    • 2011-08-14
    • 1970-01-01
    • 2013-12-06
    • 1970-01-01
    • 1970-01-01
    • 2018-06-23
    相关资源
    最近更新 更多