This documentation is archived and is not being maintained.

ImportedFromTypeLibAttribute Class

Indicates that the types defined within an assembly were originally defined in a type library.

Namespace:  System.Runtime.InteropServices
Assembly:  mscorlib (in mscorlib.dll)

'Declaration
<AttributeUsageAttribute(AttributeTargets.Assembly, Inherited := False)> _
<ComVisibleAttribute(True)> _
Public NotInheritable Class ImportedFromTypeLibAttribute _
	Inherits Attribute
'Usage
Dim instance As ImportedFromTypeLibAttribute

You can apply this attribute to assemblies, although the Type Library Importer (Tlbimp.exe) typically applies it for you when it a type library.

The primary use of the attribute is to capture the original source of the type information. For example, you can import A.tlb as an interop assembly called A.dll and have assembly B.dll reference A.dll. When you export B.dll to B.tlb, this attribute causes the references in B.tlb that point to A.dll to point instead to A.tlb. This should not be confused with the ComImportAttribute, which specifies that an individual type is implemented in COM.

Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices

Module A
	Public Function IsCOMAssembly(ByVal a As System.Reflection.Assembly) As Boolean 

		Dim AsmAttributes As Object() = a.GetCustomAttributes(GetType(ImportedFromTypeLibAttribute), True)
		If AsmAttributes.Length = 1 Then 
			Dim imptlb As ImportedFromTypeLibAttribute = AsmAttributes(0)
			Dim strImportedFrom As String = imptlb.Value

			' Print out the the name of the DLL from which the assembly is imported.
			Console.WriteLine("Assembly " + a.FullName + " is imported from " + strImportedFrom)

			Return True 
		End If 

		' This is not a COM assembly.
		Console.WriteLine("Assembly " + a.FullName + " is not imported from COM")

		Return False 
	End Function 
End Module

System.Object
  System.Attribute
    System.Runtime.InteropServices.ImportedFromTypeLibAttribute

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0
Show: