System.Runtime.InteropServices.StandardOleMarshalObject

Replaces the standard common language runtime free-threaded marshaler with the standard OLE STA marshaler
This class prevents calls made into a hosting object by OLE from entering threads other than the UI thread.
Any public static members of this type are thread safe
Any instance members are not guaranteed to be thread safe


If you expose your add-in through the COMAddIn.Object method either explicitly (non VSTO) or implicitly (with VSTO through RequestComAddInAutomationService) you might run into threading issues


Scenarios:
1) Being called from VBA - OK
2) Being called from another add-in in the same process
3) Being called from another process or thread there is a problem. By default these will not be executed on the main UI thread.
From a COM perspective all managed objects are thread neutral (by default)
What we want is to tell COM that our managed object lives in a Single Threaded Apartment (STA).



Needed for COMVisible interfaces passing List<string>
Necessary when working with generics



© 2020 Better Solutions Limited. All Rights Reserved. © 2020 Better Solutions Limited TopPrev