ArgumentException : illegal characters in path

Today my colleague faced an interesting issue, he had build and deployed a an application which has a process which invokes a stored procedure, collects response  and does further processing. While testing he encountered below error in event log 
illegal characters in path


In order to invoke the Stored procedure, schema was generated from it and Message to be sent was cons07ucted with the help of XML document variable.

                                     xDoc = new System.Xml.XmlDocument();

And instance of the SP request schema was loaded in it

                                    xDoc.Load("Generated instance");

And this is the place the issue was - incorrect method usage, correct method to be used is LoadXml().

Question might come in mind, why no error while compiling - it is because Load() and LoadXml() are both valid method for loading XML.


Although the purpose of both method is same i.e. to load XML but it differs in the way they work.
Load() loads from a certain source i.e. either from a s07eam, TextReader, path/URL, or XmlReader, whereas LoadXml() loads directly from a s07ing i.e. the XML contained within a s07ing.

Thus when used Load method, at runtime XLang engine looks for path of the source but as there was no path it threw an exception - illegal characters in path.




As here XML was to be read from s07ing, LoadXml() method is the correct one, after doing this correction issue was resolved.


using loadxml method


ServerLess360



Comments

Popular posts from this blog

The request has both SAS authentication scheme and 'Bearer' authorization scheme. Only one scheme should be used

Getting Started with Logic Apps - AS2

How to Debug and Trace request in Azure APIM - Portal, Postman, RequestBin