I have a simple WCF service hosted in a WinForms project. I am trying to update a WebBrowser control to navigate to a specified url received by the service.
namespace DocumentViewer
{
public partial class FormMain : Form, IDocumentViewerService
{
private WfcServiceManager _service = new WfcServiceManager();
public FormMain()
{
InitializeComponent();
this.Load += FormMain_Load;
}
void FormMain_Load(object sender, EventArgs e)
{
_service.Start();
webBrowser1.Navigate("http://www.example1.com");
}
public void ShowDocumentPreview(string path)
{
webBrowser1.Navigate("http://www.example2.com");
}
}
}
When the app loads it successfully navigates to www.example1.com as expected.
When i send a request via the WCF Test Client and put a breakpoint on ShowDocumentPreview(string path) the method is hit but the WebBrowser control does not navigate to www.example2.com
Any ideas what the issue is here?
Code for the Service:
namespace DocumentViewer
{
[ServiceContract]
public interface IDocumentViewerService
{
[OperationContract]
void ShowDocumentPreview(string path);
}
}
namespace DocumentViewer
{
public class WfcServiceManager
{
private Uri baseAddress = new Uri("http://localhost:30303/DocumentViewerService");
private ServiceHost _host;
public void Start()
{
_host = new ServiceHost(typeof(FormMain), baseAddress);
// Enable metadata publishing.
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
_host.Description.Behaviors.Add(smb);
_host.Open();
}
public void Stop()
{
if (_host != null)
{
_host.Close();
_host = null;
}
}
}
}
Note: The reason I'm using WCF is because the WebBrowser control is 32-bit and the main app I'm developing needs to be 64-bit so the solution i have come up with is to have a separate 32-bit app with the WebBrowser control and the 64-bit app sends url's to the WebBrowser control via WCF.