Quantcast
Viewing all articles
Browse latest Browse all 3527

System.NotSupportedException when accessing a variable of IHtmlDocument2.Script in 32 bit outlook after a second navigate

Hello all,

I'm working on an addin in outlook using VB .Net that views an html window in the reading pane using mshtml interface. The page has some javascript code which I call using IHtmlWindow2.execScript. I load the page using IHtmlWindow2.navigate(url) function and access some javascript variables by doing the following:

Dim htmlWindow As IHTMLWindow2
htmlWindow.execScript("x=somefunction();","javascript")
Dim result as String = htmlWindow.document.Script.x.ToString()


This code works fine when I run it from an outlook 64bit instance... running the addin from outlook 32bit instance (whether on 32bit or 64bit machine) it gives System.NotSupportedException after I execute a second navigate on htmlWindow, when I first navigate to the url and execute this code it works with no problem. 
using internet explorer debugger F12Chooser on the loaded page in outlook, the below code is executed with no error and return the required value.

x=somefunction();
window.document.Script.x;

However, I tried a breaking point at 

htmlWindow.execScript("x=somefunction();","javascript")

and executed the same code in the immediate window in visual studio but with another variable name each time after i do a navigate, I get no exception.

htmlWindow.execScript("y=somefunction();","javascript")
MessageBox.Show(htmlWindow.document.Script.y.ToString())

I dont understand this behaviour and I would appreciate any help in this. I suspect it has something to do with some caching but I dont know where, i searched the internet for this wih no success.

Thanx


Viewing all articles
Browse latest Browse all 3527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>