主题:C#中动态引用DLL问题
using System;
using System.Collections.Generic;
using System.Text;
namespace my
{
public class mytoall
{
public static int getall(int a ,int b)
{
return a + b;
}
}
}
编译成DLL文件(my.dll),新建了个test的Application
把my.dll复制到debug下面,为什么这样引用会有错误?
(不要右键-添加引用,这样谁都会)
namespace test
{
public partial class Form1 : Form
{
[DllImport("my.dll")]
public static extern int getall(int a,int b);
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(getall(521,365).ToString());
}
}
}
using System.Collections.Generic;
using System.Text;
namespace my
{
public class mytoall
{
public static int getall(int a ,int b)
{
return a + b;
}
}
}
编译成DLL文件(my.dll),新建了个test的Application
把my.dll复制到debug下面,为什么这样引用会有错误?
(不要右键-添加引用,这样谁都会)
namespace test
{
public partial class Form1 : Form
{
[DllImport("my.dll")]
public static extern int getall(int a,int b);
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(getall(521,365).ToString());
}
}
}