Embedding WebBrowser Control into the toolbar fails

Add-in Express™ Support Service
That's what is more important than anything else

Embedding WebBrowser Control into the toolbar fails
Using Designer to drag-drop the WebBrowser control into Toolbar/Bar fails 
George Kierstein




Posts: 47
Joined: 2013-05-04
I am trying to embed a WebBrowser control into the Toolbar form using the Designer in Visual Studio 2010 and am getting an exception - Should this work in general or is this a limitation of the platform ?

I want to create a very simple page that has a button and some javascript in it - is this possible ?

Best
G

[img]http://img.anonfiles.org/vierwer.php?file=75485707617332344240.png[/img]
Posted 23 May, 2013 23:47:52 Top
George Kierstein




Posts: 47
Joined: 2013-05-04
Any Ideas ?

Thanks
G
Posted 23 May, 2013 23:48:50 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi George,

Do you use the 'System.Windows.Forms.WebBrowser' control or the ActiveX control?
Posted 24 May, 2013 05:41:51 Top
George Kierstein




Posts: 47
Joined: 2013-05-04
I just tried a drag and drop from the Toolbox in the Form designer. I'm not all that experienced in C# so I'm not sure which one that is - sorry!

Best
G
Posted 24 May, 2013 12:42:04 Top
George Kierstein




Posts: 47
Joined: 2013-05-04
Hi,

I switched to visual studio 2012 because I was seeing the same error using my install of 2010 with a new simple windows form project that attempted to use a System.Windows.Forms.WebBrowser.

That being said I am still running into an issue - In 2012 I can succesfully add a WebBrowser control to the Toolbar and it compiles fine but it won't register claiming:

Error 1 Cannot register assembly ".. .\MyIEToolbar1\bin\Debug\MyIEToolbar1.dll". Exception has been thrown by the target of an invocation. MyIEToolbar1

Should this simply work by default ? What is causing this issue and is there anything I can do about it ?

Thanks
G
Posted 25 May, 2013 17:27:52 Top
George Kierstein




Posts: 47
Joined: 2013-05-04
It does appear to be confined to the WebBrowser control. I created a new Form that is shown when DocumentComplete is called. If I add any other controls it registers fine and works but the WebBrowser control fails.

Any Ideas ? Is this even possible ?
Posted 25 May, 2013 18:56:29 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi George,

Please try to change the constructor of the toolbar module as shown below. It should fix the threading issue of the toolbar registration in Visual Studio 2012. This issue happens with the WebBrowser control only.

        public IEToolbarModule()
        {
            if ((!Process.GetCurrentProcess().MainModule.ModuleName.StartsWith("msbuild", StringComparison.InvariantCultureIgnoreCase) || this.DesignMode))
            {
                InitializeComponent();
            }
            else
            {
                // Here you need to add the initialization code of the toolbar module from the InitializeComponent method.
                // The code shouldn't populate the Controls collection of the toolbar module, e.g
                this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
                this.HandleShortcuts = true;
                this.Name = "IEToolbarModule";
                this.Size = new System.Drawing.Size(455, 24);
            }
        }
Posted 27 May, 2013 05:14:32 Top
George Kierstein




Posts: 47
Joined: 2013-05-04
Thanks,

Wierd. I tried it again with a new Toolbar project and I could embed the WebBrowser just fine. It works perfectly without the addition of the code above. If I run into this issue again I will definitely try that and let you know.

Best
G
Posted 27 May, 2013 22:13:40 Top