0

试图附加到IE浏览器..它工作了一段时间然后开始抛出这个错误......

---------------------------

---------------------------
Unable to cast COM object of type 'System.__ComObject' to interface type 'mshtml.HTMLDocument'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{3050F55F-98B5-11CF-BB82-00AA00BDCE0B}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
---------------------------
OK   
---------------------------

此代码在 500 毫秒的计时器上触发...

有人可以告诉我如何解决吗?我做错了什么?|| 我该如何改进它...我的代码如下...

 try
            {
                ShellWindows shellWindows = new ShellWindows();

                foreach (InternetExplorer ie in shellWindows)
                {
                    HTMLDocument document = ie.Document;

                    if (ie.LocationURL.Contains(ReserveRoomRsa + " ") || ie.LocationURL.Contains(ReserveRoomWww + " "))
                    {
                        if (bCodeScannerConnected && !idScannerShown)
                        {
                            idScannerShown = true;
                            ScanID(ie, "", "", "", "", "", "");
                            ie.Document.All.Item("guestHomePhone").Focus();
                            timer3.Enabled = true;
                        }
                    }
                    else if (ie.LocationURL.Contains(ReserveRoomRsa) || ie.LocationURL.Contains(ReserveRoomWww))
                    {
                        if (bCodeScannerConnected && !idScannerShown)
                        {
                            idScannerShown = true;
                            ScanID(ie, "lastName", "firstName", "homeAddressOne", "homeZip", "homeCity", "homeState");
                            ie.Document.All.Item("guestHomePhone").Focus();
                            timer3.Enabled = true;
                        }

                        DoNotRentAlert(ie.Document);
                    }
                    else if (ie.LocationURL.Contains(FindReservationRsa) || ie.LocationURL.Contains(FindReservationWww))
                    {
                        DoNotRentAlert(ie.Document);
                    }
                }
            }
            catch (Exception err)
            {
                if (i == 0)
                {
                    i += 1;
                    MessageBox.Show(err.Message);
                }
            }

自我说明:为什么我需要更多细节?源代码比程序员在编写下一个百万美元的应用程序时想要给出的细节要多得多!

4

0 回答 0