【发布时间】:2017-12-14 20:09:49
【问题描述】:
我正在从门户应用程序调用我的 WCF 方法。
我的 WCF 设置如下:
[ServiceContract]
public interface ILogging
{
[OperationContract]
[ServiceKnownType(typeof(ErrorExceptionInformation))]
void LogException(ErrorExceptionInformation exception);
}
public class Logging : ILogging
{
public void LogException(ErrorExceptionInformation exception)
{
LogProviderManager.Default.WriteLog(exception.Application, exception.Exception, true, exception.Category);
}
}
[DataContract]
public class ErrorExceptionInformation
{
[DataMember]
public string Application { get; set; }
[DataMember]
public Exception Exception { get; set; }
[DataMember]
public string Category { get; set; }
}
这就是我在门户应用程序中调用的方式:
ErrorExceptionInformation information = new ErrorExceptionInformation
{
Exception = errorToLog,
Application = Models.Constants.ErrorLog.ErrorLocation,
Category = Models.Constants.ErrorLog.AdminPortalEnvironmentName
};
new LoggingClient().LogException(information);
但是我不断收到以下错误: 如果您使用 DataContractSerializer 或将任何静态未知的类型添加到已知类型列表中,请考虑使用 DataContractResolver - 例如,通过使用 KnownTypeAttribute 属性或将它们添加到传递给序列化程序的已知类型列表中。有关详细信息,请参阅 InnerException。
【问题讨论】:
标签: c# visual-studio wcf datacontractserializer