ServerDocument Strange Issue Question RRS feed

  • Question

  • could someone with experience with vsto help me out here. i'm trying to accomplish the following senerio:

    asp page that load a word document with cached dataset . load a dataset , use serverdocument to inject it into the document and then send it to the client

    the problem:

    if i just send the byte array the code run fine but when opened at the user  machine it does not contain any data 

    if i send the mydocument.document property , it contains garbage and can't be opened .

    here's the code 

     Dim lfilepath As String = Server.MapPath("WordDocument1.doc")
        Dim lbytes() As Byte = getMasterDoc(lfilepath)
        Dim x As ServerDocument = New ServerDocument(lbytes, ".DOC")
        Dim hostI As CachedDataHostItem = x.CachedData.HostItems("WordDocument1.ThisDocument")
        Dim dataI As CachedDataItem = hostI.CachedData(0)
        Dim lDataSet As DataSet = GetDataset()
        lDataSet.DataSetName = "MyDataSet"
        lbytes = x.Document
        Response.ContentType = "application/"
        Response.AddHeader("Content-Disposition", "attachment; filename = MyDoc.doc")
        Response.OutputStream.Write(lbytes, 0, lbytes.Length)



    Monday, March 28, 2011 9:17 PM

All replies

  • Hi blah,

    Thanks for posting in the MSDN Forum.

    Would you please tell me where you initialize you cached dataset? Is it possible that you cache database hasn’t been initialized when you request it from the client? Please ensure you cache dataset has been initialized when your application start.

    Have a good day,


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, March 30, 2011 6:08 AM
  • hi Tom,

    I have tried to open the source word document in word before running my asp application, to initialized the cached dataset . but myserverdocument.document bytes array still return garbage when written to disk


    here's a some content from it: i've got 96 page of this when writting the byte array to disk ("mydoc.doc")

    ‡ï…½ƒÑ}QÒà %v/¥C/£} á(h" Û ëÛOÇ 

    » „¤ï÷©=þ®‹ùá”ç  šª ÃâC?Ëháv=¿‚É…¤§% [xp†£{Ûµ_¼PÑ£<Í1 ¥H¶0•  ˆÙO¼R®BdÑÉ ÒJEÛ4b$§‘q_×-˜ž à6LÓõ R×7`®¨Éÿ³Ã0ÌžOÁ¯,åE n7”Liäb¡¨/ãS½¨eªÔ е¸ùÖý   ÿÿ  PK          ! ky– ƒ   Š       theme/theme/themeManager.xml


    do you think there's anything else i can try?




    Tuesday, April 5, 2011 7:44 PM