I am creating IE BHO using this example: http://code.msdn.microsoft.com/CSBrowserHelperObject-c5f3d2f6
The problem I am having is that for each tab BHO is loaded two times. I have inserted following core in BHO constructor:
Trace.WriteLine("BHO.ctor");
Trace.WriteLine("Thread: " + Thread.CurrentThread.ManagedThreadId + " of process: " + Process.GetCurrentProcess().Id);
In destructor:
Trace.WriteLine("BHO.destructor");
Trace.WriteLine("Thread: " + Thread.CurrentThread.ManagedThreadId + " of process: " + Process.GetCurrentProcess().Id);
Then in Setsite:
Trace.WriteLine("Bho.SetSite: " + site);
Trace.WriteLine("Thread: " + Thread.CurrentThread.ManagedThreadId + " of process: " + Process.GetCurrentProcess().Id);
When I start IE in debug output I see:
[3376] BHO.ctor
[3376] Thread: 1 of process: 3376
[3376] Bho.SetSite: System.__ComObject
[3376] Thread: 1 of process: 3376
[3376] BHO.ctor
[3376] Thread: 3 of process: 3376
[3376] Bho.SetSite: System.__ComObject
[3376] Thread: 3 of process: 3376
and only when I close it:
[3376] BHO.destructor
[3376] Thread: 2 of process: 3376
[3376] BHO.destructor
[3376] Thread: 2 of process: 3376
So, BHO is loaded two times and two instances of BHO exist at the same time. Why can this happen?
I discovered this issue when my BHO subscribed to events from third party assembly and I have experienced some strange behaviour (because there was more than 1 subscriber for the event). First I thought that it's a third-party library who causes this but now I removed all extra code from BHO so it basically does nothing but still is loaded two times.
Also if in SetSite I add OnDocumentComplete handler and then in this handler I write URL to debug console using trace I see that for first thread URL will be actual URL of my page (eg www.google.com) and for second thread it will be "about:blank". Also if I open one more tab and do something there and then switch to the first tab I see that one more BHO instance is created (URL: about:blank)
This may be IE's integrity level management.
I'm trying to solve this myself.
I'm currently considering:
The second one seems to disappear after a second or so.
What you saw is called virtual-tabs, mentioned only briefly in the docs . We became aware of it only recently after contacting MS support - but these are the exact symptoms (many 'ghost' navigation cycles to about:blank).
If you want to detect them (to ignore, most probably), the suggested semi-official way is -
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.