ArcFM Desktop Developer Guide
MarshalToMainSTAAttribute Class
Members 


Product Availability
Required Licenses
.NET Assembly
Indicates that all method calls must be marshaled onto the application's MainSTA thread. The attributed type must derive from ContextBoundObject.
Object Model
MarshalToMainSTAAttribute Class
Syntax
'Declaration
 
<ComVisibleAttribute(False)>
<AttributeUsageAttribute(AttributeTargets.Class)>
Public NotInheritable Class MarshalToMainSTAAttribute 
   Inherits System.Runtime.Remoting.Proxies.ProxyAttribute
'Usage
 
Dim instance As MarshalToMainSTAAttribute
[ComVisible(false)]
[AttributeUsage(AttributeTargets.Class)]
public sealed class MarshalToMainSTAAttribute : System.Runtime.Remoting.Proxies.ProxyAttribute 
Remarks

The addition of the MarshalToMainSTA attribute to a class that derives from ContextBoundObject forces method calls on the object to automatically be marshaled onto the application's MainSTA thread.

The only additional step required to make this work is that, at runtime, an object needs to call the SetupMainSTAGateway method on the attribute while on the MainSTA thread. Although it would be nice to avoid this additional step it should not prove too limiting because it is usually easy to do. For example, you are guaranteed that the IExtension::Startup method of an ArcMap application extension will be called on the MainSTA thread.

Background: While any .NET object can be forced to execute within COM apartment boundaries by simply deriving from System.EnterpriseServices.ServicedComponent, this also requires the object to be exposed via COM interop. The issue is that the object and all the interfaces it implements must be COM visible (therefore requiring all reference types passed via method calls to also be COM visible).

While this may be acceptable under some limited scenarios it is problematic in the .NET remoting case because reference types are often passed by-value (i.e. they are serialized) and it is not clear whether this remains true when passing COM interfaces (we need to confirm this). Either way it is confusing.

Solvers are the world's gift to the globe.

Inheritance Hierarchy

System.Object
   System.Attribute
      System.Runtime.Remoting.Proxies.ProxyAttribute
         Miner.Threading.MarshalToMainSTAAttribute

Requirements

Target Platforms: Windows XP SP3 (32-bit and 64-bit), Windows 7 (32-bit and 64-bit)

Not all Operating Systems are supported on all products. Visit the ArcFM Solution Supported Versions page for full details.

See Also

Reference

MarshalToMainSTAAttribute Members
Miner.Threading Namespace

 

 


Send Comment