1

I'm about developing an application level VSTO addin that consists, among others, of a UI with an embedded Webbrowser control and a simple REST-style service, based upon WCF's WebServiceHost. The service delivers content, in particular flash movies, to the embedded browser. This used to work like a charm until yesterday. For some still unknown reason (maybe some .NET update that changed some internal processing), the complete Word application now freezes when the browser loads a flash movie from the embedded server. It still works when I move the webserver code into a separate process, and it also works when the flash movie is already in the browser cache, so I am quite sure that it is the combination of serving and displaying the flash movie both in the addin that is causing the problem.

I did some research (which I should have done earlier, maybe) and learned that multi-threading and VSTO addins do not go well together. And running a webservice surely implies some kind of multi-threading.

So my question is: is there any chance to make this kind of architecture run reliably? If so: what am I missing? Or should I better try another approach? If so: what would you recommend?

Note: Using "file://" urls and thus loading the content directly from the disk is not an option since I cannot guarantee a common docroot and need to put some logic between the UI and the content serving.

SliverNinja - MSFT
  • 31,051
  • 11
  • 110
  • 173
Matthias
  • 1,759
  • 16
  • 34

1 Answers1

1

VSTO add-ins are STA, so you should consider researching WCF and STA (see related SO post).

You could always host the WCF service as a windows service to avoid the STA issues of the VSTO add-in host.

Community
  • 1
  • 1
SliverNinja - MSFT
  • 31,051
  • 11
  • 110
  • 173
  • +1 for that very interesting link - that doesn't, alas, solve the problem. The invoke-thread with STA apartment state itself is still returning (with the FileStream as result) - looks like the freeze happens somewhere inside .NET itself, where the FileStream is used to fill the HTTP response. - Using a windows service isn't liked very much by the IT operations of some users of the addin. So I am currently trying to let the WCF service run in a separate process started and controlled by the addin. – Matthias Feb 27 '12 at 16:35
  • Matthias - are you using `Process.Start` or just loading another `AppDomain` to isolate the processes? – SliverNinja - MSFT Feb 27 '12 at 16:42
  • I am using Process.Start and have it running sufficiently well by now. It's not a very elegant solution, though. And I'm not yet too confident that there might still be hidden problems. To be honest, I didn't even think of creating a separate AppDomain. Do you think this could work? – Matthias Feb 28 '12 at 19:22