Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

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

Posted on by 230

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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans