I have been trying to find out the issue faced for some documents while uploading in libraries using list.asmx service in web application.
The steps i follow:

  1. Uploads document using copy service.
  2. Update uploaded document properties.

I am facing issue for some documents while updating their properties. I don't know whether it is document size or document type which is causing problem. If i say it is document size or type, it might be wrong as i have uploaded similar document with same type and larger size with no exception.
Following the code i am using to update document's properties.

        XmlDocument doc = new XmlDocument();
        XmlElement batch = doc.CreateElement("Batch");
        batch.SetAttribute("OnError", "Continue");
        batch.SetAttribute("ListVersion", "1");
        batch.SetAttribute("ViewName", viewname);
        batch.InnerXml = "<Method ID='1' Cmd='Update'>" +
                         "<Field Name='ID'>" + id + "</Field>" +
                         "<Field Name='" + columnName + "'>" + colValue + "</Field></Method>";
        XElement xElement = Utility.ToXElement(batch);

        //ListsSoapClient object
        var proxy = Utility.GetServerListProxy();
        proxy.UpdateListItems(listname, xElement);

Exception is


Fault exception details:

Cannot access a closed Stream.

Thanks in advance.

  • Do you know which line throws the exception?
    – user2536
    May 8 '15 at 7:23
  • UpdateListItems() is the method which throws exception.
    – Ashish
    May 8 '15 at 7:24
  • This error occurs when you have two using statements for a Stream class inside each other and the outer using statement is still trying to use the variable from the second using statement.
    – user2536
    May 8 '15 at 7:26
  • There is neither using is used nor Stream class. Works fine for many documents but failing for few.
    – Ashish
    May 8 '15 at 7:30

Thanks for commenting.

Later i figure out that, the document i was trying to upload had some weird characters other than special characters in file properties attributes.

So after removing those characters, it is working fine.


I also received this error when using SPServices on a root site. The only solution was to create a sub site and use that instead. This is a known bug in certain versions of SPServices.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.