C#调用C Dll的问题
在C#中调用C写的Dll,
函数原型为 void GetPic(char * szCode, BYTE * pPicture)
用C#建个窗口应用程序
[DllImport("PictureGenerator.dll", EntryPoint = "GetPic")]
static extern void GetPic(string szCode, byte[] pPicture);
private void Form1_Load(object sender, EventArgs e)
{
Byte[] pPic = new Byte[9000];
GetPic("test", pPic);
}
这样是可以调用的。
但是,同样的代码,放在WEB中就不行了。在运行到GetPic时就会出错。说是
NullReferenceException: 未将对象引用设置到对象的实例
这是为什么啊,窗口程序的与WEB有什么不同么。