Word AddIn not working on Vista

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

Word AddIn not working on Vista
Works on XP... 
Andy Gallo




Posts: 4
Joined: 2009-07-27

I have a Word add-in which works well on XP for both Word 2003 and 2007. On Vista it doesn't even load. Looking at the add-ins in Word you see "Not Loaded. A runtime error occurred during the loading of the COM add-in."

I've tried packaging MS KB KB908002 with setup.exe.

I have UAC enabled on my target Vista machine.

I've set RegisterForAllUsers to true in AddinModule_AddinInitialize but the event handler never gets called (whereas it does get called on XP). I've tried putting try/catch blocks liberally in the code to find the load error, but I think the failure is so early on in the load process as to make my debug code useless.

I've tried removing and re-adding adxloader.dll from Word's COM add-ins, but am unable to do that while Word is running...

I've tried following along with the threads on this forum regarding others and their similar issues, but am out of ideas.

I'm about to investigate the use of caspol.exe...

Help?

- andy
Posted 27 Jul, 2009 15:57:33 Top
Andrei Smolin


Add-in Express team


Posts: 18817
Joined: 2006-05-11
Hello Andy,

When your add-in is installed, an instance of the add-in module is created and its constructor is run. The loader reads RegisterForAllUsers and creates appropriate registry entries. So, it's too late to change RegisterForAllUsers in AddinInitialize.

KB908002 isn't required if you use develop a COM add-in using Add-in Express version 2008-2009. It might be required if you develop an XLL add-in with any Add-in Express version.

So, it looks like RegisterForAllUsers is false. Is this correct?

I'd like to know the values of the following properties:

- setup project. View | File System | Application Folder. DefaultLocation = ?
- setup project. PostBuildEvent = ?

Do you run setup.exe or .MSI? Are you an administrator on Vista? Is UAC on? Are you using Vista SP2? Please make sure that you use the latest service packs for all Office versions on Vista.


Andrei Smolin
Add-in Express Team Leader
Posted 27 Jul, 2009 16:28:29 Top
Andy Gallo




Posts: 4
Joined: 2009-07-27
On XP/Word2007 I can see that RegisterForAllUsers is initially false, yes.

- setup project. View | File System | Application Folder. DefaultLocation = C:\Program Files\MyCompany\MyApp

I have updated Vista (my version is Vista Business) and Word 2007 to the latest service packs. Following that I tried installing using setup.exe (which also installs KB908002) and (after a full uninstall and reboot) tried installing the msi directly. Both produced the same results when Word was started ("Not Loaded. A runtime error occurred during the loading of the COM add-in.")

I am "adminstrator" on the Vista box. UAC is on (green light).

And finally,

- setup project. PostBuildEvent = "8:\"C:\\Program Files\\Add-in
Express\\Add-in Express for .NET\\Bin\\DisableUAC.exe\"
\"$(BuiltOuputPath)\" /UAC=Off"

That sure looked suspicious. I changed the value to "8:" with no benefit. I tried installing for "everyone" and for "just me" with the same erroneous result.

Seeking input. Thank you.

- andy

Posted 28 Jul, 2009 14:47:24 Top
Andrei Smolin


Add-in Express team


Posts: 18817
Joined: 2006-05-11
Hello Andy,

It looks like you are installing the add-in after you get an UAC prompt (probably, KB908002 produces it). If so, this means you get administrator permissions at this moment.

After the installation finishes, you run Word with standard user permissions (that's what UAC is designed for: an administrator gets administrator permissions only after UAC prompts for this).

As a standard user, you can't access files or folders that an administrator can access. And this is the moment in which your add-in brokes: it fires an exception and Word (as well as any other Office application) changes its LoadBehavior in the registry to 2 (or blocks it in some other way).

To verify this theory find winword.exe (it's located in C:\Program Files\Microsoft Office\Office 12 on my PC) and use "Run as administrator" to run it. If LoadBehavior of your add-in in the registry is 3, and if you don't have other problems in your code, Word will load your add-in.


Andrei Smolin
Add-in Express Team Leader
Posted 28 Jul, 2009 15:28:48 Top
Andy Gallo




Posts: 4
Joined: 2009-07-27

I installed my MSI, checked the registry to see that LoadBehavior was set to 3, then located winword.exe and did the right click "run as administrator".

Word came up, my app did not load, and LoadBehavior got set to 2.

???

- andy
Posted 28 Jul, 2009 16:41:34 Top
Andrei Smolin


Add-in Express team


Posts: 18817
Joined: 2006-05-11
Hello Andy,

LoadBehavior = 2 often is an indication of an exception at add-in stratup.


Andrei Smolin
Add-in Express Team Leader
Posted 29 Jul, 2009 07:09:40 Top
Andy Gallo




Posts: 4
Joined: 2009-07-27
In an effort to find that exception I've added some try/catch and debug statements to my code as follows:

public AddinModule()
{
try
{
// TODO
MessageBox.Show("Here in AddinModule constructor", "Info");
InitializeComponent();
// Please add any initialization code to the AddinInitialize event handler
AddinInitialize += new AddinExpress.MSO.ADXEvents_EventHandler(AddinModule_AddinInitialize);
}
catch (Exception e)
{
MessageBox.Show("Error constructing AddinModule: " + e.Message, "Error");
}
}

public static void AddinRegister(Type t)
{
try
{
// TODO
MessageBox.Show("Here in AddinRegister", "Info");
AddinExpress.MSO.ADXAddinModule.ADXRegister(t);
}
catch (Exception e)
{
MessageBox.Show("Error registering addin: " + e.Message, "Error");
throw e;
}
}

void AddinModule_AddinInitialize(object sender, EventArgs e)
{
// TODO
MessageBox.Show("Here in AddinModule_AddinInitialize", "Info");
}



The behavior is:

1) On XP/Word07 and Win2K/Word03: At the end of the msi running, "Here in AddinRegister" followed by "Here in AddinModule constructor". The msi then displays the final page and is done. On Word startup, "Here in AddinModule constructor" followed by "Here in AddinModule_AddinInitialize". My addin then functions as intended.

2) On Vista/Word07: Same behavior for the msi as above - AddinRegister and the AddinModule constructor are called. On Word startup, however, we see no messages at all - the addin constructor is not called, nor does it throw exception. My addin is not loaded.

What code can I show you in an effort to find the solution? Thanks.

- andy
[/CODE][CODE]
Posted 29 Jul, 2009 12:14:27 Top
Andrei Smolin


Add-in Express team


Posts: 18817
Joined: 2006-05-11
Hello Andy,

Thank you for the information. Can you send me adxloader.log created right after you install your add-in (before you start Word)? The file is typically located in My Documents\Add-in Express. Send your e-mail to the support e-mail address mentioned in {Add-in Express install folder}\readme.txt. Please make sure your e-mail contains a link to this topic.


Andrei Smolin
Add-in Express Team Leader
Posted 29 Jul, 2009 13:04:01 Top