VsShellUtilities.TryGetPackageExtensionPoint<TExtensionPoint, TInterface> Method

Creates an instance of an extension point from the given package. This is analagous to finding an "Export" of a given type (T) with the instance metadata given by the "instance" Guid.

Namespace:  Microsoft.VisualStudio.Shell
Assembly:  Microsoft.VisualStudio.Shell.12.0 (in Microsoft.VisualStudio.Shell.12.0.dll)

Syntax

'Declaration
Public Shared Function TryGetPackageExtensionPoint(Of TExtensionPoint As Class, TInterface As Class) ( _
    package As Guid, _
    instance As Guid _
) As TInterface
public static TInterface TryGetPackageExtensionPoint<TExtensionPoint, TInterface>(
    Guid package,
    Guid instance
)
where TExtensionPoint : class 
where TInterface : class
public:
generic<typename TExtensionPoint, typename TInterface>
where TExtensionPoint : ref class 
where TInterface : ref class 
static TInterface TryGetPackageExtensionPoint(
    Guid package, 
    Guid instance
)
static member TryGetPackageExtensionPoint : 
        package:Guid * 
        instance:Guid -> 'TInterface  when 'TExtensionPoint : not struct when 'TInterface : not struct
JScript does not support generic types or methods.

Type Parameters

  • TExtensionPoint
    The type of extension point
  • TInterface
    The interface requested.

Parameters

  • package
    Type: Guid

    The package that contains the instance.

  • instance
    Type: Guid

    The instance identifier for the requested extension point.

Return Value

Type: TInterface
The extension point.

Exceptions

Exception Condition
ArgumentException

The extension point is not recognized by the package, or the package does not use attributes to declare any class that implements the extension.

InvalidCastException

The package does not implement the VsPackageExtensionProvider interface, or the extension provider was created but it does not implement the TInterface interface.

.NET Framework Security

See Also

Reference

VsShellUtilities Class

Microsoft.VisualStudio.Shell Namespace