DancesWithBamboo

I have 2 Word documents that have a parent-child relationship to each other. Document B pulls a string from the data island inside of Document A using the ServerDocument (client side...no web or server here). Both documents are open at the same time. What happens is that when I update the cached string field in A, B doesn't see the updated value until after A has been closed, reopened, and then saved. It is like the data was cached in the AppDomain or other "Ether" and then when A reopened it sucked in the data and then the ServerDocument object in B was able to see it.

Anyone ever used the data islands like this What exactly is the process behind this cachng mechanism Is there a way to force the cache inside the document to be up-to-date without closing the document



Re: Visual Studio Tools for Office BUG? Data Island cache not updating immediately

DancesWithBamboo

Update to my issue:

The string I have marked as cached in my document only gets updated to the cache the first time the document is saved. If I leave the document open after saving and keep editing the value, subsequent saves don't update the cache. Baiscally I get one save after the doc is opened that actually does anythingto the cache. That has to be a bug in VSTO





Re: Visual Studio Tools for Office BUG? Data Island cache not updating immediately

Phil Hoff - MSFT

The data islands are not updated until the document is saved, as you observed. Currently, there is no way to force an update of the data islands short of programmatically saving the document. However, there is a known issue with Word 2003 in which Save() does not update the data islands on subsequent invocations (that is, only the first Save() works), as you also observed. This is because, on these subsequent invocations of Save(), Word fails to save the state of any ActiveX controls embedded within the document and VSTO uses an ActiveX control as its "data island".

-Phil





Re: Visual Studio Tools for Office BUG? Data Island cache not updating immediately

JesseJ

Wow, this explains a problem I had a week ago but haven't had time to post about yet. Is it safe to assume that Save() doesn't have this problem in Word 2007 Also, any chance MS will patch this for Word 2003

-Jesse




Re: Visual Studio Tools for Office BUG? Data Island cache not updating immediately

Phil Hoff - MSFT

The Save() method in Word 2007 works properly for both *.docx and *.doc formats. I can't say whether the bug will ever be addressed for Word 2003, but if it's a critical issue for you I would log a bug against it (http://connect.microsoft.com/). The squeaky wheel and all that.

-Phil





Re: Visual Studio Tools for Office BUG? Data Island cache not updating immediately

DancesWithBamboo

I had a funny feeling this would be the answer. Microsoft is always more concearned about releasing the next flashy version rather than focusing on building real usable tools for the developer community. Who cares about scrolling ribbons and vector graphics when the document doesn't even save. Upgrading to 2007 is not a viable solution and is at least a year out for my company. I'll need to scrap my whole architecture and start over. It will be a long time before I use Word/VSTO again.



Re: Visual Studio Tools for Office BUG? Data Island cache not updating immediately

DancesWithBamboo

By the way, Is there a KB article or other documentation on this issue that I can reference when contacting MSFT and explaining a slip in timeline



Re: Visual Studio Tools for Office BUG? Data Island cache not updating immediately

Phil Hoff - MSFT

I was not able to find a KB article on this issue, but here is a link to a previous report:

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx FeedbackID=166387

As a workaround, you might try replicating a "user-induced save" rather than use Document.Save(). On my machine, the following code displays "string" in the message box the first time the document is opened. The second time the document is opened, "string 3" is displayed as expected. (If you used the standard Document.Save() method, you would see the incorrect "string 1" when the document is opened the second time.)

Code Snippet

public partial class ThisDocument

{

[Microsoft.VisualStudio.Tools.Applications.Runtime.Cached]

public String StrTest = "string";

private void ThisDocument_Startup(object sender, System.EventArgs e)

{

System.Windows.Forms.MessageBox.Show(StrTest);

StrTest = "string 1";

SaveViaCommandBar();

StrTest = "string 2";

SaveViaCommandBar();

StrTest = "string 3";

SaveViaCommandBar();

}

private void SaveViaCommandBar()

{

CommandBars["File"].Controls["Save"].Execute();

}

private void ThisDocument_Shutdown(object sender, System.EventArgs e)

{

}

#region VSTO Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InternalStartup()

{

this.Startup += new System.EventHandler(ThisDocument_Startup);

this.Shutdown += new System.EventHandler(ThisDocument_Shutdown);

}

#endregion

}

There may be better ways of sharing data in real-time between Word documents than relying on the data islands, as I don't believe they were intended to be used in that fashion. (The data islands were intended to be used for storing data between viewing/editing sessions and/or in a client/server arrangement, hence the class name "ServerDocument".) What methods might be more appropriate will depend on what data is being shared, when (how is data access synchronized, new data signaled, etc.), and the configuration of the target machines (is .NET 3.0 available, etc).

-Phil





Re: Visual Studio Tools for Office BUG? Data Island cache not updating immediately

DancesWithBamboo

Phil-

Thanks for the reply. I will try using the command bar save and see what happens. I can also get this to happen just caching data in a document for use within itself; No need to use ServerDocument at all.

Is there some way of accessing the XML with a document without loading Word other than using ServerDocument and dataislands I have used the Word interfaces before, but it takes some 6-10 seconds for Word to load my typical document behind the scenes vs. dataislands that were in the sub-second range.

Thanks again.