I've come up with a workaround which performs exactly what I wanted (starts external browser and loads specific web site while posting some parameters to it). Instead of using WebBrowser
control HTML file (similar as in the question) with Form and a JavaScript to submit the form onLoad
event is generated. Then the generated HTML content is written into the file system and started with default browser later on.
File may be created with similar code:
using (StreamWriter file = File.CreateText (filePath))
{
file.WriteLine (GetHtml());
file.Close ();
}
Default browser may be opened with something like the following code:
using (dynamic shell = AutomationFactory.CreateObject ("WScript.Shell"))
{
shell.Run (filePath, 7, false);
}
And after the default browser is up and running we may delete the file we just generated:
if (File.Exists (filePath))
{
File.Delete (filePath);
}
Please note that in order to create/delete a file your SL application needs to be trusted application. That is, it has to have elevated permissions (check Application.Current.HasElevatedPermissions
property).
Access local file system in Silverlight 5. In SL 4 one could use com interoperability and Scripting.FileSystemObject
to access local file system.