我在VB5中写了一个旧程序。这个程序调用一个用c ++编写的DLL。 我想从VB5转换到C#。 这是原始代码:
VB5中的声明:
Option Explicit <br>
Private Declare Sub GENRAS _ <br>
Lib "C:\WINNT\system\genras32.dll" _ <br>
(ByVal pmarca_de_input As String, _ <br>
pcant_rasgo As Long, _ <br>
ppeso_rasgo As Long, _ <br>
ByVal ptab_rasgos As String) <br>
VB5中的调用:
Private Sub Command1_Click() <br>
Dim pmarca_de_input As String * 201 <br>
Dim pcant_rasgo As Long <br>
Dim ppeso_rasgo As Long <br>
Dim ptab_rasgos As String * 1400 <br>
Dim sPeso As String <br>
Dim sRasgo As String <br>
Dim sBuffer As String <br>
Dim i As Integer <br>
ptab_rasgos = String(Len(ptab_rasgos), Chr(0)) <br>
pmarca_de_input = UCase(Text1.Text) <br>
Call GENRAS(pmarca_de_input, pcant_rasgo, ppeso_rasgo, ptab_rasgos) <br>
这是我在c#
中尝试的转换[DllImport(@"C:\Users\Victor Herrera\Documents\visual studio 2017\Projects\Test_1_genras\Test_1_genras\genras32.dll", CharSet = CharSet.Unicode)]
public static extern void GENRAS(string pmarca_de_input,ref long pcant_rasgo,ref long ppeso_rasgo,ref string ptab_rasgos);
private void button1_Click(object sender, EventArgs e)
{
long pcant_rasgo=0;
long ppeso_rasgo=0;
string rasgos = "";
GENRAS("maria",ref pcant_rasgo,ref ppeso_rasgo,ref rasgos);
}
在“ppeso”我应该收到一个号码(例如:195)
在“pcant”中我应该收到一个数字(例如:8)
在“rasgos”我应该收到一个字符串(例如:MA; 170 | MI; 195 | AI; 190 | A; 210 |
System.BadImageFormatException:'Se ha intentado cargar un programa con un formato wrongo。 (ExcepcióndeHRESULT:0x8007000B)' (英文:尝试加载一个错误(不正确)格式的程序)