本文整理匯總了C#中System.EntryPointNotFoundException類的典型用法代碼示例。如果您正苦於以下問題:C# EntryPointNotFoundException類的具體用法?C# EntryPointNotFoundException怎麽用?C# EntryPointNotFoundException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EntryPointNotFoundException類屬於System命名空間,在下文中一共展示了EntryPointNotFoundException類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetMyNumber
//引入命名空間
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);
}
}
}
輸出:
EntryPointNotFoundException: Unable to find an entry point named 'GetMyNumber' in DLL 'User32.dll'.
示例2: Main
//引入命名空間
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));
}
}
輸出:
Unhandled Exception: System.EntryPointNotFoundException: Unable to find an entry point named 'Double' in DLL '.\TestDll.dll'. at Example.Double(Int32 number) at Example.Main()
示例3: 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);
}
}
}
示例4: Main
//引入命名空間
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));
}
}
輸出:
20
示例5: SayGoodMorning
//引入命名空間
using System;
public static class StringUtilities
{
public static String SayGoodMorning(String name)
{
return String.Format("A top of the morning to you, {0}!", name);
}
}
示例6: Main
//引入命名空間
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"));
}
}
輸出:
Unhandled Exception: System.EntryPointNotFoundException: Unable to find an entry point named 'GoodMorning' in DLL 'StringUtilities.dll'. at Example.GoodMorning(String& name) at Example.Main()
示例7: Main
//引入命名空間
using System;
public class Example
{
public static void Main()
{
Console.WriteLine(StringUtilities.SayGoodMorning("Dakota"));
}
}
輸出:
A top of the morning to you, Dakota!