Partilhar via


COM.newmethod Method

Definition

Overloads

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)

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.

protected:
 override void newmethod();
protected override void newmethod ();
override this.newmethod : unit -> unit
Protected Overrides Sub newmethod ()

Remarks

The class name of a COM object is either its programmatic identifier (ProgID) or its class identifier (CLSID):

  • ProgIDs have the following format: program.component.version
  • CLSIDs are 128-bit values and have the following format: {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}

If an attacker can control input to the new method, a security risk exists. Therefore, this method runs under Code Access Security. Calls to this method on the server require permission from the InteropPermission class. Make sure that the user has development privileges by setting the security key to SysDevelopment on the control that calls this method.

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

void COMExample() 
{ 
    COM               com; 
    str               result; 
    InteropPermission perm; 
    // Set the 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 the code access permission scope. 
    CodeAccessPermission::revertAssert(); 
}

Applies to

newmethod(String)

public:
 void newmethod(System::String ^ text1);
public void newmethod (string text1);
override this.newmethod : string -> unit
Public Sub newmethod (text1 As String)

Parameters

text1
String

Applies to

newmethod(String, String)

public:
 void newmethod(System::String ^ _className, System::String ^ _computerName);
public void newmethod (string _className, string _computerName);
override this.newmethod : string * string -> unit
Public Sub newmethod (_className As String, _computerName As String)

Parameters

_className
String

The name of the remote computer on which to instantiate the COM object; optional. If this parameter is omitted, the COM object is instantiated on the local computer. If the computer name is specified, the DCOM system component must be installed on both the local computer and the remote computer. The specific COM object must support DCOM, and it must be correctly configured on both the local computer and the remote computer. The system component is a standard component of Microsoft Windows 98, Windows NT, and later versions. In Windows 95, the DCOM system component must be installed.

_computerName
String

The name of the remote computer on which to instantiate the COM object; optional. If this parameter is omitted, the COM object is instantiated on the local computer. If the computer name is specified, the DCOM system component must be installed on both the local computer and the remote computer. The specific COM object must support DCOM, and it must be correctly configured on both the local computer and the remote computer. The system component is a standard component of Microsoft Windows 98, Windows NT, and later versions. In Windows 95, the DCOM system component must be installed.

Applies to