web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Encountered unexpected namespace - The namespace must be empty - Parameter name: ns

(0) ShareShare
ReportReport
Posted on by 238

Hi,

Were using WCF (running as a Windows Service) to run custom code written in C#. We ran it in 2015 and it worked perfectly fine. Were now looking to upgrade to 2016/365 on-prem. We spinned up a sandbox environment which we upgraded to 365 and started QA'ing. We're Half ways into this, and most functionality works without any flaws with the exception of one function which produces inconsistent results. 

I'm by all means not a coder, so easy there... I'm just basically trying to understand whether its a code issue or a result of something else. As far as i understand, if it functioned well in 2015, then it should function fine in 365. Or not? that would be a bummer...

The error indicates line 553 in InvoiceCreationHelper.cs. I dont know whether this is the issue or as a result of the issue. The line says the following: "String action = invoice.ToJson();". Yes, the custom code is supposed to created an invoice

Here is the full exception:

Encountered unexpected namespace 'schemas.microsoft.com/.../Contracts'. The namespace must be empty.
Parameter name: ns

   at System.Runtime.Serialization.Json.XmlJsonWriter.WriteStartElement(String prefix, String localName, String ns)
   at System.Runtime.Serialization.XmlWriterDelegator.WriteStartElement(String prefix, String localName, String ns)
   at System.Runtime.Serialization.Json.JsonWriterDelegator.WriteStartElement(String prefix, String localName, String ns)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteExtensionDataMember(XmlWriterDelegator xmlWriter, ExtensionDataMember member)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteExtensionData(XmlWriterDelegator xmlWriter, ExtensionDataObject extensionData, Int32 memberIndex)
   at WriteEntityReferenceToJson(XmlWriterDelegator , Object , XmlObjectSerializerWriteContextComplexJson , ClassDataContract , XmlDictionaryString[] )
   at System.Runtime.Serialization.Json.JsonClassDataContract.WriteJsonValueCore(XmlWriterDelegator jsonWriter, Object obj, XmlObjectSerializerWriteContextComplexJson context, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.Json.XmlObjectSerializerWriteContextComplexJson.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithoutXsiType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContextComplex.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
   at WriteReccurenceInvoiceToJson(XmlWriterDelegator , Object , XmlObjectSerializerWriteContextComplexJson , ClassDataContract , XmlDictionaryString[] )
   at System.Runtime.Serialization.Json.JsonClassDataContract.WriteJsonValueCore(XmlWriterDelegator jsonWriter, Object obj, XmlObjectSerializerWriteContextComplexJson context, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.Json.XmlObjectSerializerWriteContextComplexJson.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithoutXsiType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.Json.DataContractJsonSerializer.InternalWriteObjectContent(XmlWriterDelegator writer, Object graph)
   at System.Runtime.Serialization.Json.DataContractJsonSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph)
   at System.Runtime.Serialization.XmlObjectSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
   at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
   at System.Runtime.Serialization.Json.DataContractJsonSerializer.WriteObject(XmlDictionaryWriter writer, Object graph)
   at System.Runtime.Serialization.Json.DataContractJsonSerializer.WriteObject(Stream stream, Object graph)
   at PluginCore.Extentions.XmlObjectSerializerExtensions.Serialize(XmlObjectSerializer serializer, Object graph)
   at PluginCore.Extentions.JsonExtensions.ToJson(Object graph)
   at Dev.CRMPlugin.Helpers.InvoiceCreationHelper.GenerateInvoice(Boolean withCouponCode, mesh_globalDevsettings DevSettings, Nullable`1 orderId, Boolean forReccurring, Boolean billableOrdersModule, Boolean isfirstApplianceInvoice, Boolean generateOnlyOneTime, List`1 ordIdBillableModuleForQPR, Boolean needUpdateCustomersDates, Boolean isFromCustomersPortal) in D:\Projects\Dev\GIT\Dev-phase1\SOURCE\Dev\Dev.CRMPlugin\Helpers\InvoiceCreationHelper.cs:line 553

*This post is locked for comments

I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans