Is there any drawback of making the add-in DLL marked as ComVisible=false by default, and then adding ComVisible only on the AddinModule class?

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

Is there any drawback of making the add-in DLL marked as ComVisible=false by default, and then adding ComVisible only on the AddinModule class?
 
EnterpriseDev


Guest


Background information: I received various compiler warnings related to COM such as (1) "Warning: Type library exporter encountered a generic type instance in a signature. Generic code may not be exported to COM." and (2) That a few DevExpress dll's needed to be registered with regasm /tlb.

To solve this I made everything in the main Assembly hidden from COM as default (Project->Properties->Assembly Information and uncheck Make Assembly COM-visible). Then I added the attribute [ComVisible(true)] to the AddinModule that derives from AddinExpress.MSO.ADXAddinModule, so that the ADX functions would be visible for COM.

Is there anything wrong with this approach?
Posted 23 Jul, 2016 02:01:38 Top
EnterpriseDev


Guest


I think I found the answer myself but any additional information you might have on the topic can be useful. By only exposing AddinModule as COM visible, I received a few run-time errors about missing code on production (non-dev) environments that I first did not see when starting this thread. It seems like the DevExpress code I was using was not "callable" from the main add-in DLL even though the correct DLLs were available in the add-in installation folder. So I reverted back to using ComVisible for the whole project and then ran "regasm /tlb" on the external dependencies I had. For the warning "Warning: Type library exporter encountered a generic type instance in a signature. Generic code may not be exported to COM.", I made the class using that ComVisible=false, and then made sure I tested properly that the code still worked in production environments.
Posted 24 Jul, 2016 11:47:55 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hello EnterpriseDev,

Setting Comvisible=false on the assembly level makes all public classes unanvailable for COM; default is true. You may want to specify ComVisible=True on specific classes. The COM-visible classes can be used from other COM clients such as VBA.

To find more about this I suggest that you read these articles:
- http://www.codeproject.com/Articles/612604/Best-Practice-in-Writing-a-COM-Visible-Assembly-Cs
- http://stackoverflow.com/questions/3309764/why-is-marking-an-assembly-comvisibletrue-discouraged
- [URL=http://stackoverflow.com/questions/15688395/whats-the-deal-with-comvisible-default-and-public-classes-com-exposure]What's the deal with [ComVisible] default and public classes COM exposure?[/URL]
- [URL=https://blogs.msdn.microsoft.com/cristib/2012/10/31/how-com-works-how-to-build-a-com-visible-dll-in-c-net-call-it-from-vba-and-select-the-proper-classinterface-autodispatch-autodual-part12/]How COM works & How to build a COM visible DLL in C#.Net, call it from VBA and select the proper ClassInterface (AutoDispatch, AutoDual) [part1/2][/URL]


Andrei Smolin
Add-in Express Team Leader
Posted 25 Jul, 2016 04:38:17 Top