trying to attach to an IE browser.. it works for awhile then starts throwing this error...
---------------------------
---------------------------
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
---------------------------
this code is fired on a timer of 500 millisecods...
could someone tell me how to fix it?? what I'm doing wrong?? || how I can improve it... My code is as follows...
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);
}
}
NOTE TO SELF: Why do I need more details?? the Source Code is WAY MORE DETAILS than a PROGRAMMER Wants to give out when writing the next million dollar app!
User contributions licensed under CC BY-SA 3.0