0

iframe のドキュメント オブジェクトを取得してオブジェクトに保存する必要があるこのコード スニペットがあります。

//just a wrapper object to store the document object   
DocObj obj = new DocObj(HtmlDoc);

ManualResetEvent aDoneEvents = new ManualResetEvent(false);
string errorMessage = "";
Thread aThread = new Thread(() =>
{
    try
    {
        //finding the iframe element in the current document
        IHTMLElement IElem = LocatorBuilder.GetLocator(Target)
                   .Find(this.HTMLDoc);

        obj.HTMLDoc = (IElem as HTMLIFrame).document as HTMLDocument;

    }
    catch (Exception e)
    {
        errorMessage = e.Message;
    }
    aDoneEvents.Set();
});

aThread.SetApartmentState(ApartmentState.STA);
aThread.IsBackground = true;
aThread.Start();
aDoneEvents.WaitOne();
if (errorMessage != "")
{
    throw new Exception(errorMessage);
}
HtmlDoc = obj.HTMLDoc;

しかし、新しいドキュメント オブジェクトを取得しようとすると、最後の行で次の例外が発生します。

前回の関数評価がタイムアウトしたため、関数評価が無効になりました。関数の評価を再度有効にするには、実行を続行する必要があります

4

1 に答える 1

0
mshtml.IHTMLDocument3 doc3 =   (mshtml.IHTMLDocument3)webBrowser.Document.DomDocument;
mshtml.IHTMLFrameBase2 frame = (mshtml.IHTMLFrameBase2)doc3.getElementById("iframe_name");
if (frame != null)
{
    mshtml.IHTMLWindow2 w2 = (mshtml.IHTMLWindow2)frame.contentWindow;
    doc3 = (mshtml.IHTMLDocument3)w2.document;
}
于 2015-02-13T11:17:09.637 に答える