EntryPointNotFoundException Sınıf

Tanım

Giriş yönteminin olmaması nedeniyle bir sınıf yükleme girişimi başarısız olduğunda oluşan özel durum.

public ref class EntryPointNotFoundException : TypeLoadException
public class EntryPointNotFoundException : TypeLoadException
[System.Serializable]
public class EntryPointNotFoundException : TypeLoadException
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public class EntryPointNotFoundException : TypeLoadException
type EntryPointNotFoundException = class
    inherit TypeLoadException
[<System.Serializable>]
type EntryPointNotFoundException = class
    inherit TypeLoadException
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type EntryPointNotFoundException = class
    inherit TypeLoadException
Public Class EntryPointNotFoundException
Inherits TypeLoadException
Devralma
EntryPointNotFoundException
Öznitelikler

Açıklamalar

EntryPointNotFoundException Ortak dil çalışma zamanı derlemenin giriş noktasını tanımlayamadığı için bir derleme yükleyemediğinde bir özel durum oluşur. Bu özel durum aşağıdaki koşullar altında oluşturulabilir:

  • Ortak dil çalışma zamanı yürütülebilir bir derlemede bir uygulama giriş noktasını (genellikle bir Main yöntem) bulamıyor. Uygulama giriş noktası, parametresi olmayan bir genel veya static yöntem veya tek parametresi olarak dize dizisi olmalıdır. Giriş noktası döndürebilir voidveya bir Int32 veya UInt32 çıkış kodu döndürebilir. Uygulama derlemesi birden fazla giriş noktası tanımlayamaz.

  • İşlev bulunamadığından, Windows DLL'deki bir işleve yapılan çağrı çözümlenemiyor. Aşağıdaki örnekte, User32.dll adlı EntryPointNotFoundExceptionbir GetMyNumber işlev içermediğinden bir özel durum oluşturulur.

    using System;
    using System.Runtime.InteropServices;
    
    public class Example
    {
       [DllImport("user32.dll")]
       public static extern int GetMyNumber();
    
       public static void Main()
       {
          try {
             int number = GetMyNumber();
          }
          catch (EntryPointNotFoundException e) {
             Console.WriteLine("{0}:\n   {1}", e.GetType().Name,
                               e.Message);
          }
       }
    }
    // The example displays the following output:
    //    EntryPointNotFoundException:
    //       Unable to find an entry point named 'GetMyNumber' in DLL 'User32.dll'.
    
    open System
    open System.Runtime.InteropServices
    
    [<DllImport "user32.dll">]
    extern int GetMyNumber()
    
    try
        let number = GetMyNumber()
        ()
    with :? EntryPointNotFoundException as e ->
        printfn $"{e.GetType().Name}:\n   {e.Message}"
    
    // The example displays the following output:
    //    EntryPointNotFoundException:
    //       Unable to find an entry point named 'GetMyNumber' in DLL 'User32.dll'.
    
    Module Example
        Declare Auto Function GetMyNumber Lib "User32.dll" () As Integer
    
       Public Sub Main()
          Try
             Dim number As Integer = GetMyNumber()
          Catch e As EntryPointNotFoundException
             Console.WriteLine("{0}:{2}   {1}", e.GetType().Name,  
                               e.Message, vbCrLf)
          End Try   
       End Sub
    End Module
    ' The example displays the following output:
    '    EntryPointNotFoundException:
    '       Unable to find an entry point named 'GetMyNumber' in DLL 'User32.dll'.
    
  • yöntem çağrısında kullanılan ad derlemede bulunan bir adla eşleşmediğinden, Windows DLL'deki bir işleve yapılan çağrı çözümlenemiyor. Bu durum genellikle alanın örtük olarak veya açıkça olarak DllImportAttribute.ExactSpellingolarak ayarlanmış olması nedeniyle true oluşur. Çağrılan yöntem bir veya daha fazla dize parametresi içerir ve hem ANSI hem de Unicode sürümüne sahiptir ve yöntem çağrısında kullanılan ad bu ANSI veya Unicode sürümünün adına karşılık gelmez. Aşağıdaki örnek, User32.dlliçinde Windows MessageBox işlevini çağırmaya çalışarak bir çizim sağlar. İlk yöntem tanımı dize hazırlamayı belirttiğindenCharSet.Unicode, ortak dil yöntemi çağrısında MessageBoxWkullanılan ad yerine işlevinin MessageBoxgeniş karakterli sürümünü arar. İkinci yöntem tanımı işlevi yerine öğesini MessageBoxW çağırarak bu sorunu düzeltmektedir MessageBox .

    using System;
    using System.Runtime.InteropServices;
    
    public class Example
    {
       [DllImport("user32.dll", CharSet = CharSet.Unicode, ExactSpelling = true )]
       public static extern int MessageBox(IntPtr hwnd, String text, String caption, uint type);
    
       [DllImport("user32.dll", CharSet = CharSet.Unicode, ExactSpelling = true )]
       public static extern int MessageBoxW(IntPtr hwnd, String text, String caption, uint type);
    
       public static void Main()
       {
          try {
             MessageBox(new IntPtr(0), "Calling the MessageBox Function", "Example", 0);
          }
          catch (EntryPointNotFoundException e) {
             Console.WriteLine("{0}:\n   {1}", e.GetType().Name,
                               e.Message);
          }
    
          try {
             MessageBoxW(new IntPtr(0), "Calling the MessageBox Function", "Example", 0);
          }
          catch (EntryPointNotFoundException e) {
             Console.WriteLine("{0}:\n   {1}", e.GetType().Name,
                               e.Message);
          }
       }
    }
    
    open System
    open System.Runtime.InteropServices
    
    [<DllImport("user32.dll", CharSet = CharSet.Unicode, ExactSpelling = true )>]
    extern int MessageBox(IntPtr hwnd, String text, String caption, uint ``type``)
    
    [<DllImport("user32.dll", CharSet = CharSet.Unicode, ExactSpelling = true )>]
    extern int MessageBoxW(IntPtr hwnd, String text, String caption, uint ``type``)
    
    try
        MessageBox(IntPtr 0, "Calling the MessageBox Function", "Example", 0u)
        |> ignore
    with :? EntryPointNotFoundException as e ->
        printfn $"{e.GetType().Name}:\n   {e.Message}"
    
    try
        MessageBoxW(IntPtr 0, "Calling the MessageBox Function", "Example", 0u)
        |> ignore
    with :? EntryPointNotFoundException as e ->
        printfn $"{e.GetType().Name}:\n   {e.Message}"
    
    Module Example
       Declare Unicode Function MessageBox Lib "User32.dll" Alias "MessageBox" (
          ByVal hWnd As IntPtr, ByVal txt As String, ByVal caption As String, 
          ByVal typ As UInteger) As Integer  
    
       Declare Unicode Function MessageBox2 Lib "User32.dll" Alias "MessageBoxW" (  
          ByVal hWnd As IntPtr, ByVal txt As String, ByVal caption As String, 
          ByVal typ As UInteger) As Integer  
          
       Public Sub Main()
          Try
             MessageBox(IntPtr.Zero, "Calling the MessageBox Function", "Example", 0 )
          Catch e As EntryPointNotFoundException
             Console.WriteLine("{0}:{2}   {1}", e.GetType().Name,  
                               e.Message, vbCrLf)
          End Try
    
          Try
             MessageBox2(IntPtr.Zero, "Calling the MessageBox Function", "Example", 0 )
          Catch e As EntryPointNotFoundException
             Console.WriteLine("{0}:{2}   {1}", e.GetType().Name,  
                               e.Message, vbCrLf)
          End Try
    
       End Sub
    End Module
    
  • Dinamik bağlantı kitaplığındaki bir işlevi süslü adı yerine basit adıyla çağırmaya çalışıyorsunuz. Genellikle, C++ derleyicisi DLL işlevleri için düzenlenmiş bir ad oluşturur. Örneğin, aşağıdaki C++ kodu TestDll.dlladlı Double kitaplıkta adlı bir işlevi tanımlar.

    __declspec(dllexport) int Double(int number)
    {
        return number * 2;
    }
    

    Aşağıdaki örnekteki kod işlevi çağırmaya çalıştığında, işlev bulunamadığından EntryPointNotFoundException bir Double özel durum oluşturulur.

    using System;
    using System.Runtime.InteropServices;
    
    public class Example
    {
       [DllImport("TestDll.dll")]
       public static extern int Double(int number);
    
       public static void Main()
       {
          Console.WriteLine(Double(10));
       }
    }
    // The example displays the following output:
    //    Unhandled Exception: System.EntryPointNotFoundException: Unable to find
    //    an entry point named 'Double' in DLL '.\TestDll.dll'.
    //       at Example.Double(Int32 number)
    //       at Example.Main()
    
    open System
    open System.Runtime.InteropServices
    
    [<DllImport "TestDll.dll">]
    extern int Double(int number)
    
    printfn $"{Double 10}"
    // The example displays the following output:
    //    Unhandled Exception: System.EntryPointNotFoundException: Unable to find
    //    an entry point named 'Double' in DLL '.\TestDll.dll'.
    //       at Example.Double(Int32 number)
    //       at Example.Main()
    
    Module Example
       Public Declare Function DoubleNum Lib ".\TestDll.dll" Alias "Double" _
                      (ByVal number As Integer) As Integer
       
       Public Sub Main()
          Console.WriteLine(DoubleNum(10))
       End Sub
    End Module
    ' The example displays the following output:
    '    Unhandled Exception: System.EntryPointNotFoundException: Unable to find an 
    '    entry point named 'Double' in DLL '.\TestDll.dll'.
    '       at Example.Double(Int32 number)
    '       at Example.Main()
    

    Ancak işlev, süslü adı (bu örnekte), kullanılarak çağrılırsa, ?Double@@YAHH@Zaşağıdaki örnekte gösterildiği gibi işlev çağrısı başarılı olur.

    using System;
    using System.Runtime.InteropServices;
    
    public class Example
    {
       [DllImport("TestDll.dll", EntryPoint = "?Double@@YAHH@Z")]
       public static extern int Double(int number);
    
       public static void Main()
       {
          Console.WriteLine(Double(10));
       }
    }
    // The example displays the following output:
    //    20
    
    open System
    open System.Runtime.InteropServices
    
    [<DllImport("TestDll.dll", EntryPoint = "?Double@@YAHH@Z")>]
    extern int Double(int number)
    
    printfn $"{Double 10}"
    // The example displays the following output:
    //    20
    
    Module Example
       Public Declare Function DoubleNum Lib ".\TestDll.dll" Alias "?Double@@YAHH@Z" _
                      (ByVal number As Integer) As Integer
       
       Public Sub Main()
          Console.WriteLine(DoubleNum(10))
       End Sub
    End Module
    ' The example displays the following output:
    '    20
    

    dll tarafından dışarı aktarılan işlevlerin süslü adlarını Dumpbin.exegibi bir yardımcı program kullanarak bulabilirsiniz.

  • Yönetilen bir derlemedeki bir yöntemi yönetilmeyen bir dinamik bağlantı kitaplığıymış gibi çağırmaya çalışıyorsunuz. Bunu uygulamada görmek için aşağıdaki örneği StringUtilities.dlladlı bir derlemeye derleyin.

    using System;
    
    public static class StringUtilities
    {
       public static String SayGoodMorning(String name)
       {
          return String.Format("A top of the morning to you, {0}!", name);
       }
    }
    
    module StringUtilities
    
    let SayGoodMorning name =
        $"A top of the morning to you, %s{name}!"
    
    Module StringUtilities
       Public Function SayGoodMorning(name As String) As String
          Return String.Format("A top of the morning to you, {0}!", name)
       End Function
    End Module
    

    Ardından, StringUtilities.dll dinamik bağlantı kitaplığında yöntemini yönetilmeyen kod gibi çağırmaya StringUtilities.SayGoodMorning çalışan aşağıdaki örneği derleyip yürütür. Sonuç bir EntryPointNotFoundException özel durumdur.

    using System;
    using System.Runtime.InteropServices;
    
    public class Example
    {
       [DllImport("StringUtilities.dll", CharSet = CharSet.Unicode )]
       public static extern String SayGoodMorning(String name);
    
       public static void Main()
       {
          Console.WriteLine(SayGoodMorning("Dakota"));
       }
    }
    // The example displays the following output:
    //    Unhandled Exception: System.EntryPointNotFoundException: Unable to find an entry point
    //    named 'GoodMorning' in DLL 'StringUtilities.dll'.
    //       at Example.GoodMorning(String& name)
    //       at Example.Main()
    
    open System
    open System.Runtime.InteropServices
    
    [<DllImport("StringUtilities.dll", CharSet = CharSet.Unicode )>]
    extern String SayGoodMorning(String name)
    
    printfn $"""{SayGoodMorning "Dakota"}"""
    // The example displays the following output:
    //    Unhandled Exception: System.EntryPointNotFoundException: Unable to find an entry point
    //    named 'GoodMorning' in DLL 'StringUtilities.dll'.
    //       at Example.GoodMorning(String& name)
    //       at Example.Main()
    
    Module Example
       Declare Unicode Function GoodMorning Lib "StringUtilities.dll" (
          ByVal name As String) As String  
    
       Public Sub Main()
          Console.WriteLine(SayGoodMorning("Dakota"))
       End Sub
    End Module
    ' The example displays the following output:
    '    Unhandled Exception: System.EntryPointNotFoundException: Unable to find an entry point 
    '    named 'GoodMorning' in DLL 'StringUtilities.dll'.
    '       at Example.GoodMorning(String& name)
    '       at Example.Main()
    

    Özel durumu ortadan kaldırmak için yönetilen derlemeye bir başvuru ekleyin ve StringUtilities.SayGoodMorning aşağıdaki örnekte olduğu gibi yönetilen koddaki diğer yöntemlere erişdiğiniz gibi yöntemine erişin.

    using System;
    
    public class Example
    {
       public static void Main()
       {
           Console.WriteLine(StringUtilities.SayGoodMorning("Dakota"));
       }
    }
    // The example displays the following output:
    //        A top of the morning to you, Dakota!
    
    printfn $"""{StringUtilities.SayGoodMorning "Dakota"}"""
    // The example displays the following output:
    //        A top of the morning to you, Dakota!
    
    Module Example
       Public Sub Main()
          Console.WriteLine(StringUtilities.SayGoodMorning("Dakota"))
       End Sub
    End Module
    ' The example displays the following output:
    '       A top of the morning to you, Dakota!
    
  • COM DLL'sindeki bir yöntemi Windows DLL'siymiş gibi çağırmaya çalışıyorsunuz. COM DLL'sine erişmek için, projeye başvuru eklemek için Visual Studio Add Reference seçeneğini belirleyin ve ardından COM sekmesinden tür kitaplığını seçin.

EntryPointNotFoundExceptionörneğinin ilk özellik değerlerinin listesi için bkz. EntryPointNotFoundException oluşturucuları.

Oluşturucular

Name Description
EntryPointNotFoundException()

EntryPointNotFoundException sınıfının yeni bir örneğini başlatır.

EntryPointNotFoundException(SerializationInfo, StreamingContext)
Geçersiz.

Serileştirilmiş verilerle EntryPointNotFoundException sınıfının yeni bir örneğini başlatır.

EntryPointNotFoundException(String, Exception)

Belirtilen bir hata iletisi ve bu özel durumun nedeni olan iç özel duruma başvuru ile EntryPointNotFoundException sınıfının yeni bir örneğini başlatır.

EntryPointNotFoundException(String)

Belirtilen bir hata iletisiyle sınıfının yeni bir örneğini EntryPointNotFoundException başlatır.

Özellikler

Name Description
Data

Özel durum hakkında kullanıcı tanımlı ek bilgiler sağlayan anahtar/değer çiftleri koleksiyonunu alır.

(Devralındığı yer: Exception)
HelpLink

Bu özel durumla ilişkili yardım dosyasının bağlantısını alır veya ayarlar.

(Devralındığı yer: Exception)
HResult

Belirli bir özel duruma atanan kodlanmış sayısal bir değer olan HRESULT değerini alır veya ayarlar.

(Devralındığı yer: Exception)
InnerException

Geçerli özel duruma neden olan Exception örneğini alır.

(Devralındığı yer: Exception)
Message

Bu özel durum için hata iletisini alır.

(Devralındığı yer: TypeLoadException)
Source

Hataya neden olan uygulamanın veya nesnenin adını alır veya ayarlar.

(Devralındığı yer: Exception)
StackTrace

Çağrı yığınındaki anlık çerçevelerin dize gösterimini alır.

(Devralındığı yer: Exception)
TargetSite

Geçerli özel durumu oluşturan yöntemini alır.

(Devralındığı yer: Exception)
TypeName

Özel duruma neden olan türün tam adını alır.

(Devralındığı yer: TypeLoadException)

Yöntemler

Name Description
Equals(Object)

Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler.

(Devralındığı yer: Object)
GetBaseException()

Türetilmiş bir sınıfta geçersiz kılındığında, sonraki bir veya daha fazla özel durumun kök nedeni olan Exception döndürür.

(Devralındığı yer: Exception)
GetHashCode()

Varsayılan karma işlevi işlevi görür.

(Devralındığı yer: Object)
GetObjectData(SerializationInfo, StreamingContext)
Geçersiz.

SerializationInfo Nesneyi sınıf adı, yöntem adı, kaynak kimliği ve ek özel durum bilgileriyle ayarlar.

(Devralındığı yer: TypeLoadException)
GetType()

Geçerli örneğin çalışma zamanı türünü alır.

(Devralındığı yer: Exception)
MemberwiseClone()

Geçerli Objectbasit bir kopyasını oluşturur.

(Devralındığı yer: Object)
ToString()

Geçerli özel durumun dize gösterimini oluşturur ve döndürür.

(Devralındığı yer: Exception)

Ekinlikler

Name Description
SerializeObjectState
Geçersiz.

Özel durum hakkında serileştirilmiş veriler içeren bir özel durum durumu nesnesi oluşturmak için bir özel durum seri hale getirildiğinde gerçekleşir.

(Devralındığı yer: Exception)

Şunlara uygulanır

Ayrıca bkz.