can i set AppDomain of Add-in Express

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

can i set AppDomain of Add-in Express
 
chris chen


Guest


Hi,

I created a ole/activex which embeded chromium browser into powerpoint, i insert the com object into ppt with api PowerPointApp.ActiveWindow.Selection.SlideRange.Shapes.AddOLEObject(), but I found a problem when i open the ppt that has inserted three ole objects, each com object will be initialized three times, if I implement the event adxPowerPointEvents_SlideSelectionChanged, when traversing all the shapes in this event handler, the first two instantiations are in default appdomains, the third instance is triggered by GetAllShapes(slides[i].Shapes, ref existingShapes) and the appdoamin is C:\Users\cc\Desktop\MyAddin183\MyAddin183 \bin\Debug\, if I don't create this handle, then all three instantiations are in default appdomains. When I get the inserted ole object by iterating through all the shapes, I get the ole objects, whose appdomain can be the default appdomain, or it can be C:\Users\cc\Desktop\MyAddin183\MyAddin183 \bin\Debug\, with a certain randomness. I want to know if it is possible to set add-in express appdomains to default appdomains,because it seems that whenever an ole load is triggered with add-in express, its appdomain is "C:\Users\cc\Desktop\MyAddin183\MyAddin183 \bin\Debug\", either by AddOLEObject or by referencing slides

I saw this article "https://www.add-in-express.com/docs/net-deploying-addins.php#loading-assembly" mentioning that add-in express loader can set the appdomain
Loading process
The following steps occur when a user starts an Office application.

The application locates the registry entries that identify your Office add-in. These records are created as part of the registration process.
If the application finds the corresponding registry entries, it loads either adxloader.dll (32bit Office applications) or adxloader64.dll (64bit Office). The installer of your add-in deploys these DLLs to the add-in's installation folder.
The loader reads the manifest, which is located in the same folder and locates the add-in assembly. If the manifest specifies this, a log file is created at the specified location. See also Add-in Express loader manifest and Get details about add-in loading.
The loader initializes CLR, creates an AppDomain using the configuration file specified by the manifest, loads your assembly into the domain, and creates an instance of your add-in module.
When one of the start-up events is received on the IDTExtensibility2 and IRibbonExtensibility COM interfaces, the loader translates the call to the AddinInitialize and OnRibbonBforeCreate events of the add-in module, respectively, and in this way your assembly starts functioning as an Office add-in.


thanks!
Posted 05 Jan, 2023 01:46:38 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hello Chris,

An Add-in Express add-in is designed to be loaded in a specific AppDomain. I wonder whether you need to have the add-in if you develop an OLE/ActiveX control.

Regards from Poland (GMT+1),

Andrei Smolin
Add-in Express Team Leader
Posted 06 Jan, 2023 07:57:44 Top
chris chen


Guest


Hi Andrei,

thanks for your reply. yes i need the Add-in Express add-in which is designed to be loaded in default AppDomain. if so the ole/activex can be in the same appdomains as add-in express regardless of ole/activex's loading via Shapes.AddOLEObject or from an open file.
Posted 06 Jan, 2023 08:43:30 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hello Chris,

An Add-in Express add-in is designed to be loaded in a specific AppDomain so that 1) it doesn't depend on any other .NET-based code and 2) it doesn't influence or get influenced by any other .NET-based code loaded in Excel.

I wonder what code is is executed in the default AppDomain and why you want the add-in code to be intermixed with that code. Obviously, there should be two independent code bases: the add-in and what ever code you develop. If you want your code to

Regards from Poland (GMT+1),

Andrei Smolin
Add-in Express Team Leader
Posted 06 Jan, 2023 10:05:41 Top