在 Windows 服务中托管的 WCF 服务 - 错误/预期的命名空间

WCF Service hosted in a Windows Service - Wrong / Expected Namespace

我安装了一个 WCF 服务,它在启动时不断抛出意外的命名空间异常。奇怪的是,如果我通过 IIS 托管它或通过 WCFSvcHost 在 visual studio 中托管它,它工作得很好。设置安装程序 ServiceHost 时,我无法在设计器中找到任何命名空间声明。有什么想法吗?

我在使用其他主机时对数据进行序列化和反序列化没有遇到任何问题。

[DataContract(Name = "ClientSite", Namespace = "http://IAmRedacted.com/IAmRedacted.WCF.DataContract")]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)]
public class ClientSite : IAppServerRequest

异常:

Service cannot be started. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.Serialization.SerializationException: Error in line 1 position 153. Expecting element 'ClientSite' from namespace 'http://IAmRedacted.com/IAmRedacted.WCF.DataContract'.. Encountered 'Element' with name 'ClientSite', namespace 'http://schemas.datacontract.org/2004/07/IAmRedacted.Framework.WCF'. at System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName, DataContractResolver dataContractResolver) at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver) at System.Runtime.Serialization.DataContractSerializer.ReadObject(XmlDictionaryReader reader, Boolean verifyObjectName) at IAmRedacted.WCF.ClientSite.LoadClientSiteData()

'IAmRedacted.Framework.WCF' 是我使用的旧名称空间声明,但后来被简化了,我无法在任何地方找到对它的引用。

我不知道因为我使用 Windows 服务作为主机,XML 文件被保存到 /windows 而不是本地目录。无效的命名空间来自 /windows/syswow64.

中仍然存在的旧 XML 文件