【发布时间】:2014-02-12 09:40:07
【问题描述】:
我有一个 WPF 应用程序,我必须加载 DLL cc3260mt.dll
我使用 LoadLibrary() 调用它,但无论出于何种原因,我都会收到 ArithmeticException。
这是我的代码的样子:
public partial class MainWindow : Window
{
[DllImport("kernel32.dll")]
static extern IntPtr LoadLibrary(string dllToLoad);
[DllImport("kernel32.dll")]
static extern IntPtr FreeLibrary(IntPtr hModule);
public MainWindow()
{
InitializeComponent();
try
{
string cc3260mtPath = "dll/cc3260mt.dll";
IntPtr cc3260Link = LoadLibrary(cc3260mtPath);
}
catch (Exception ex)
{
Console.WriteLine("ERROR : " + ex.Message);
}
} // <-- This is where I get the Exception.
}
当我一步一步运行我的代码时,我可以清楚地看到当我退出我的 MainWindow() 类时出现了异常。
你们知道是什么让我遇到了这个例外吗?
【问题讨论】:
-
大概就是这个问题的答案了……stackoverflow.com/questions/21677867/…
标签: c# wpf visual-studio-2012 dll loadlibrary