Training
Module
Call methods from the .NET Class Library using C# - Training
Use functionality in the .NET Class Library by calling methods that return values, accept input parameters, and more.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Visual Studio generates an interop assembly containing metadata when you add a reference to a type library. If a primary interop assembly is available, Visual Studio uses the existing assembly before generating a new interop assembly.
Install the COM DLL or EXE file on your computer, unless a Windows Setup.exe file performs the installation for you.
Choose Project, Add Reference.
In the Reference Manager, choose COM.
Select the type library from the list, or browse for the .tlb file.
Choose OK.
In Solution Explorer, open the shortcut menu for the reference you just added, and then choose Properties.
In the Properties window, make sure that the Embed Interop Types property is set to True. This causes Visual Studio to embed type information for COM types in your executables, eliminating the need to deploy primary interop assemblies with your app.
Note
The menu and dialog box options may vary depending on the version of Visual Studio you're using.
Generate an interop assembly as described in How to: Generate Interop Assemblies from Type Libraries.
Use the -link (C# Compiler Options) or -link (Visual Basic) compiler option with the interop assembly name to embed type information for COM types in your executables.
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Training
Module
Call methods from the .NET Class Library using C# - Training
Use functionality in the .NET Class Library by calling methods that return values, accept input parameters, and more.