Migration from Add-in Express 2010 to 2011 causing problem

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

Migration from Add-in Express 2010 to 2011 causing problem
 
Phuong Nguyen




Posts: 52
Joined: 2009-04-08
Hi Support Team,

I migrated my project from Add-in Express (VS 2008) to Add-in Express 2011 (Visual Studio 2010) and below are two critical problems I saw

1. I have an sidebar object and it gave me the full screen size sizebar, it looks like the migration has changed my sidebar size automatically
2. I can not register my project, this is the error I got

Cannot register assembly "C:\Public\Clearcase\phu1_view\vob\CV2\SBBU\findit-MR_1.0.1\ieaddon\bin\Release\FindITIEAddon.dll". Exception has been thrown by the target of an invocation.

Please help since I suppose it will be a smooth migration since I just bought Add-in 2011 and Visual Studio 2010.

Thanks,
Phuong
Posted 02 Aug, 2011 00:07:30 Top
Sergey Grischenko


Add-in Express team


Posts: 7224
Joined: 2004-07-05
Hi Phuong,

1. Please go to the InitializaComponent method of your bar and remove 'this.AutoScaleDimensions ...' statement. Then just rebuild and reopen the designer.
2. Did you add any custom code to the constructor of iemodule or bar? If so, please move the code to the OnConnect event handler. It should fix the issue.
Posted 02 Aug, 2011 05:27:53 Top
Phuong Nguyen




Posts: 52
Joined: 2009-04-08
HI Sergey,

For #2, I moved my custom code to OnConnect event handler but I still can not register with the same error message. Is there something else can cause this? I expect to migrate smoothly because our customer just want to support IE9.

Thanks,
Phuong
Posted 02 Aug, 2011 22:57:14 Top
Phuong Nguyen




Posts: 52
Joined: 2009-04-08
I also noticed that the file 'adxloader.dll.manifest' is changed on 2011 Add-in express. How can i migrate my old adxload.dll.manifest file to this new format?

Thanks,
Phuong
Posted 02 Aug, 2011 23:05:16 Top
Phuong Nguyen




Posts: 10
Joined: 2011-07-14
I found the problem, I have OnConnect event handler in both IEModule and IEToolbar class, IE toolbar reference to a static varibale in IEModule as IEModule.var1 but for somehow the IEModule OnConnect event handler does not run so the parameter never get initialized and cause the exception. My question is

1. Does OnConnect event handler of IEModule is run or if I have to do something to make it trigger?
2. If it does, does it run before OnConnect event handler of IEToolbar?

Thanks,
Phuong
Posted 03 Aug, 2011 00:42:23 Top
Sergey Grischenko


Add-in Express team


Posts: 7224
Joined: 2004-07-05
Hi Phuong.

We didn't change anything in the manifest. All Add-in Express modules are created when you register the add-on in Visual Studio. So, please don't initialize any static variables in the modules.

does it run before OnConnect event handler of IEToolbar?

Usually static variables are initialized first in the code.

I moved my custom code to OnConnect event handler but I still can not register with the same error message. Is there something else can cause this?

Try to initialize all static data in the OnConnect event handler.

I expect to migrate smoothly because our customer just want to support IE9.

Did you noticed the '//Please write any initialization code in the OnConnect event handler' text in the constructor of the iemodule? The fact is that we don't recommend to put the custom code to constructors of our modules. The same rule is applied to static variables.

If the issue still exists, please send me a simple project for testing. I will check it.
Posted 04 Aug, 2011 05:18:27 Top
Phuong Nguyen




Posts: 52
Joined: 2009-04-08
Hi Sergey,

Thanks for prompt response. I followed your instruction and I still can not get OnConnect handler to work on IEModule. For testing, I create a very simple example

IEToolbar with a single label1, and label text field points to IEModule static variable as following

private void MyIEToolbar1_OnConnect(object sender, int threadId)
{
this.label1.Text = IEModule.tblabel;
}

IEModule connect class OnConnect Event will initialize this value as following

public static string tblabel;

private void IEModule_OnConnect(object sender, int threadId)
{
tblabel = "Test";
}

Since IEModule_OnConnect never triggered so on my IE9, the toolbar label is always 'empty', does not show "Test" value.

I can send you this simple program if you tell me how I can upload it or send to what email address?

Thanks again,
Phuong
Posted 04 Aug, 2011 22:44:24 Top
Sergey Grischenko


Add-in Express team


Posts: 7224
Joined: 2004-07-05
Hi Phuong.

If the OnConnect event is not called, the toolbar is not loaded by IE. I tested the same code but 'tblabel' was not static. It worked fine in IE9.
By the way, IE creates a new instance of the toolbar for each tab. So, the static data is useless in IE programming.

Please send me an example with this issue. I will test it.
Posted 05 Aug, 2011 07:52:05 Top
Phuong Nguyen




Posts: 52
Joined: 2009-04-08
Hi Sergey,

I sent email with attachment project for your testing (please check support email). I use static parameter because I want some of these parameter sharable between my Toolbar and Sidebar class. I did saw the toolbar is loaded in my IE9 with an empty toolbar run across on the top of browser. If I hardcoded a value to this label, i will be able to see the value on toolbar.

Thanks,
Phuong
Posted 05 Aug, 2011 13:49:18 Top
Sergey Grischenko


Add-in Express team


Posts: 7224
Joined: 2004-07-05
Hi Phuong.

The code in the example will never work correctly because add-ons are loaded after toolbars and explorere bars (if they are enabled). Please change the code as shown below. To compile the code you need to change the Modifiers property of 'label1' to 'public'.

private void IEModule_OnConnect(object sender, int threadId)
{
tblabel = "Test";

MyIEToolbar1 toolbar = this.ToolBars[0].ToolBarObj as MyIEToolbar1;
if (toolbar != null)
{
toolbar.label1.Text = tblabel;
}
}
Posted 08 Aug, 2011 06:23:59 Top