none
Load Behavior and Word add-in. RRS feed

  • Question

  • I have a query regarding Word add-in and load behavior. I am using administrator account to carry out the installation and running the word. Can someone please help clarifying the same?

    Load Behavior when add-in is installed for current user or HKCU:

    If I install the add-in for current user, the registry entries will be created under HKCU\Software\Microsoft\Office\Word\ Addins\[addin name] . I am setting the LoadBehavior value to 10 (Hex) and opening the word. If I check the load behavior value of the add-in, it reads “Load at next startup only”. After closing this COM Add-ins window, I click on the add-in and then close the word. At this moment, LoadBehavior value changes to 9. From next time onwards, if I open word Load Behavior is going to be Load On Demand. This behavior is in line with the behavior explained at https://msdn.microsoft.com/en-us/library/bb386106.aspx  

     Add-in behavior with LoadBehavior = 10

    Once we click on add-in and close the word, load behavior value changes to 9.

    LoadBehavior = 9  

    Load Behavior when add-in is installed for everyone on the machine / HKLM:

    If I install the add-in for everyone, the registry entries will be created under HKLM\Software\{Wow6432Node}\Microsoft\Office\Word\ Addins\[addin name] . At this time, I am setting the LoadBehavior value to 10 (Hex) and opening the word. If I check the load behavior value of the add-in, it should read  “Load at next startup only” but in this case it reads “Load on demand, (currently loaded) ”. After closing this COM Add-ins window, I click on the add-in and then close the word. At this moment, LoadBehavior value should change to 9. But that is also not happening and LoadBehavior value continues to remain 10.

    Can someone please explain why this discrepancy in behavior between HKLM and HKCU even if LoadBehavior value (10) is same?

    Wednesday, September 2, 2015 9:12 PM

Answers

  • >>>Can someone please explain why this discrepancy in behavior between HKLM and HKCU even if LoadBehavior value (10) is same?

    Registering VSTO Add-ins for the Current User vs. All Users

    When a VSTO Add-in is installed, it can be registered in two ways:

    •For the current user only (that is, it is available only to the user that is logged onto the computer when the VSTO Add-in is installed). In this case, the registry entries are created under the HKEY_CURRENT_USER.

    •For all users (that is, any user that logs onto the computer can use the VSTO Add-in). In this case, the registry entries are created under HKEY_LOCAL_MACHINE.

    All VSTO Add-ins that you create by using Visual Studio can be registered for the current user. However, VSTO Add-ins can be registered for all users only in certain scenarios. These scenarios depend on the version of Microsoft Office on the computer and how the VSTO Add-in was deployed.

    LoadBehavior Values

    The LoadBehavior entry under the Root\Software\Microsoft\Office\application name\Addins\add-in ID key contains a bitwise combination of values that specify the run time behavior of the VSTO Add-in. The lowest order bit (values 0 and 1) indicates whether the VSTO Add-in is currently unloaded or loaded. Other bits indicate when the application attempts to load the VSTO Add-in.

    Typically, the LoadBehavior entry is intended to be set to 0, 3, or 16 (in decimal) when the VSTO Add-in is installed on end user computers. By default, Visual Studio sets the LoadBehavior entry of your VSTO Add-in to 3 when you build or publish it.

    The following table lists all the possible values of the LoadBehavior entry

    Value (in decimal) VSTO Add-in status VSTO Add-in load behavior Description
    9 Loaded Load on demand

    The VSTO Add-in will be loaded only when the application requires it, such as when a user clicks a UI element that uses functionality in the VSTO Add-in (for example, a custom button in the Ribbon).

    If the application successfully loads the VSTO Add-in, the LoadBehavior value remains 9, but the status of the VSTO Add-in in the COM Add-ins dialog box is updated to indicate that the VSTO Add-in is currently loaded. If an error occurs when loading the VSTO Add-in, the LoadBehavior value changes to 8.

    16 Loaded Load first time, then load on demand

    Set this value if you want your VSTO Add-in to be loaded on demand. The application loads the VSTO Add-in when the user runs the application for the first time. The next time the user runs the application, the application loads any UI elements that are defined by the VSTO Add-in, but the VSTO Add-in is not loaded until the user clicks a UI element that is associated with the VSTO Add-in.

    When the application successfully loads the VSTO Add-in for the first time, the LoadBehavior value remains 16 while the VSTO Add-in is loaded. After the application closes, the LoadBehavior value changes to 9.

    For more information, click here to refer about Registry Entries for VSTO Add-ins

    Friday, September 4, 2015 7:21 AM

All replies

  • >>>Can someone please explain why this discrepancy in behavior between HKLM and HKCU even if LoadBehavior value (10) is same?

    Registering VSTO Add-ins for the Current User vs. All Users

    When a VSTO Add-in is installed, it can be registered in two ways:

    •For the current user only (that is, it is available only to the user that is logged onto the computer when the VSTO Add-in is installed). In this case, the registry entries are created under the HKEY_CURRENT_USER.

    •For all users (that is, any user that logs onto the computer can use the VSTO Add-in). In this case, the registry entries are created under HKEY_LOCAL_MACHINE.

    All VSTO Add-ins that you create by using Visual Studio can be registered for the current user. However, VSTO Add-ins can be registered for all users only in certain scenarios. These scenarios depend on the version of Microsoft Office on the computer and how the VSTO Add-in was deployed.

    LoadBehavior Values

    The LoadBehavior entry under the Root\Software\Microsoft\Office\application name\Addins\add-in ID key contains a bitwise combination of values that specify the run time behavior of the VSTO Add-in. The lowest order bit (values 0 and 1) indicates whether the VSTO Add-in is currently unloaded or loaded. Other bits indicate when the application attempts to load the VSTO Add-in.

    Typically, the LoadBehavior entry is intended to be set to 0, 3, or 16 (in decimal) when the VSTO Add-in is installed on end user computers. By default, Visual Studio sets the LoadBehavior entry of your VSTO Add-in to 3 when you build or publish it.

    The following table lists all the possible values of the LoadBehavior entry

    Value (in decimal) VSTO Add-in status VSTO Add-in load behavior Description
    9 Loaded Load on demand

    The VSTO Add-in will be loaded only when the application requires it, such as when a user clicks a UI element that uses functionality in the VSTO Add-in (for example, a custom button in the Ribbon).

    If the application successfully loads the VSTO Add-in, the LoadBehavior value remains 9, but the status of the VSTO Add-in in the COM Add-ins dialog box is updated to indicate that the VSTO Add-in is currently loaded. If an error occurs when loading the VSTO Add-in, the LoadBehavior value changes to 8.

    16 Loaded Load first time, then load on demand

    Set this value if you want your VSTO Add-in to be loaded on demand. The application loads the VSTO Add-in when the user runs the application for the first time. The next time the user runs the application, the application loads any UI elements that are defined by the VSTO Add-in, but the VSTO Add-in is not loaded until the user clicks a UI element that is associated with the VSTO Add-in.

    When the application successfully loads the VSTO Add-in for the first time, the LoadBehavior value remains 16 while the VSTO Add-in is loaded. After the application closes, the LoadBehavior value changes to 9.

    For more information, click here to refer about Registry Entries for VSTO Add-ins

    Friday, September 4, 2015 7:21 AM
  • Hello Trushar,

    I could be wrong but I believe that the discrepancy is by design. It is often the case that a normal (non-elevated) user cannot write to the LM hive.

    You will find that even though the LoadBehaviour does not change in LM, Office "overwrite" this value by writing in CU when the application is closing.

    Try going through your second scenario by running Office elevated and you will find that the value does change as you would expect...

    Hope it helps.

    Leo

    • Proposed as answer by Lenny S Wednesday, September 9, 2015 9:21 AM
    • Unproposed as answer by Lenny S Wednesday, September 9, 2015 10:55 AM
    Wednesday, September 9, 2015 9:21 AM
  • Hello again Trushar,

    I looked into your issue further and found that even though the behaviour I described above is correct, the HKCU value of 9 does not override the HKLM value of 10 and the addin is always Loaded at startup ie. it is marked as "Loaded on Demand (currently loaded)".

    One way to fix this is by including (copying over) the Manifest value in the HKCU hive. This makes the LoadBehaviour value in HKCU override the one in HKLM as I initially suggested. However this is not ideal because it will cause errors when you uninstall the addin.

    Maybe it is worth opening a support case with Microsoft...?

    Wednesday, September 9, 2015 11:14 AM