다음을 통해 공유


Activating a COM Object

The technique you use to reference the metadata DLL depends on your programming environment and your preferences. The syntax for activating a COM object is language-dependent. For syntax and usage references, see your language documentation.

Assuming that you have an assembly containing the Loan class and its members, you can perform early-bound activation with little effort. The following code example activates an instance of the LOANLib.Loan coclass from managed code:

Imports System
Imports LoanLib

Public Class LoanApp
    Public Shared Sub Main()
       ...
       Dim ln As New Loan()
       ...
    End Sub
End Class
[C#]
using System;
using LoanLib;

public class LoanApp {
    public static void Main(String[] Args) {
        Loan ln = new Loan();
        ...
    }
}

When a .NET client creates and instance of the Loan coclass, the runtime must locate its metadata, regardless of whether the class is a .NET class or a COM coclass. Metadata must be available at run time in order to early bind to a class. Metadada is not required for late-bound activation.

See Also

Using COM Types in Managed Code | Importing a Type Library as an Assembly | COM Interop Sample: .NET Client and COM Server