Share via


IVsDataProviderObjectFactory.GetAssembly Method

Resolves a provider-specific assembly string to its corresponding Assembly representation.

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

Syntax

'Declaration
Function GetAssembly ( _
    assemblyString As String _
) As Assembly
Assembly GetAssembly(
    string assemblyString
)
Assembly^ GetAssembly(
    String^ assemblyString
)
abstract GetAssembly : 
        assemblyString:string -> Assembly
function GetAssembly(
    assemblyString : String
) : Assembly

Parameters

  • assemblyString
    Type: System.String

    A provider-specific assembly string.

Return Value

Type: System.Reflection.Assembly
An Assembly object representing the assembly resolved from the specified assembly string, if found; otherwise, nulla null reference (Nothing in Visual Basic).

Exceptions

Exception Condition
ArgumentNullException

The assemblyString parameter is nulla null reference (Nothing in Visual Basic).

Remarks

A provider implements this method when there are assembly names specified as strings in formats such as a data support XML file, and these assembly names cannot be automatically resolved (or would be resolved incorrectly) by the CLR’s Load method. One use of this method would be to expand an incomplete assembly declaration. (For example, if the string is "MyAssembly", it might get expanded to "MyAssembly, Version=2.0.0.0, Culture=neutral, PublicKeyToken=1234567890ABCDEF" before the CLR resolves it.)

This method is provided to shorten a provider’s specification of type names, which can help reduce duplication of a commonly used assembly throughout the code base.

Examples

The following code demonstrates how to implement this method to return the assembly in which the provider object factory is contained if the assembly string is empty. The example inherits from the framework DataProviderObjectFactory class, which provides a default implementation of the GetType and GetAssembly methods.

using System;
using System.Reflection;
using Microsoft.VisualStudio.Data.Core;
using Microsoft.VisualStudio.Data.Framework;

public class MyProviderObjectFactory2 : DataProviderObjectFactory
{
    public override object CreateObject(Type objType)
    {
        return null;
    }

    public override Assembly GetAssembly(string assemblyString)
    {
        if (assemblyString == null)
        {
            throw new ArgumentNullException("assemblyString");
        }
        if (assemblyString.Length == 0)
        {
            return GetType().Assembly;
        }
        return base.GetAssembly(assemblyString);
    }
}

.NET Framework Security

See Also

Reference

IVsDataProviderObjectFactory Interface

Microsoft.VisualStudio.Data.Core Namespace