bitness-aware component

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

bitness-aware component
 
Subscribe
Leon Lai Kan




Posts: 200
Joined: 2018-12-20
Hi, Andrei


My computer uses:
* Windows 10 (64-bit)
* Visual Studio 2019 (64-bit)
* Office 2016 (32-bit)


I read your Article " Deploying Per-user Office Extensions via an MSI Installer"

Click here


It says:


If you use a 32-bit component in your Office extension (say a native-code DLL, ActiveX DLL , or .NET assembly), you have to compile it for the x86 platform. Please keep in mind that such an Office extension will work in 32-bit Office 2000-2016 only and will not work in 64-bit Office 2010-2016.

Similarly, if you use a 64-bit component, you have to compile the project for the x64 platform but your Office extension will work in 64-bit Office 2010-2016 only.

Summing up, if you use a bitness-aware component, your extension will work for Office versions of that bitness only.


MY QUESTION:


I create a simple Excel add-in: 1 Tab, 1 Group, I button.
I debug > register > start.

It loads correctly in Excel.
I tried numerous times. It works perfectly.

Then I add an About Box ( Project > Add New Item > About Box)
I debug > register > start.

It loads correctly in Excel. It works on a few occasions, then stops loading completely.

------
Could it be that the About Box I have used is a 64-bit component, and therefore fails to load in Excel 32-bit?


Thanks
Leon
Posted 08 Jul, 2019 05:23:39 Top
Dmitry Kostochko


Add-in Express team


Posts: 2839
Joined: 2004-04-05
Hi Leon,

Thank you for the detailed description.

Could it be that the About Box I have used is a 64-bit component, and therefore fails to load in Excel 32-bit?


I don't think so because you have added a standard .NET form. Moreover, you say "It loads correctly in Excel. It works on a few occasions, then stops loading completely.". So, it is caused by something else. Please check the contents of the adxLoader.log file, probably it contains an error.
Posted 08 Jul, 2019 07:47:58 Top
Leon Lai Kan




Posts: 200
Joined: 2018-12-20
Hi, Dmitry

Thanks for your reply.

I don't think so because you have added a standard .NET Form

Please note that my add-in does not "crash" if there is no About Box.
If I insert the template About Box (which has an image in it), sooner or later it "crashes".



Please check the contents of the adxLoader.log file

--------------------
When I set RegisterForAllUsers = False, then Build > Register > Start,
the add-in is correctly loaded in Excel.

A log file (adxloader.log) is generated, and it shows "Success" everywhere (i.e after each task).
So, I presume there are no errors.

------------------

But if I set RegisterForAllUsers = True, then Build > Register > Start,
the add-in is neither registered in Excel (Options > Add-in) nor does it load in Excel.

Also, THERE IS NO LOG FILE (adxloader.log)

There is also no entry in HKLM in Windows Registry.

Sometimes, there is a Registry entry in HKLM, but still no adxloader.log, and still not loading in Excel
----------------------

The problem is driving me crazy for months!

ADDED:

Is there any possibility that the software versions I am using are INCOMPATIBLE?
* Windows 10 (64-bit)
* Visual Studio 2019 (64-bit)
* Office 2016 (32-bit)
* ADX (latest version)

Leon
Posted 08 Jul, 2019 08:17:34 Top
Dmitry Kostochko


Add-in Express team


Posts: 2839
Joined: 2004-04-05
Hi Leon,

Thank you for the additional information. What else beside switching the RegisterForAllUsers property and adding the About doalog did you change in your project? BTW, I hope that you unregister your project before updating the RegisterForAllUsers property, correct?

Also, lets check the following things:
- Do you run your VS 2019 under elevated privileges?
- Do you have UAC settings on the default level in your Windows 10?

Is there any possibility that the software versions I am using are INCOMPATIBLE?


Everything is compatible, thank you. Note, Visual Studio remains a 32 bit application:
https://developercommunity.visualstudio.com/content/problem/517541/vs-2019-downloaded-x64-version-installed-x86.html
Posted 08 Jul, 2019 11:19:35 Top
Leon Lai Kan




Posts: 200
Joined: 2018-12-20
Dmitry,

... you unregister your project ...

Yes, I did unregister before build and register again

Elevated Privileges, UAC

NB: I have not yet reached the Setup project stage.
I just did: build > register > start Excel in Visual Studio.

Elevated Privileges:
Are you asking if I run Visual Studio as Admin? Yes, I do.

UAC:
My UAC slider is on the 2nd bar from top.
I have now pushed it to the top bar (Always notify).
Reboot computer. Still same problem.


What else did you change in your project?

Nothing.

Notice that I use a very SIMPLE add-in in order to pinpoint the problem: just 1 Tab, 1 Group, 1 button, 1 About Box, and 3 lines of code to Show the About Box when button is pressed.

I simply rebuilt with RegisterForAllUsers = T and F repeatedly to see when and where it crashes.

Mr.Andrei worked on my problem for a long time. He even witnessed the phenomenon through Teamviewer.


But I can say something:

None of my add-in EVER crashed if there are NO PICTURES.

But when I add pictures, as glyphs in my buttons, or as a picture in my About box, sooner or later, the add-in crashes.

It stops loading in Excel especially when RegisterForAllUsers = T


This is a very strange issue, and I cannot proceed in my add-in development.

If my add-in has not yet crashed, I can even PROVOKE IT AND MAKE IT CRASH: Simply by changing the picture one or more times (either in the About Screen or the Glyphs in the buttons). Then I build again. If it does not crash yet, it will crash after I build a few more times!

Sometimes, just before it crashes, I get this unhelpful message with no details:
Exception has been thrown by the target of an invocation.




I have already reformatted my computer twice and reinstalled everything many times. Same problem.

I HAVE A GUT FEELING THAT PICTURES ARE THE PROBLEM. I Use 32x32 png pictures.

COULD IT BE A CASE OF BADIMAGEFORMATEXCEPTION?

HOW CAN IMAGES PREVENT MY ADD-IN FROM LOADING IN EXCEL even though the add-in is registered in HKLM?

I also don't understand why the problem arises mainly when RegisterForAllUsers = True


Is there any way I can manually FORCE the add-in to load in Excel?


Please give me a LIST of things I could check and report back to you.




-------
Best Regards,
Leon
Posted 08 Jul, 2019 15:35:38 Top
Andrei Smolin


Add-in Express team


Posts: 16466
Joined: 2006-05-11
Hello Leon,

Leon Lai Kan writes:
But when I add pictures, as glyphs in my buttons


Are you saying this occurs if you set an image on a Ribbon button using the Glyph property? I.e. with no About box?

I assume there's an About dialog that doesn't prevent your add-in from loading. If so, please send me two copies of the About box files from your project: 1) before and 2) after you modify the dialog so that the issue may occur.

Leon Lai Kan writes:
I HAVE A GUT FEELING THAT PICTURES ARE THE PROBLEM.


This requires a prove.

Leon Lai Kan writes:
COULD IT BE A CASE OF BADIMAGEFORMATEXCEPTION?


No. See https://docs.microsoft.com/en-us/dotnet/api/system.badimageformatexception?view=netframework-4.8.

Leon Lai Kan writes:
HOW CAN IMAGES PREVENT MY ADD-IN FROM LOADING IN EXCEL even though the add-in is registered in HKLM?


We are very pessimistic about your explanation: we don't see a relation between images and ability/inability to load in Excel. Anyway, a good hypothesis must also explain why the issue occurs sometimes only.

Note that to be registered in HKLM, the add-in must have at least the three keys listed in section Locating COM Add-ins in the Registry, see the PDF file in the folder {Add-in Express}\Docs on your development PC. Do you have them? Specifically, after I register a per-machine add-in on my 64-bit Windows, I search through the registry for the ProgId of my add-in and find out these keys:
- the CLSID key in HKLM\SOFTWARE\Classes\CLSID\{Guid attribute of the add-in module class here}; the default value of the InprocServer32 subkey points to adxloader64.dll
- the ProgId key in HKLM\Classes\{ProgId attribute of the add-in module class here}
- the CLSID key in HKLM\SOFTWARE\Classes\WOW6432Node\CLSID\{Guid attribute of the add-in module class here}; the default value of the InprocServer32 subkey points to adxloader.dll
- the Add-in key in HKLM\SOFTWARE\Microsoft\Office\Excel\Addins\{ProgId attribute of the add-in module class here}
- the CLSID key in HKLM\SOFTWARE\WOW6432Node\Classes\CLSID\{Guid attribute of the add-in module class here}; the default value of the InprocServer32 subkey points to adxloader.dll
- the Add-in key in HKLM\SOFTWARE\WOW6432Node\Microsoft\Office\Excel\{ProgId attribute of the add-in module class here}

Leon Lai Kan writes:
Is there any way I can manually FORCE the add-in to load in Excel?


No. This is Excel who decides whether to load the add-in or not. This is the add-in who may fail and thus break the loading process. Note that adxloader.log may have a trace of this fail. That is, once you see your add-in not loaded, check adxloader.log: if the add-in gets through the loading phases correctly, the final line in adxloader.log reads: The instance of the managed add-in class has been created successfully. When checking adxloader.log always make sure it isn't an old one.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 09 Jul, 2019 06:30:35 Top
Leon Lai Kan




Posts: 200
Joined: 2018-12-20
Hi, Andrei

Thanks a lot for your very helpful information on Registry.

I will keep records of the 5 keys you have given me, and make frequent backups of my folders.

If my program crashes again, I will compare the keys before and after the crash, and contact you again.

Leon
Posted 10 Jul, 2019 07:37:26 Top
Andrei Smolin


Add-in Express team


Posts: 16466
Joined: 2006-05-11
Hello Leon,

The keys are created when you register the add-in. This is the moment when you need to compare the keys. After that the keys can't be changed unless you unregister the add-in.

Leon Lai Kan writes:
... then Build > Register > Start,


I assume this means "click the Register Project Item in the Build menu (=Build | Register Project)" or "right-click the add-in project in the Solution Explorer and choose Add-in Express | Register on the context menu" . Please confirm my understanding is correct.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 10 Jul, 2019 07:44:46 Top
Leon Lai Kan




Posts: 200
Joined: 2018-12-20
Hi, Andrei

Please confirm my understanding is correct.


On the Visual Studio Menu, I click: Build > Rebuild About200

Then, on the same menu, I click: Register Project

Then I click Start (i.e. Start Excel)

--------

My new project crashed again just now.

I created a SIMPLE Project: Just 1 Tab, 1 Group, 1 Button.

Then I added 1 About Box:
Project > Add New Item > About Box
NB: There is already a logo on that About Box.
I also added 3 lines of code in the click event of the button to display the About Box.

--------

I kept on rebuilding and registering the project many times to see at which point it crashes.
But this time I am keeping a watch on the Registry entries before and after the crash.

-------
In the Project Properties, I set RegisterForAllUsers = False.
I built the project many times. It did not crash.
I even changed the logo. It did not crash.

-------
Then I set RegisterForAllUsers = True.
I built the project many times. I changed logo. It did not crash.

--------
I have now done 40 trials!
I thought: " I can't reproduce my issue now! What happens? In the past, it crashed much earlier."

---------
Then I set RegisterForAllUsers = False AGAIN.
This time, when I built and then registered, the add-in is not loaded in Excel.
The "crash" has just occurred!

----------
Thanks to your info on Registry, I could compare the entries Before and After the "crash".

----------
This is what I notice:
Now, LoadBehaviour = 0 in 2 of the keys you have given me. Formerly LoadBehaviour = 3

------------
See the 3 attached pictures.



Awaiting your instructions for further tests.

Leon

[img]https://cp.sync.com/file/1395452569/view/image[/img]
Posted 10 Jul, 2019 08:57:27 Top
Andrei Smolin


Add-in Express team


Posts: 16466
Joined: 2006-05-11
Leon Lai Kan writes:
Now, LoadBehaviour = 0


Office doesn't do this. It sets LoadBehavior=2 if the add-in fails in some way. Make sure no COM add-ins are loaded. Also check the log of your antivirus.

I don't see the images. Please send them to the support email address.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 10 Jul, 2019 10:59:20 Top