Note that there are some explanatory texts on larger screens.

plurals
  1. POPublic member 'elements' on type 'DBNull' not found
    text
    copied!<p>We have an ActiveX component that displays a Web page in an Internet Explorer window via SHDocVw. In the DocumentComplete event handler, we attempt to retrieve the value from one of the controls on the page. We <em>know</em> the control is on the page (it's visible via a <a href="http://fiddler2.com/" rel="nofollow">Fiddler</a> trace).</p> <p>It's at this point that things get wonky. We receive the following error message at runtime:</p> <pre><code>Error Message: Public member 'elements' on type 'DBNull' not found. Error Routine Location: at Microsoft.VisualBasic.CompilerServices.Symbols.Container.GetMembers(String&amp; MemberName, Boolean ReportErrors) at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack) at Foo.AddinModule.m_internetExplorer_DownloadComplete(Object pDisp, Object&amp; url) Error Source: Microsoft.VisualBasic Error Site Location: System.Reflection.MemberInfo[] GetMembers(System.String ByRef, Boolean) </code></pre> <p>The offending line of code is this one:</p> <pre><code>Me.IEInstance.Document.forms("frmRedirect").elements("redirectData").Value = outlookXML.OuterXml </code></pre> <p>So, essentially, <code>Me.IEInstance.Document.forms("frmRedirect")</code> is evaluating to <code>DBNull</code>.</p> <p>We've eliminated case sensitivity issues. Tried moving the control around within the page, and verified that the HTML is well-formed. I have no idea why this is occurring. A sample of the generated HTML is below.</p> <p>Can anyone suggest a cause and a possible resolution for this issue? I'm entertaining any and all suggestions at this point.</p> <p><strong>HTML Sample</strong></p> <pre><code>&lt;form id='frmRedirect' name='frmRedirect' action='pw_outlook/choosecontacts.aspx' method='POST'&gt; &lt;input type='hidden' name='redirectData'&gt; &lt;/form&gt; </code></pre> <p><strong>UPDATE 3/28/2012</strong></p> <p>We have determined that the code works fine under certain configurations. Then, mysteriously, it will succeed <em>for some users</em> if you change the code as follows:</p> <pre><code>Me.IEInstance.Document.forms("frmRedirect").Elements("redirectData").Value = outlookXML.OuterXml ^ ^ </code></pre> <p>That is, if you simply change the case of <code>Elements</code>. This, to me, smacks of a case sensitivity issue during a COM vtable lookup, but the mystery is that it doesn't occur for everyone. Just <em>some</em> users.</p> <p>Also, please note that the form that is returned by <code>.forms("frmRedirect")</code> is a valid object; however, it doesn't appear to have an <code>elements()</code> method.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload