Partager via


IVsDataProvider.TryCreateObject<TObject, TSite> Method (Guid, TSite)

Tries to create an instance of the specified DDEX support entity for the specified DDEX data source that is implemented by the DDEX provider, sited with the specified site object.

Namespace:  Microsoft.VisualStudio.Data.Core
Assembly:  Microsoft.VisualStudio.Data.Core (in Microsoft.VisualStudio.Data.Core.dll)

Syntax

'Declaration
Function TryCreateObject(Of TObject, TSite) ( _
    source As Guid, _
    site As TSite _
) As TObject
TObject TryCreateObject<TObject, TSite>(
    Guid source,
    TSite site
)
generic<typename TObject, typename TSite>
TObject TryCreateObject(
    Guid source, 
    TSite site
)
abstract TryCreateObject : 
        source:Guid * 
        site:'TSite -> 'TObject 
JScript does not support generic types or methods.

Type Parameters

  • TObject
    The object.
  • TSite
    The site.

Parameters

  • source
    Type: System.Guid

    A DDEX data source identifier, or Empty for no specific data source.

  • site
    Type: TSite

    An instance of an object that should site the new DDEX support entity.

Return Value

Type: TObject
An instance of the specified DDEX support entity for the specified DDEX data source that is implemented by the DDEX provider, sited with the specified site object, if the DDEX provider supports it. Otherwise, the default instance of type TObject.

Exceptions

Exception Condition
DataProviderException

Instantiation of a new instance of the support entity threw an exception, whether by way of a CreateInstance call through reflection or through the DDEX provider’s CreateObject or CreateObject method implementation, or creation of the default or client object implementation (if there is one) failed.

Remarks

This method delegates to the TryCreateObject method, passing typeof(TObject) as the objType parameter value. It then identifies whether the resulting instance is of type TObject and, if it is, casts it and returns. If not, it returns the default instance of type TObject.

.NET Framework Security

See Also

Reference

IVsDataProvider Interface

TryCreateObject Overload

Microsoft.VisualStudio.Data.Core Namespace