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

357 views Asked by At

I have a WCF Service that I've installed that keeps throwing an unexpected namespace exception upon startup. The odd part is that it works just fine if I host it via IIS or in visual studio via the WCFSvcHost. I'm unable to find any namespace declaration in the designer when setting up the installer ServiceHost. Any ideas?

I've had no issues serializing and deserializing the data when using the other hosts.

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

Exception:

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' is an old namespace declaration that I used, but it's since been simplified and I'm unable to find a reference to it anywhere.

1

There are 1 answers

0
Dimenus On BEST ANSWER

I didn't know that because I was using a Windows Service as a host, the XML file was saved to /windows rather than the local directory. The invalid namespace was from an old XML file that still existed in /windows/syswow64.