从c.net调用32位dll [英] Calling an 32bit dll from c.net
问题描述
我有一个调用dll的VB6程序。我正在将程序转换为c.net 2010.我正在x86下构建。 dll是用PowerBasic创建的。
VB6代码
声明函数trm_Open LibTRM.DLL (PathFileName As String,MultiUser As Long)As
UidFileName =c:\ user.trm
multiUserMode = 1
hUidFile = trm_Open(UidFileName,multiUserMode)
c.net 2010
[DllImport(@TRM.DLL)]
static extern int trm_Open(string pathFileName,int nMultiUser);
public int trmOpen(string pathFileName,int nMultiUser)
{
返回trm_Open(pathFileName,nMultiUser);
}
string filename =c:\ user.trm;
int mu = 1;
rtc = trmOpen(filename,mu) ;
我收到此错误。
类型''系统的未处理异常。 trmtest1.exe中发生了DllNotFoundException''
附加信息:Unab le加载DLL''TRM.DLL'':无效访问内存位置。 (HRESULT异常:0x800703E6)
谢谢,
马克
Hi,
I have a VB6 program that call a dll. I''m converting the program to c.net 2010. I''m building under x86. The dll was created with PowerBasic.
VB6 Code
Declare Function trm_Open Lib "TRM.DLL" (PathFileName As String, MultiUser As Long) As Long
UidFileName = "c:\user.trm"
multiUserMode = 1
hUidFile = trm_Open(UidFileName, multiUserMode)
c.net 2010
[DllImport(@"TRM.DLL")]
static extern int trm_Open(string pathFileName, int nMultiUser);
public int trmOpen(string pathFileName, int nMultiUser)
{
return trm_Open(pathFileName, nMultiUser);
}
string filename = "c:\user.trm";
int mu=1 ;
rtc = trmOpen(filename, mu);
I''m getting this error.
An unhandled exception of type ''System.DllNotFoundException'' occurred in trmtest1.exe
Additional information: Unable to load DLL ''TRM.DLL'': Invalid access to memory location. (Exception from HRESULT: 0x800703E6)
Thanks,
Mark
推荐答案
将TRM.DLL放在应用程序的输出文件夹中,再试一次。
-SA
Place "TRM.DLL" in the output folder of your application, try again.
—SA
>
这篇关于从c.net调用32位dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!