Unauthorized Access Exception

  • Thread starter Thread starter vijay_3491
  • Start date Start date
V

vijay_3491

Hi,

I am using Web browser control in my application. When accessing
webbrowser.document.window.frames[0].document throws an Unauthorized
access exception

Any one pls help.

Thanks in Advance
 
What is the URL in the document that you have loaded? If you have just
a form with a webbrowser in it, and you go to that document, do you still
get that error?

Do you have any browser helper objects which could be interfering with
the page? That's my first guess, since the WebBrowser control is really
just a managed wrapper around IE (more or less).
 
What is the URL in the document that you have loaded? If you have just
a form with a webbrowser in it, and you go to that document, do you still
get that error?

Do you have any browser helper objects which could be interfering with
the page? That's my first guess, since the WebBrowser control is really
just a managed wrapper around IE (more or less).


Nicholas,

I'm jumping in here since I run into a similar problem.
I use the code below to retrieve DOM element infos from websites.

In one of my apps, I get the unauthorizedaccess exception in some
websites, especially those who need a login (webmail stuff and so on)
On others however the code below works just fine. I played a little
around with ExecutionContext and Security Settings, but with no
success. Any hints how I should proceed ?

here is part of the code, no interaction with the website is needed, I
just collect the entire tags.InnerHTML info

Thread newThread = new Thread(new
ParameterizedThreadStart(LogInnerHTML));
newThread.SetApartmentState(ApartmentState.STA);
newThread.Start((IHTMLDocument2)ie.Document); //ie is a
valid InternetExplorer instance used to navigate to the url
newThread.Join();

......

internal static void LogInnerHTML(object inputParam)
{
string output = "";

IHTMLDocument2 document = (IHTMLDocument2)inputParam;
IHTMLFramesCollection2 frames =
((IHTMLDocument2)document).frames;

IHTMLElementCollection documentTags = document.all;
foreach (IHTMLElement tag in documentTags)
output += tag.innerHTML + "\n";

if (frames.length != 0)
{
for (int i = 0; i < frames.length; i++)
{
object index = i;
IHTMLWindow2 window =
(IHTMLWindow2)frames.item(ref index);
IHTMLDocument2 frameDocument = window.document;
IHTMLElementCollection allTags =
frameDocument.all;
foreach (IHTMLElement myTag in allTags)
output += myTag.innerHTML + "\n";
}
}
}


thx a lot :)

Ulf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top