Note that there are some explanatory texts on larger screens.

plurals
  1. POStatic reference to instance in IE Toolbar
    primarykey
    data
    text
    <p>I am having an interesting issue with a COM component written to function as a toolbar in IE. Basically if you open up several tabs at once in IE the individual instances of the COM objects get all twisted around. Bear with me here.</p> <p>Say I open up five browser tabs all at once by right clicking several different links and opening them in new tabs. Now a function of my toolbar involves selecting text in the web page and then clicking a button to copy that text into the Toolbar. So let's do that in tab 3. We select text and click the button and nothing is there. However, if we select text in tab 2, then go back to tab 3 and click the button we get the text selected in tab 2. So...the toolbar in tab 3 getting stuff from tab 2. Not good.</p> <p>I have traced this problem back to static references inside our COM object, the toolbar.</p> <pre><code>[ComVisible(true), Guid("2CC75392-1182-470D-BECC-EFA33E629AB8")] [CLSCompliant(false)] public sealed class Toolbar : ADXIEToolbar { public static Toolbar Instance; public Toolbar() { Instance = this; InitializeComponent(); } ...other code... } </code></pre> <p>Note only one toolbar instance exists per each IE tab.</p> <p>This reference doesn't get assigned properly, almost like it isn't thread safe (it isn't) but instead not domain safe or something. It will sometimes reference another instance down the line. Same with other static fields and even thread-safe singletons. I don't get it.</p> <p>Also note that if I pass a reference to this toolbar (inside InitializeComponent) to a control I have the same issue.</p> <pre><code>this.publicationDateCb.Toolbar = this; </code></pre> <p>This reference will sometimes point to a different tab.</p> <p>If I use a purely subscription based model with absolutely zero static references with the toolbar as the referee then things seem to work fine. This basically means I would have to re-design the program to where no classes interacted with each other directly - they fire events that the toolbar subscribes to, calling methods in other classes. Ouch.</p> <p>So should I go with that model (which may be ideal but I am pretty far along here) or is there a simple fix I am missing here?</p> <p>Other notes: </p> <ul> <li>All IE tabs are running in seperate processes.</li> <li>The BHO/Toolbar is running in the same process as the IE tab.</li> <li>I am using Add-In-Express for Internet Explorer to handle the IE integration.</li> <li>The project is written for .NET 3.5; the loader uses .NET 2.0</li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload