Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8387253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:09:46+00:00 2026-06-09T18:09:46+00:00

I’m working on a vb.net application that interacts with a (third party provided) web

  • 0

I’m working on a vb.net application that interacts with a (third party provided) web app to provide additional functionality (e.g. removing menu items, pulling information from the pages, etc.). The web app is completely driven by javascript but is hosted in asp.net and is only used with Internet Explorer.

I’m trying to read properties from a javascript object and execute some of it’s functions. I’ve managed to get hold of the javascript object by getting the mshtml.HTMLDocument of the iframe the script resides in and using the following code:

Dim jsObject as Object
jsObject = htmldoc.Script.jsObject

jsObject exists as a {System.__ComObject} and i can use it to execute any of it’s functions or read it’s properties as follows:

Dim value as String = jsObject.FunctionThatReturnsAString()
jsObject.FunctionTHatDoesSomethingInWebApp("Param1", "Param2")

This works great. However, when I leave the page/frame with jsObject in and return to it, the same code throws an exception when getting the javascript object from the frame again (i.e. executing the following line):

jsObject = htmldoc.Script.jsObject

Exception: Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))

If I stop debugging and restart, it works again (until i leave the page, etc.). I’m not sure what’s happening that’s causing the javascript object to disappear as far as my app’s concerned. I’m presuming it’s due to my app holding a reference to the COM object and i need to release it in some way (particulary as it’s got a base type of MarshalByRefObject – which makes sense as it’s being passed between app domains).

Why is this happening? Is there a better way of accessing a javascript object, it’s properties and functions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T18:09:48+00:00Added an answer on June 9, 2026 at 6:09 pm

    I’ve found what is, in my case, a better way of achieving what I need. Instead of accessing the jsObject directly as a COM Object (and worrying about Marshaling, etc.), I either use:

    • execScript to call functions with no return value or
    • create a hidden div element in the frame i’m working in, set the innerHTML of that div equal to whatever javascript variable/function return value that i’m interested in using execScript and then read that value seperately from the DOM

    To read a variable/function return i use the following vb.net function:

    Private Function getJScriptVariable(ByVal JScript As String)
        Dim command As New StringBuilder()
        command.Append("var e = document.getElementById('Matt_JScriptReturn');")
        command.Append("if (e == null) {")
        command.Append("var e = document.createElement('div');")
        command.Append("e.id = 'Matt_JScriptReturn';")
        command.Append("e.type = 'hidden';")
        command.Append("document.body.appendChild(e);")
        command.Append("}")
        command.Append("e.innerHTML = ")
        command.Append(JScript)
        command.Append(";")
    
        'fMaster is the frame containing the javascript's mshtml.IHTMLWindow2
        fMaster.execScript(command.ToString(), "JScript")
    
        'N.B. fMaster_Document is the fMaster's mshtml.HTMLDocument
        Return fMaster_Document.getElementById("Matt_JScriptReturn").innerHTML
    
        'Optionally execScript to remove element from DOM at this point
    End Function
    

    Then i would use that function as follows (respecting my example in the original question):

    Dim value as String = getJScriptVariable("jsObject.FunctionThatReturnsAString()")
    

    To execute javascript code without needing to return a value I simply execute it as follows:

    fMaster.execScript("jsObject.FunctionTHatDoesSomethingInWebApp('Param1', 'Param2')")
    

    I’d still be interesting in finding out why i had the problem earlier with the javascipt object being unable to access after leaving the page and returning, however this solves my problem so i’m happy for now! I hope this helps someone else at some point.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
We're building an app, our first using Rails 3, and we're having to build
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.