C# DLL
--------------------------------------------------------------------------
using System;
namespace FileCm
{
public class Class1
{
public static long aa(long x, long y)
{
return (x*y);
}
}
}
--------------------------------------------------------------------------
编译成 FileCm.Dll
VB 6 中
----------------------------------------------------------------------------
Declare Function aa Lib "FileCm" (ByVal x As Long, ByVal y As Long) As Longfunction bb()
aa 1,1
end function
----------------------------------------------------------------------------
VB 中 出错了,告诉我FileCm中找不到 aa,为啥?
小弟 第一次 Dll 不会用牙,,
--------------------------------------------------------------------------
using System;
namespace FileCm
{
public class Class1
{
public static long aa(long x, long y)
{
return (x*y);
}
}
}
--------------------------------------------------------------------------
编译成 FileCm.Dll
VB 6 中
----------------------------------------------------------------------------
Declare Function aa Lib "FileCm" (ByVal x As Long, ByVal y As Long) As Longfunction bb()
aa 1,1
end function
----------------------------------------------------------------------------
VB 中 出错了,告诉我FileCm中找不到 aa,为啥?
小弟 第一次 Dll 不会用牙,,
VB : 点project菜单中的reference
用tlbexp导出dll再注册也不行。
用vb.net应该可以,但是写的时候得注意,需要符合FCL规范。
using System;
namespace FileCm
{
public class Class1
{
public int aa(int x, int y)
{
return (x*y);
}
}
}
命令提示符下运行:
regasm your.dll /tlb:your.tlb /codebase
然后在VB中引用your.tlb文件
Private Sub Form_Load()
Set obj = New Class1
d = obj.aa(3, 4)
MsgBox d
End Sub
------------------------------------------
我给帖子加了 29 分,谢谢你的回复(非常感谢)
我用你的方法试了一下,不行
我这样做的,你看看有没有错:
1,在 VS.net 下生成 FileCm.dll ,文件在 I:\FileCm.dll
2,在 命令提示符下 regasm I:\FileCm.dll/tlb:I:\File.tlb/codebase
3, 在 命令提示符下 regasm I:\FileCm.dll/tlb:File.tlb/codebase
4,先把FileCm.dll拷贝到C:\Program Files\Common Files\System\Mapi\2052\NT目录下(因为 ReGasm.exe 在 这个目录下),然后 regasm FileCm.dll /tlb:FileCm.tlb /codebase
以上方法都不行,希望解答
----------------------------------------
我这样做的,你看看有没有错:
1,在 VS.net 下生成 FileCm.dll ,文件在 I:\FileCm.dll
2,在 命令提示符下 regasm I:\FileCm.dll/tlb:I:\FileCm.tlb/codebase(失败)
3, 在 命令提示符下 regasm I:\FileCm.dll/tlb:FileCm.tlb/codebase(失败)
4,先把FileCm.dll拷贝到C:\Program Files\Common Files\System\Mapi\2052\NT目录下
(因为 ReGasm.exe 在 这个目录下),然后 regasm FileCm.dll /tlb:FileCm.tlb /codebase
(失败)
失败的提示是:RegAsm error: The given path's format is not supported.
gacutil -i FileCm.dll注意,命令程序要和dll在同一目录下,或者在可直接访问的Windows目录下。
但是 在 VB6 中引用时出错了
他说 装载 DLL 失败兹,,这么困难,还是我笨