Type.GetTypeFromProgID Metod

Definition

Hämtar den typ som är associerad med den angivna programidentifieraren (ProgID).

Överlagringar

Name Description
GetTypeFromProgID(String)

Hämtar den typ som är associerad med den angivna programidentifieraren (ProgID) och returnerar null om ett fel påträffas vid inläsning av Type.

GetTypeFromProgID(String, Boolean)

Hämtar den typ som är associerad med den angivna programidentifieraren (ProgID) och anger om ett undantag ska utlösas om ett fel inträffar när typen läses in.

GetTypeFromProgID(String, String)

Hämtar den typ som är associerad med den angivna programidentifieraren (progID) från den angivna servern och returnerar null om ett fel uppstår när typen läses in.

GetTypeFromProgID(String, String, Boolean)

Hämtar den typ som är associerad med den angivna programidentifieraren (progID) från den angivna servern och anger om ett undantag ska utlösas om ett fel inträffar när typen läses in.

GetTypeFromProgID(String)

Källa:
Type.cs
Källa:
Type.cs
Källa:
Type.cs
Källa:
Type.cs
Källa:
Type.cs

Hämtar den typ som är associerad med den angivna programidentifieraren (ProgID) och returnerar null om ett fel påträffas vid inläsning av Type.

public:
 static Type ^ GetTypeFromProgID(System::String ^ progID);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static Type? GetTypeFromProgID(string progID);
public static Type? GetTypeFromProgID(string progID);
[System.Security.SecurityCritical]
public static Type GetTypeFromProgID(string progID);
public static Type GetTypeFromProgID(string progID);
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member GetTypeFromProgID : string -> Type
static member GetTypeFromProgID : string -> Type
[<System.Security.SecurityCritical>]
static member GetTypeFromProgID : string -> Type
Public Shared Function GetTypeFromProgID (progID As String) As Type

Parametrar

progID
String

ProgID av den typ som ska hämtas.

Returer

Den typ som är associerad med angivet ProgID, om progID är en giltig post i registret och en typ är associerad med den, nullannars .

Attribut

Undantag

progID är null.

Kommentarer

Den här metoden tillhandahålls för COM-stöd. ProgID:er används inte i Microsoft .NET Framework eftersom de har ersatts av begreppet namnområde.

Se även

Gäller för

GetTypeFromProgID(String, Boolean)

Källa:
Type.cs
Källa:
Type.cs
Källa:
Type.cs
Källa:
Type.cs
Källa:
Type.cs

Hämtar den typ som är associerad med den angivna programidentifieraren (ProgID) och anger om ett undantag ska utlösas om ett fel inträffar när typen läses in.

public:
 static Type ^ GetTypeFromProgID(System::String ^ progID, bool throwOnError);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static Type? GetTypeFromProgID(string progID, bool throwOnError);
public static Type? GetTypeFromProgID(string progID, bool throwOnError);
[System.Security.SecurityCritical]
public static Type GetTypeFromProgID(string progID, bool throwOnError);
public static Type GetTypeFromProgID(string progID, bool throwOnError);
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member GetTypeFromProgID : string * bool -> Type
static member GetTypeFromProgID : string * bool -> Type
[<System.Security.SecurityCritical>]
static member GetTypeFromProgID : string * bool -> Type
Public Shared Function GetTypeFromProgID (progID As String, throwOnError As Boolean) As Type

Parametrar

progID
String

ProgID av den typ som ska hämtas.

throwOnError
Boolean

true för att utlösa eventuella undantag som inträffar.

-eller-

false för att ignorera eventuella undantag som inträffar.

Returer

Den typ som är associerad med den angivna programidentifieraren (ProgID), om progID är en giltig post i registret och en typ är associerad med den, nullannars .

Attribut

Undantag

progID är null.

Angivet ProgID är inte registrerat.

Exempel

I följande exempel hämtas en typ genom att ett ProgID skickas, vilket anger om ett undantag ska utlösas om ProgID är ogiltigt. Exemplet visar sedan ClassID som är relaterat till ProgID, tillsammans med eventuella tillämpliga undantagsmeddelanden.

using System;
class MainApp
{
    public static void Main()
    {
        try
        {
            // Use the ProgID HKEY_CLASSES_ROOT\DirControl.DirList.1.
            string myString1 ="DIRECT.ddPalette.3";
            // Use a nonexistent ProgID WrongProgID.
            string myString2 ="WrongProgID";
            // Make a call to the method to get the type information of the given ProgID.
            Type myType1 =Type.GetTypeFromProgID(myString1,true);
            Console.WriteLine("GUID for ProgID DirControl.DirList.1 is {0}.", myType1.GUID);
            // Throw an exception because the ProgID is invalid and the throwOnError
            // parameter is set to True.
            Type myType2 =Type.GetTypeFromProgID(myString2,true);
        }
        catch(Exception e)
        {
            Console.WriteLine("An exception occurred.");
            Console.WriteLine("Source: {0}", e.Source);
            Console.WriteLine("Message: {0}", e.Message);
        }
    }
}
open System

try
    // Use the ProgID HKEY_CLASSES_ROOT\DirControl.DirList.1.
    let myString1 ="DIRECT.ddPalette.3"
    // Use a nonexistent ProgID WrongProgID.
    let myString2 ="WrongProgID"
    // Make a call to the method to get the type information of the given ProgID.
    let myType1 =Type.GetTypeFromProgID(myString1, true)
    printfn $"GUID for ProgID DirControl.DirList.1 is {myType1.GUID}."
    // Throw an exception because the ProgID is invalid and the throwOnError
    // parameter is set to True.
    let myType2 =Type.GetTypeFromProgID(myString2, true)
    ()
with e ->
    printfn "An exception occurred."
    printfn $"Source: {e.Source}"
    printfn $"Message: {e.Message}"
Class MainApp
    Public Shared Sub Main()
        Try
            ' Use the ProgID HKEY_CLASSES_ROOT\DirControl.DirList.1.
            Dim myString1 As String = "DIRECT.ddPalette.3"
            ' Use a nonexistent ProgID WrongProgID.
            Dim myString2 As String = "WrongProgID"
            ' Make a call to the method to get the type information of the given ProgID.
            Dim myType1 As Type = Type.GetTypeFromProgID(myString1, True)
            Console.WriteLine("GUID for ProgID DirControl.DirList.1 is {0}.", myType1.GUID.ToString())
            ' Throw an exception because the ProgID is invalid and the throwOnError 
            ' parameter is set to True.
            Dim myType2 As Type = Type.GetTypeFromProgID(myString2, True)
        Catch e As Exception
            Console.WriteLine("An exception occurred.")
            Console.WriteLine("Source: {0}", e.Source.ToString())
            Console.WriteLine("Message: {0}", e.Message.ToString())
        End Try
    End Sub
End Class

Kommentarer

Den här metoden tillhandahålls för COM-stöd. Program-ID:er används inte i Microsoft .NET Framework eftersom de har ersatts av begreppet namnområde.

Se även

Gäller för

GetTypeFromProgID(String, String)

Källa:
Type.cs
Källa:
Type.cs
Källa:
Type.cs
Källa:
Type.cs
Källa:
Type.cs

Hämtar den typ som är associerad med den angivna programidentifieraren (progID) från den angivna servern och returnerar null om ett fel uppstår när typen läses in.

public:
 static Type ^ GetTypeFromProgID(System::String ^ progID, System::String ^ server);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static Type? GetTypeFromProgID(string progID, string? server);
public static Type? GetTypeFromProgID(string progID, string? server);
[System.Security.SecurityCritical]
public static Type GetTypeFromProgID(string progID, string server);
public static Type GetTypeFromProgID(string progID, string server);
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member GetTypeFromProgID : string * string -> Type
static member GetTypeFromProgID : string * string -> Type
[<System.Security.SecurityCritical>]
static member GetTypeFromProgID : string * string -> Type
Public Shared Function GetTypeFromProgID (progID As String, server As String) As Type

Parametrar

progID
String

ProgID för den typ som ska hämtas.

server
String

Servern som typen ska läsas in från. Om servernamnet är nullåtergår den här metoden automatiskt till den lokala datorn.

Returer

Den typ som är associerad med den angivna programidentifieraren (progID), om progID är en giltig post i registret och en typ är associerad med den, annars . null

Attribut

Undantag

progID är null.

Exempel

I följande exempel hämtas en typ genom att ett ProgID- och servernamn skickas. Exemplet visar sedan ClassID som är relaterat till ProgID eller genererar ett undantag om ProgID eller servernamnet är ogiltigt.

using System;
class MainApp
{
    public static void Main()
    {
        try
        {
            // Use the ProgID localhost\HKEY_CLASSES_ROOT\DirControl.DirList.1.
            string theProgramID ="DirControl.DirList.1";
            // Use the server name localhost.
            string theServer="localhost";
            // Make a call to the method to get the type information for the given ProgID.
            Type myType =Type.GetTypeFromProgID(theProgramID,theServer);
            if(myType==null)
            {
                throw new Exception("Invalid ProgID or Server.");
            }
            Console.WriteLine("GUID for ProgID DirControl.DirList.1 is {0}.", myType.GUID);
        }
        catch(Exception e)
        {
            Console.WriteLine("An exception occurred.");
            Console.WriteLine("Source: {0}" , e.Source);
            Console.WriteLine("Message: {0}" , e.Message);
        }		
    }
}
open System

try
    // Use the ProgID localhost\HKEY_CLASSES_ROOT\DirControl.DirList.1.
    let theProgramID ="DirControl.DirList.1"
    // Use the server name localhost.
    let theServer="localhost"
    // Make a call to the method to get the type information for the given ProgID.
    let myType =Type.GetTypeFromProgID(theProgramID, theServer)
    if myType = null then
        raise (Exception "Invalid ProgID or Server.")
    printfn $"GUID for ProgID DirControl.DirList.1 is {myType.GUID}."
with e ->
    printfn "An exception occurred."
    printfn $"Source: {e.Source}"
    printfn $"Message: {e.Message}"
Class MainApp
    Public Shared Sub Main()
        Try
            ' Use ProgID localhost\HKEY_CLASSES_ROOT\DirControl.DirList.1.
            Dim theProgramID As String = "DirControl.DirList.1"
            ' Use Server name localhost.
            Dim theServer As String = "localhost"
            ' Make a call to the method to get the type information for the given ProgID.
            Dim myType As Type = Type.GetTypeFromProgID(theProgramID, theServer)
            If myType Is Nothing Then
                Throw New Exception("Invalid ProgID or server.")
            End If
            Console.WriteLine("GUID for ProgID DirControl.DirList.1 is {0}.", myType.GUID.ToString())
        Catch e As Exception
            Console.WriteLine("An exception occurred.")
            Console.WriteLine("Source: {0}.", e.Source.ToString())
            Console.WriteLine("Message: {0}.", e.Message.ToString())
        End Try
    End Sub
End Class

Kommentarer

Den här metoden tillhandahålls för COM-stöd. Program-ID:er används inte i Microsoft .NET Framework eftersom de har ersatts av begreppet namnområde.

Se även

Gäller för

GetTypeFromProgID(String, String, Boolean)

Källa:
Type.cs
Källa:
Type.cs
Källa:
Type.cs
Källa:
Type.cs
Källa:
Type.cs

Hämtar den typ som är associerad med den angivna programidentifieraren (progID) från den angivna servern och anger om ett undantag ska utlösas om ett fel inträffar när typen läses in.

public:
 static Type ^ GetTypeFromProgID(System::String ^ progID, System::String ^ server, bool throwOnError);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static Type? GetTypeFromProgID(string progID, string? server, bool throwOnError);
public static Type? GetTypeFromProgID(string progID, string? server, bool throwOnError);
[System.Security.SecurityCritical]
public static Type GetTypeFromProgID(string progID, string server, bool throwOnError);
public static Type GetTypeFromProgID(string progID, string server, bool throwOnError);
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member GetTypeFromProgID : string * string * bool -> Type
static member GetTypeFromProgID : string * string * bool -> Type
[<System.Security.SecurityCritical>]
static member GetTypeFromProgID : string * string * bool -> Type
Public Shared Function GetTypeFromProgID (progID As String, server As String, throwOnError As Boolean) As Type

Parametrar

progID
String

ProgID för Type att få.

server
String

Servern som typen ska läsas in från. Om servernamnet är nullåtergår den här metoden automatiskt till den lokala datorn.

throwOnError
Boolean

true för att utlösa eventuella undantag som inträffar.

-eller-

false för att ignorera eventuella undantag som inträffar.

Returer

Den typ som är associerad med den angivna programidentifieraren (progID), om progID är en giltig post i registret och en typ är associerad med den, annars . null

Attribut

Undantag

progID är null.

Angivet progID är inte registrerat.

Exempel

I följande exempel hämtas en typ genom att ett ProgID- och servernamn skickas. Exemplet visar sedan ClassID som är relaterat till ProgID och anger om ett undantag ska utlösas om ProgID eller servernamnet är ogiltigt.


using System;
class MainApp
{
    public static void Main()
    {
        try
        {
            // Use server localhost.
            string theServer="localhost";
            // Use  ProgID HKEY_CLASSES_ROOT\DirControl.DirList.1.
            string myString1 ="DirControl.DirList.1";
            // Use a wrong ProgID WrongProgID.
            string myString2 ="WrongProgID";
            // Make a call to the method to get the type information for the given ProgID.
            Type myType1 =Type.GetTypeFromProgID(myString1,theServer,true);
            Console.WriteLine("GUID for ProgID DirControl.DirList.1 is {0}.", myType1.GUID);
            // Throw an exception because the ProgID is invalid and the throwOnError
            // parameter is set to True.
            Type myType2 =Type.GetTypeFromProgID(myString2, theServer, true);
        }
        catch(Exception e)
        {
            Console.WriteLine("An exception occurred. The ProgID is wrong.");
            Console.WriteLine("Source: {0}" , e.Source);
            Console.WriteLine("Message: {0}" , e.Message);
        }
    }
}
open System
try
    // Use server localhost.
    let theServer="localhost"
    // Use  ProgID HKEY_CLASSES_ROOT\DirControl.DirList.1.
    let myString1 ="DirControl.DirList.1"
    // Use a wrong ProgID WrongProgID.
    let myString2 ="WrongProgID"
    // Make a call to the method to get the type information for the given ProgID.
    let myType1 =Type.GetTypeFromProgID(myString1, theServer, true)
    printfn $"GUID for ProgID DirControl.DirList.1 is {myType1.GUID}."
    // Throw an exception because the ProgID is invalid and the throwOnError
    // parameter is set to True.
    let myType2 =Type.GetTypeFromProgID(myString2, theServer, true)
    ()
with e ->
    printfn "An exception occurred. The ProgID is wrong."
    printfn $"Source: {e.Source}"
    printfn $"Message: {e.Message}"
Class MainApp
    Public Shared Sub Main()
        Try
            ' Use Server localhost.
            Dim theServer As String = "localhost"
            ' Use  ProgID HKEY_CLASSES_ROOT\DirControl.DirList.1.
            Dim myString1 As String = "DirControl.DirList.1"
            ' Use a wrong ProgID WrongProgID.
            Dim myString2 As String = "WrongProgID"
            ' Make a call to the method to get the type information for the given ProgID.
            Dim myType1 As Type = Type.GetTypeFromProgID(myString1, theServer, True)
            Console.WriteLine("GUID for ProgID DirControl.DirList.1 is {0}.", myType1.GUID.ToString())
            ' Throw an exception because the ProgID is invalid and the throwOnError 
            ' parameter is set to True.
            Dim myType2 As Type = Type.GetTypeFromProgID(myString2, theServer, True)
        Catch e As Exception
            Console.WriteLine("An exception occurred. The ProgID is wrong.")
            Console.WriteLine("Source: {0}", e.Source.ToString())
            Console.WriteLine("Message: {0}", e.Message.ToString())
        End Try
    End Sub
End Class

Kommentarer

Den här metoden tillhandahålls för COM-stöd. Program-ID:er används inte i Microsoft .NET Framework eftersom de har ersatts av begreppet namnområde.

Se även

Gäller för