proxen
Posts: 2
Joined: 2013-01-10
|
Hello
I try to add ElementHost control to host WPF controls.
After that I got
error MSB3217: Cannot register assembly "<skip>\bin\Debug\MyIEToolbarTest.dll". Exception has been thrown by the target of an invocation.
in Visual Studio 2012
The same in the VS2010 works correctly.
What am I doing wrong?
Thanks. |
|
Sergey Grischenko
Add-in Express team
Posts: 7233
Joined: 2004-07-05
|
Hello,
Creating a new instance of the ElementHost class produces the 'The calling thread must be STA, because many UI components require this' error.
To avoid the issue please add the code below to the toolbar constructor.
public IEToolbarModule()
{
if (Process.GetCurrentProcess().ProcessName.Equals("MSBuild", StringComparison.InvariantCultureIgnoreCase))
{
try
{
InitializeComponent();
}
catch (Exception)
{
// Properties below are required for the registration and should be initialized.
this.Name = "IEToolbarModule";
this.Position = ADXIEToolBarPosition.tbpDefault;
this.MenuText = "My menu text";
this.NoGripper = false;
this.ResetToolbarLayout = false;
this.Title = "My Title";
this.HelpText = "My help text";
this.Size = new System.Drawing.Size(521, 24);
}
}
else
{
InitializeComponent();
}
}
|
|
proxen
Posts: 2
Joined: 2013-01-10
|
Thank you, Sergey.
It works now. |
|