Loading COM and Excel Automation addin in same appdomain.

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

Loading COM and Excel Automation addin in same appdomain.
Loading COM and Excel Automation addin in same appdomain. 
Ashim Mishra


Guest


Hi Team,

I am trying to load my COM and Excel automation addin in same appdomain. I have read your https://www.add-in-express.com/creating-addins-blog/2010/03/24/addin-xll-rtd-one-assembly/ article and was able to work it out. I called one of my public UDF function directly using ExcelApp.Evaluate from my COM's WindowActive handler and was able to load both in one AppDomain. Initially i tried to call it from AddinInitalize, AddinStartupComplete handler but it was returning the error code. Keeping it in Window Active handler worked for me. But whenever i am trying to open any workbook directly(Just double clicking on any excel file) excel loads UDF(excel automation) before invoking WindowActive or any other events.
It would be great help if you could help me with the event that gets invokes before excel invokes UDF.


Thanks in advance.
Posted 11 Feb, 2019 10:58:48 Top
Andrei Smolin


Add-in Express team


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

The earliest possible moment for a COM add-in to invoke your UDF is the OnHostApplicationInitialized() method; override it on the add-in module. I wonder if this works for you in that scenario.


Andrei Smolin
Add-in Express Team Leader
Posted 11 Feb, 2019 11:07:39 Top
Ashim Mishra


Guest


No, that didn't work for me. Still emitting the same error code. Is there any other way i can make it possible ?
Posted 11 Feb, 2019 11:13:37 Top
Ashim Mishra


Guest


Hi Andrei,

Any update on the solution to make both COM and Excel automation addin in same appdomain ?

Thanks
Posted 12 Feb, 2019 02:29:03 Top
Andrei Smolin


Add-in Express team


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

Checking...


Andrei Smolin
Add-in Express Team Leader
Posted 12 Feb, 2019 03:04:41 Top
Andrei Smolin


Add-in Express team


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

I assume there's no way to load the Automation add-in in the AppDomain of the COM add-in in this scenario. Does this produce any difficulty?


Andrei Smolin
Add-in Express Team Leader
Posted 12 Feb, 2019 04:47:28 Top
Ashim Mishra


Guest


Hello Andrei,

Yes, this might impact lots of area in our application. we are sharing few assemblies which are being initialized by COM addin, and we are using them in Automation add-in. Since we cannot access those properties(of common assemblies) our flow of different functionalities like authentication etc will not work. Do you suggest any other way something like XLL to do the same job. Based on the article that you wrote it looks like XLL always load in the same appdomain as the COM addin.

Thanks
Posted 12 Feb, 2019 09:38:26 Top
Andrei Smolin


Add-in Express team


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

Variant #1.Different AppDomains.

An Excel Automation add-in can call a public method defined on the add-in module:

ExcelApp.COMAddins.Item(strMyComAddinProgId).Object.MyPublicPropertyOrMethod.

1. strMyComAddinProgId - see the ProgId attribute of your add-in module.
2. MyPublicPropertyOrMethod is called via late binding (see System.Type.InvokeMember in MSDN or search through our forums)

See also http://www.add-in-express.com/creating-addins-blog/2010/07/02/standalone-application-addin-communicate/.

A COM add-in may invoke a public method defined in the Automation add-in.

Variant #2. You can use an XLL. The problem is. Typically, you use the Excel object model in an Excel Automation add-in. But, you should not use the Excel object model in an XLL while implementing the same functionality in an XLL may be painfully difficult.


Andrei Smolin
Add-in Express Team Leader
Posted 12 Feb, 2019 09:53:24 Top