Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / October 2004

Tip: Looking for answers? Try searching our database.

How do I resolve a mshtml SecurityException I'm experiencing?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dan the Man - 29 Oct 2004 18:04 GMT
Hi!

I'm new to infopath and am trying to use C# managed code to programmatically
setup a Custom Task Pane whenever the context changes.  My code is below.  At
first, I had a problem compiling the code because C# could not recognize type
HTMLDocument.  So, I added the mshtml.dll reference using c:/Program
Files/Microsoft.NET/Primary Interop Assemblies/Microsoft.mshtml.dll.  The
problem successfully compiled but when I run the application, I get
"System.Security.SecurityException" when I try to access HTMLDocument!  I
know I'm missing a step.  Do I need to add the mshtml reference to my
infopath Form? What else could it be?

Dan

P.S. Here is the code:

[InfoPathEventHandler(EventType=InfoPathEventType.OnContextChange)]
public void OnContextChange(DocContextChangeEvent e)
{
    if (e.Type == "ContextNode")
    {
        // Retrieve task pane object
          TaskPane oTaskPane =
            thisXDocument.View.Window.TaskPanes[0];

          // Retrieve html object for task pane
        // Now get the HTMLDocument
        HTMLTaskPaneObject oHtmlPane = (HTMLTaskPaneObject)oTaskPane;

        // This is where the exception occurs!!!!!
        mshtml.IHTMLElementCollection oHtmlDoc =
            oHtmlPane.HTMLDocument.all;
         
          // Clear previous help topic from task pane
          if (helpString != null)
               ((mshtml.IHTMLElement)
oHtmlDoc.item(helpString,null)).style.display="none";
     
          // Display DIV statement having same ID as the context node name
          ((mshtml.IHTMLElement)
oHtmlDoc.item(e.Context.nodeName,null)).style.display="";
       
        // Keep record of string displayed, so can later be cleared
        helpString=e.Context.nodeName;
     
        // XML Selection or Context has changed. Write code here to respond to the
changes.
        return;
    }
}
Franck Dauch? - 29 Oct 2004 21:08 GMT
Your form needs to be fully trusted.

Signature

Franck

> Hi!
>
[quoted text clipped - 49 lines]
> }
> }

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.