本文整理汇总了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!