Controlling .NET WebBrowser with Adobe SVG Viewer

I am having problems loading SVG files in a .NET WebBrowser control. If I create a new WinForms Application project, drag the WebBrowser control and button onto the Form1.cs design surface, and add a line in the mouse button handler to set the Url property of the WebBrowser control to the SVG file, I get two IE script errors at runtime (like in the dialog you get when there is a Javascript issue). Thus, the only line of code I write is:

webBrowser1.Url = new Uri(@"http://wiki.allegro.cc/pub/f/fb/Grozilla.svg");

      

This SVG file loads fine if I view the IE link directly; the errors I am getting through the test app:

line 2, char 1, error: Invalid character, followed by
line 1, char 1, error: Object expected

      

(assuming I say yes to the "continue scripting on this page" prompt).

I am using IE 7.0.5730.13, Adobe SVG Viewer 3.03 build 94, Visual Studio 2008

. Can anyone repeat this? Has anyone seen it / got any idea on how to fix it?

(edit: pre-setting the url in the constructor for the example, but this raised the question of whether the element had finished initializing or not, so changed the example of using the button - the problem still occurs. This error originally appeared in production code, so the example program. which I wrote was an attempt to isolate the problem and reproduce it as easily as possible.)

(edit 2: after testing several different machines, these problems seem to be related to IE7 - start IE6 and everything works fine.)

0


source to share


2 answers


I found that when working with WebBrowser, you cannot make calls to navigate to the page when creating the control.

I got around this by creating a timer that starts once on form load (turn it on in the constructor) and then in the event handler for the timer call Navigate or set the Url property and it should work.



I could not tell you why, although life is for me.

0


source


It looks like adding the original website SVG file to the list of trusted sites solves the problem, so it has something to do with IE security.



0


source







All Articles