Silverlight exception with javascript “failed to invoke” when using HtmlPage.Window.Invoke

Silverlight can interact with the Javascript that reside in the page that this one is hold. We have seen in the Silverlight Communication post that it’s possible with the use of System.Windows.Browser.HtmlPage.Window.Invoke.

Sometime, an exception can be thrown with the title “InvalidOperationException was unhandled by user code”. The troubleshooting tips should contain something like “Failed to invoke”.

InvalidOperationException was unhandled by user code

In fact, what happen is the Javascript is throwing an error. It can be any errors not catch in the Javascript. So, when you get this error, the best thing to do is to launch a Javascript Developer tool (for example F12 with Internet Explorer) and activate the Script Debugging functionality. When an error will be thrown and not catch, the tool will break and you will be able to change your script.

If you like my article, think to buy my annual book, professionally edited by a proofreader. directly from me or on Amazon. I also wrote a TypeScript book called Holistic TypeScript

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.