发贴两天了!!谁能解决C#调用VB写的DLL

kongwzg 2005-07-18 08:49:56

在VB中写的testDll.dll,并编译了,代码(已经通过VB调用的测试)如下:
Option Explicit

Public Function jia(ByVal a As Long, ByVal b As Long) As Long
Dim s As Long
s = a + b
jia = s
End Function

C#的form代码如下:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace test11
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void button1_Click(object sender, System.EventArgs e)
{
c1 c = new c1();
c.Jia(1,2);
}
}
}

c#中类c1的代码如下:
using System;
using System.Runtime.InteropServices;

namespace test11
{
/// <summary>
/// c1 的摘要说明。
/// </summary>
public class c1
{
public c1()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
[DllImport("testDll.dll")]
private static extern void jia(int a,int b);

public void Jia(int pX,int pY)
{
int i;
i=jia( pX, pY);
}

}
}

已经把testDll.dll拷到了bin\Debug的目录;还在 项目->添加引用 把它引用进来了

运行程序错误提示:"无法在 DLL testDll.dll 中找到名为 jia 的入口点"

注意:1 不是要调用API
2 private static extern void jia改为private static extern int jia也是一样的

或者看贴:http://community.csdn.net/Expert/topic/4149/4149505.xml?temp=.642544
...全文
68 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
JzeroBiao 2005-07-18
  • 打赏
  • 举报
回复
注册VB6控件.你的VS.NET下那张系统备份里有....

110,499

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧