//系统的dll
[DllImport("user32.dll")]
public static extern int MessageBoxA(IntPtr h, string m, string c, System.UInt32 type);
//自己的dll
[DllImport("ClassLibrary1.dll")]
public static extern string UserID();下面是:
string a = UserID();//此处报出不可以加载ClassLibrary1.dll,为什么????????
IntPtr h = new IntPtr(0);
MessageBoxA(h, "Hello", "标题", 0);
[DllImport("user32.dll")]
public static extern int MessageBoxA(IntPtr h, string m, string c, System.UInt32 type);
//自己的dll
[DllImport("ClassLibrary1.dll")]
public static extern string UserID();下面是:
string a = UserID();//此处报出不可以加载ClassLibrary1.dll,为什么????????
IntPtr h = new IntPtr(0);
MessageBoxA(h, "Hello", "标题", 0);
要调用自己生成的DLL,直接"添加引用"就可以了.然后在代码里using yourdll
生成dll的class文件有问题吗? 等待高手指点ing...using System;namespace ClassLibrary1
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
public class Class1
{
public static bool Swap(long i,long j)
{
i = i+j;
j = i-j;
i = i-j;
return true;
}
}
}
你的调用方程序是什么语言?如果也是C#的话,直接Reference引用不就可以用了么,干嘛这么麻烦。
我的QQ 18473575 不怕麻烦的高手请加!!!
如果是别的程序生成的DLL,找不到入口点就是路径问题
添加到引用就可以.
然后USING一下.
怎样写一个正确的class文件,设置其入口呢
希望能给我一个简单的,能说明问题的例子 等待ing...
(我的QQ:18473575 Email:[email protected] , [email protected])
(第一次接触DLL,望大家不吝赐教)
C和VC的DLL中有些函数可以使用DllImport引入.net中使用。非COM的C、VC的DLL不能通过添加引用使用。
C#的DLL可以直接添加引用使用。也可以动态加载程序集的方式使用(见System.Reflection.Assembly类)。但不可以通过DllImport引入。