WPF Web Application throws System.MissingMethodException while calling Javascript method in IE9/IE10/IE11

Problem description

  • You have a WPF web application as XBAP package. 
  • You want your application communicate with Javascript via BrowserInteropHelper.HostScript. 
  • Your clients decided to upgrade to Windows 8.
  • Your application works in IE8 but throws System.MissingMethodException in IE9/IE10/IE11.
  • You did everything but no luck.

Solution

Although the problem seems frustration.  The solution is simple. You need to call your function as a function of document object. So, you need to change two parts/lines of your existing code as shown red below.

//WPF/.Net part
dynamic host = BrowserInteropHelper.HostScript;
host.document.OnYourWPFApplicationLoaded(new CallbackObject(this));
//Javascript part
document.OnYourWPFApplicationtLoaded = function OnYourWPFApplicationtLoaded(callbackObj) {        
   ...
}

And … That’s it 🙂

Advertisements

2 thoughts on “WPF Web Application throws System.MissingMethodException while calling Javascript method in IE9/IE10/IE11

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s