Skip to main content

SalObject

Namespace: PPJ.Runtime.Com

Assembly: PPJ.Runtime.50 (5.0.0.0)

Wraps an automation object and manages its interfaces, enumeration, and COM error state.

public class SalObject : SalFunctionalClass, IDisposable

Assigning Value attaches the object and detaches the previous value. Dispose the wrapper when its attached object is no longer needed.

Example:

using PPJ.Runtime.Com;

using (var automation = new SalObject())
{
if (automation.CreateObject("Scripting.Dictionary"))
System.Console.WriteLine(automation.IsDispatchValid());
}

Constructors

Instance member SalObject()

Initializes a wrapper without an attached object.

Instance member SalObject(obj)

Initializes a wrapper and attaches the supplied object.

NameTypeDescription
objObjectThe wrapper or automation object involved in the attachment.

Properties

Static member AutoErrorMode

Boolean: Gets or sets whether HandleException propagates automation exceptions instead of recording them.

Instance member AutoRelease

Boolean: Gets or sets whether detaching also releases the attached COM object automatically.

Instance member Value

Object: Gets or sets the attached automation object, updating reflected interface fields and enabling automatic release.

Methods

Instance member Attach(obj)

Assigns this wrapper's object to another wrapper.

ParameterTypeDescription
objSalObjectThe destination wrapper that receives this Value.

Returns: Boolean. True if assignment succeeds; false for a null destination or a handled COM error.

The destination argument receives this Value; this wrapper remains attached.

Protected member AttachInterface(com)

Assigns an automation object to the wrapper's reflected interface fields.

ParameterTypeDescription
comObjectThe object assigned to the reflected interface fields.

An incompatible field type is reported as InvalidCastException.

Instance member Count()

Reads the attached collection's public Count property through reflection.

Returns: SalNumber. The element count, or zero if no enumerator or property value is available.

Instance member CreateObject()

Creates and attaches an instance of the COM class declared by the wrapper's _CoClass field.

Returns: Boolean. True if creation and attachment succeed; false if the field is absent or creation fails.

Instance member CreateObject(progid)

Creates and attaches the COM class identified by a ProgID or CLSID.

ParameterTypeDescription
progidStringThe registered programmatic identifier or CLSID string.

Returns: Boolean. True if creation and attachment succeed; otherwise, false.

Instance member CreateObjectEx(host)

Creates the wrapper's declared COM class on the specified host.

ParameterTypeDescription
hostStringThe host on which to activate the COM class.

Returns: Boolean. True if the _CoClass field exists and creation succeeds; otherwise, false.

Instance member CreateObjectEx(progid, host)

Creates the specified COM class on a host and assigns the wrapper's _CoClass field.

ParameterTypeDescription
progidStringThe registered programmatic identifier or CLSID string.
hostStringThe host on which to activate the COM class.

Returns: Boolean. True if the _CoClass field exists and creation succeeds; otherwise, false.

Instance member Detach()

Releases tracked interfaces and detaches the current object.

Returns: Boolean. True after detachment completes.

Clears the attached object and cached enumerator even if release fails.

Instance member Dispose()

Detaches this wrapper once and releases its tracked COM references.

Protected member Finalize()

Destructor.

Instance member GetInterface(iface, iid)

Queries the attached object for an interface and assigns it to another wrapper.

ParameterTypeDescription
ifaceSalObjectThe destination wrapper that receives the queried interface.
iidStringThe requested interface GUID, or an empty value to assign the current object.

Returns: Boolean. True if the interface is assigned; otherwise, false.

An empty interface identifier assigns the current object without querying a specific interface.

Instance member GetLastError(err)

Copies details of the most recently handled exception into an error record.

ParameterTypeDescription
errSalOleErrorInfoThe error record to populate.

Returns: SalBoolean. True if a stored exception is available; otherwise, false.

Only available exception fields are assigned; existing fields in the record are not cleared.

Instance member HandleException(e)

Traces an automation exception and either stores or rethrows it.

ParameterTypeDescription
eExceptionThe exception to record or propagate.

Returns: Boolean. False when automatic error propagation is disabled.

With AutoErrorMode enabled, a COMException is thrown directly; otherwise its InnerException is thrown. With automatic errors disabled, the original exception is stored for GetLastError.

Instance member IsCollection()

Determines whether an enumerator can be obtained for the attached object.

Returns: SalBoolean. True if an enumerator is available; otherwise, false.

Instance member IsDispatchValid()

Tests whether an object is currently attached.

Returns: Boolean. True if Value is non-null; otherwise, false.

This checks only for a non-null reference, not COM server availability.

Static member MTSDisableCommit()

Marks the current COM+ context as unable to commit its transaction.

Static member MTSEnableCommit()

Allows the current COM+ context to commit its transaction.

Static member MTSIsCallerInRole(role)

Tests the immediate caller's membership in a COM+ role.

ParameterTypeDescription
roleSalStringThe COM+ security role name.

Returns: SalBoolean. True if the caller belongs to the role; otherwise, false.

Static member MTSIsInTransaction()

Tests whether the current COM+ context participates in a transaction.

Returns: Boolean. True if the context participates in a transaction; otherwise, false.

Static member MTSIsSecurityEnabled()

Tests whether COM+ role-based security is enabled in the current context.

Returns: Boolean. True if security is enabled; otherwise, false.

Static member MTSSetAbort()

Votes to abort the current COM+ transaction and marks the object as complete.

Static member MTSSetComplete()

Votes to commit the current COM+ transaction and marks the object as complete.

Instance member Next(obj)

Advances the cached enumerator and attaches its current item to the supplied wrapper.

ParameterTypeDescription
objSalObjectThe destination wrapper for the next collection item.

Returns: SalBoolean. True if another item is available; otherwise, false.

Instance member Reset()

Resets the cached enumerator to its initial position.

Returns: SalBoolean. True after reset; false if enumeration is unavailable.

Instance member Skip(nElems)

Advances the cached enumerator by the requested number of elements.

ParameterTypeDescription
nElemsSalNumberThe number of enumeration steps to perform; nonpositive values perform no steps.

Returns: SalBoolean. True if all requested advances succeed; false if enumeration is unavailable or ends early.