asp.net调用vc的dll问题.咋一直找不到dll?
http://blog.csdn.net/jingzhongrong/archive/2008/05/08/2416623.aspx调用代码来自他这里.我在winform里测试成功了.但是在asp.net下不成功.
int hModule = InvokeHelper.LoadLibrary(@"Express.dll");
if (0 != hModule)
{
}
else
{
return -1;
}
代码就是上边这样.咋总返回-1?我把Express.dll放在bin下边了.想是这样才出错.所以改成
int hModule = InvokeHelper.LoadLibrary(@"D:\project\cha66\Site\Bin\Express.dll");
但还是不能成功.我又放到system32了.还是不行.哪位有做过类似的?你们咋解决的啊?
public static class InvokeHelper--------------------编程问答--------------------
{
[DllImport("Kernel32")]
public static extern int GetProcAddress(int handle, String funcName);
[DllImport("Kernel32")]
public static extern int LoadLibrary(String fileName);
[DllImport("Kernel32")]
public static extern int FreeLibrary(int handle);
///<summary>
///通过非托管函数名转换为对应的委托, by jingzhongrong
///</summary>
///<param name="dllModule">通过LoadLibrary获得的DLL句柄</param>
///<param name="functionName">非托管函数名</param>
///<param name="t">对应的委托类型</param>
///<returns>委托实例,可强制转换为适当的委托类型</returns>
public static Delegate GetFunctionAddress(int dllModule, string functionName, Type t)
{
int address = GetProcAddress(dllModule, functionName);
if (address == 0)
return null;
else
return Marshal.GetDelegateForFunctionPointer(new IntPtr(address), t);
}
///<summary>
///将表示函数地址的IntPtr实例转换成对应的委托, by jingzhongrong
///</summary>
public static Delegate GetDelegateFromIntPtr(IntPtr address, Type t)
{
if (address == IntPtr.Zero)
return null;
else
return Marshal.GetDelegateForFunctionPointer(address, t);
}
///<summary>
///将表示函数地址的int转换成对应的委托,by jingzhongrong
///</summary>
public static Delegate GetDelegateFromIntPtr(int address, Type t)
{
if (address == 0)
return null;
else
return Marshal.GetDelegateForFunctionPointer(new IntPtr(address), t);
}
//本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/jingzhongrong/archive/2008/05/08/2416623.aspx
}
右击bin文件夹—添加引用—浏览—选择要引用的dll文件—确定 --------------------编程问答--------------------
我放进去了.我调用的是非托管Dll --------------------编程问答-------------------- 网站bin目录 下
DLL操作权限 --------------------编程问答-------------------- 在web.config中加
<identity impersonate="true" userName="administrator" password="xxxxx" />
补充:.NET技术 , ASP.NET