Henri Pellemans
Posts: 7
Joined: 2023-08-10
|
Hi at ADX,
Using
Win 10 PRO 64-bit
Excel 365 64-bit
VS2022 VB.NET
ADX
All software most recent versions
Referring to an old topic
https://www.add-in-express.com/forum/read.php?FID=5&TID=10033
I moved some Public Shared Functions from the main XLL module to an Additional XLL module.
The functions in the main and additional module work fine, as I have crossreferences the modules by an Import statement.
So far so good.
However the functions in the Additional XLL module don't appear in Excel. The solution Eugene offered some 12 years ago does not work, at least I don't know how to do this. I think the ADX and/or VS software has changed.
Any idea how to fix this?
By the way, adding the first Addiotional XLL module automatically adds a reference (Import statement) to the main XLL module. Adding the second one, no reference to the main XLL module is made. It is not difficult to do so manually, just noticed it.
Regards from the Netherlands,
Henri |
|
Andrei Smolin
Add-in Express team
Posts: 19122
Joined: 2006-05-11
|
Hello Henri,
That section reads as follows. Having an additional module in your add-in assembly doesn't make sense; so you are expected to have it in another assembly. Then you must inform the main module that you have an additional module. When the add-in starts, it reads that information, loads the other library and invokes the additional module class.
You can specify that information at the design time or run time; the section 'How to develop the modular architecture of your COM and XLL add-in' describes doing this at the run time.
At the design time, you do this. Obtain the ProgId of your additional module. Open the designer of your main module, and, in the Properties window, start the editor of the Modules property, add an item to the collection and set the item's ModuleProgId property to the ProgId of your additional module.
How to add an additional module to a class library.
Create a class library project (.NET Framework) in the solution where you have your add-in project. Add an additional module to the add-in project. Move the additional module to the class library project; see menu File | Move {file name} into | {another project}.
How to obtain the ProgId of your additional module.
Right-click the class library project and choose Properties. Switch to the Compile tab (VB.NET) or to the Build tab (C#). Check the 'Register for COM interop' check box. Build the class library project. Start REGEDIT.EXE. Search the name of your additional module class in the registry.
In a test scenario I have this registry key (I call it a ProgID key): HKEY_CLASSES_ROOT\ClassLibrary1.XLLAdditionalModule1; that is {project name}.{additional module name}.
For the user or for all users?
Note that in my case the ProgID key is created in HKEY_CLASSES_ROOT, not in HKCU; that is "for all users", not "for the user". This difference is mentioned in section 'How to develop the modular architecture of your COM and XLL add-in': HKEY_CLASSES_ROOT means the registration was made with administrative permissions; this is so because my IDE is started elevated. Your installer may not have that luxury and you will need to create a similar key in HKCU. Note other possibilities mentioned in that section.
Creating the ProgID in HKCU manually also requires that you create all keys and registry values associated with CLSID.
The ProgID key contains a subkey called CLSID. Searching the value of that CLSID (simply 'this CLSID') in the registry finds it in HKEY_CLASSES_ROOT\CLSID\{some CLSID here}; study subkeys of that key.
Suggestion: google for ProgID, CLSID, and how to find them in the registry. Suggestion: check also section 'Locating COM add-ins in the registry' of the Add-in Express manual; it provides a small description of the CLSID and ProgID keys.
NOTE: building a class library project with the 'Register for COM interop' check box selected registers public classes of the class library project in the registry; make sure to clear that check box and build your class library project once again to get it unregistered; having such a key non-deleted may cause issues that would require you to detect such entries in the registry and delete them. When you register/unregister an Add-in Express project in the IDE, Add-in Express manipulates that check box behind the scenes.
HTH
Regards from Poland (GMT+2),
Andrei Smolin
Add-in Express Team Leader |
|
Henri Pellemans
Posts: 7
Joined: 2023-08-10
|
Hi Andrei,
More than one XLL module in one XLL add-in project does make sense. I have UDFs that not need updates. But a lot of UDFs have to be updated each month, or each half year of each year or incidentally. I want to separate them.
At the design time, you do this. Obtain the ProgId of your additional module. Open the designer of your main module, and, in the Properties window, start the editor of the Modules property, add an item to the collection and set the item's ModuleProgId property to the ProgId of your additional module.
It was a long time ago I used Additional XLL modules, so I just forgot how to handle this. In fact it was quite easy to add the additional XLL modules to the Modules property of the main XLL. That said, the solution of Eugene, some 12 year ago still is correct :), I overlooked it.
FYI: at the time being I just register my add-ins. There is no "Publish" project.
As always, many thanks for your answer.
Henri |
|