COM Class

Definition

The COM class is used to create Component Object Model (COM) objects.

public ref class COM : Microsoft::Dynamics::Ax::Xpp::XppObjectBase
[Microsoft.Dynamics.Ax.Xpp.KernelClass]
[Microsoft.Dynamics.BusinessPlatform.SharedTypes.InternalUseOnly]
public class COM : Microsoft.Dynamics.Ax.Xpp.XppObjectBase
[<Microsoft.Dynamics.Ax.Xpp.KernelClass>]
[<Microsoft.Dynamics.BusinessPlatform.SharedTypes.InternalUseOnly>]
type COM = class
    inherit XppObjectBase
Public Class COM
Inherits XppObjectBase
Inheritance
Microsoft.Dynamics.AX.KernelInterop.ProxyBase
COM
Attributes
KernelClassAttribute Microsoft.Dynamics.BusinessPlatform.SharedTypes.InternalUseOnlyAttribute

Remarks

The COM class also supports Distributed Component Object Model (DCOM). DCOM enables objects that support DCOM to run on remote computers. When a COM object has been instantiated by using the COM class, its methods and properties can be accessed by using either the COMDispFunction class or the extended syntax for the COM class. The extended syntax enables methods and properties to be directly called on the COM object, even though they don't appear in the Lookup list (for example, com.comMethod("Hello World");). The extended syntax supports calls to methods and properties that take any number of arguments. Some COM objects support the concept of optional arguments. Only optional variant arguments can be omitted. If optional arguments are omitted, the COM object uses its default values. To omit an argument for the COM object and force it to use its default value, specify the COMArgument::NoValue enumeration, as shown in the following example.

com.comMethod(COMArgument::NoValue, "Hello Another World");

If the arguments to omit from the COM object appear at the end of the argument list, omit them from the code. The following types are supported for the extended syntax for the COM class argument type and return type:

  • array
  • COM
  • COMVariant
  • date
  • enum
  • int
  • real
  • str

If a COM object returns a date, and if the extended syntax is used, the return value of the COM method should be assigned to a COMVariant class variable. The actual date and time (format) can then be extracted from the COMVariant class by using the date and time properties. If the date return value is assigned to a date variable instead of a COMVariant class, the time component of the date is lost. When the extended syntax is used, you can still call the COM class methods (the methods that appear in the Lookup list) on the objects. The COM class methods have a higher priority than the methods on the actual COM object. If a method on the COM object has the same name as a method on the COM class (for example, attach), you cannot call that method on the COM object. To enable Finance and Operations to call the method on the COM object instead of the method that has the same name on the COM class, prefix the duplicate method name with an underscore (for example, com._detach();). The extended syntax for the COM class is evaluated at run time, not compile time, which causes a slight decrease in performance. If high-performance code is required, consider using the COMDispFunction class. This class offers performance improvements over the extended syntax for the COM class.

This example calls the GetFileName method from the Scripting.FileSystemObject COM object.

void COMExample() 
{ 
    COM               com; 
    str               result; 
    InteropPermission perm; 
    ; 
    // Set code access permission to help protect the use of the 
    // COM object. 
    perm = new InteropPermission(InteropKind::ComInterop); 
    if (perm == null) 
    { 
        return; 
    } 
    // Permission scope starts here. 
    perm.assert(); 
    com = new COM("Scripting.FileSystemObject"); 
    if (com != null) 
    { 
        result = com.GetFileName(@"c:\boot.ini"); 
    } 
    // Close code access permission scope. 
    CodeAccessPermission::revertAssert(); 
}

Constructors

COM()
COM(IntPtr)
COM(String)
COM(String, String)

Fields

__k_COMId
kernelClass (Inherited from XppObjectBase)

Methods

__shouldCallNew(Type)
addXppProxyReference(Type, Object) (Inherited from XppObjectBase)
attach(Int64)

Attaches an instance of the COM class to a COM interface.

Call(String, Object[], Type[], Object[]) (Inherited from XppObjectBase)
cancelTimeOut(Int32) (Inherited from XppObjectBase)
createFromInterface(Int64)

Creates an instance of the COM class by using the specified COM interface.

createFromObject(COM)

Creates an instance of the COM class by using the specified COM object.

createFromVariant(COMVariant)

Creates an instance of the COM class by using the specified instance of the COMVariant class.

createKernelClass(Object[], Type[], Object[]) (Inherited from XppObjectBase)
detach()

Detaches a COM object from the class that it was associated with.

dispatch(Object[])

Reserved. Do not explicitly call this method.

documentationName()

Returns the textual name of the COM object that is associated with the instance of the COM class.

equal(XppObjectBase) (Inherited from XppObjectBase)
error()

Returns a COMError object that is associated with the instance of the COM class.

finalize()

Frees resources that are associated with the instance of the COM class.

GetIntPtr() (Inherited from XppObjectBase)
GetKernelInstanceUniqueId() (Inherited from XppObjectBase)
getObject(String)

Returns an instance of a COM object that is running.

getObjectEx(String)

Returns an instance of a COM object that is specified by its file name.

getTimeOutTimerHandle() (Inherited from XppObjectBase)
getXppProxyReference(Type) (Inherited from XppObjectBase)
handle()
interface()

Returns the interface that is associated with the COM object.

IsManagedValid() (Inherited from XppObjectBase)
kernelhandle()
KernelInstanceDisposed() (Inherited from XppObjectBase)
lcid()
lcid(Int32)
MakeReflectionCall(String, Object[]) (Inherited from XppObjectBase)
newmethod()

Creates an instance of the COM class that can be attached to the COM class and optionally instantiates a COM object on a specified computer.

newmethod(String)
newmethod(String, String)
notify() (Inherited from XppObjectBase)
notifyAll() (Inherited from XppObjectBase)
objectOnServer()
Obsolete.
(Inherited from XppObjectBase)
setTimeOut(String, Int32)
Obsolete.
(Inherited from XppObjectBase)
setTimeOut(String, Int32, Boolean)
Obsolete.
(Inherited from XppObjectBase)
ToString()

Returns a string that represents the instance of the COM class.

unsupported(Int32)

Reserved.

unsupported(Int32, Object)
unsupported(Int32, Object, Object)
unsupported(Int32, Object, Object, Object)
usageCount() (Inherited from XppObjectBase)
VerifyKernelClass() (Inherited from XppObjectBase)
wait() (Inherited from XppObjectBase)
Xml() (Inherited from XppObjectBase)
Xml(Int32) (Inherited from XppObjectBase)

Applies to