你的意思是不是这样的阿 using System; using System.Runtime.InteropServices;namespace Beep { class Class1 { [DllImport("kernel32.dll")] public static extern bool Beep(int frequency, int duration); static void Main(string[] args) { Random random = new Random(); for (int i = 0; i < 10000; i++) { Beep(random.Next(10000), 100); } } } }
将 COM 组件转换为 .NET 程序集后,可以通过在 ASP.NET 页的顶部放置一条指令来将它导入该页。例如,下面的指令导入由 Tlbimp 实用工具创建的命名空间 MyNewNamespace:Dos模式下
Tlbimp XPass.dll /out:XinNuo.dll /namespace:xnps. 由 Tlbimp.exe 生成的程序集文件必须放置在 ASP.NET 应用程序的 \bin 目录下。原始的 COM 组件文件必须对它所驻留的目录进行注册。
在 ASP.NET 页中使用单线程 (STA) COM 组件(如使用 Visual Basic 开发的组件)时,必须在该 ASP.NET 页上的 <%@ Page > 标记中包括兼容性属性 aspcompat=true。
、使用vs.net添加for example
MClass aa=new MClass();
object tt=aa.yourfunction(ref ttt); 引用b.dll,直接引用b.dll
2、使用using指令在源文件中引用名称空间。
3、构造一个类的实例。
4、通过实例调用属性和方法。
欢迎您使用Microsoft技术,分享知识,共同进步!
ms-help://MS.VSCC/MS.MSDNVS.2052/cpguide/html/cpconimportingtypelibraryasassembly.htm
using System;
using System.Runtime.InteropServices;namespace Beep
{
class Class1
{
[DllImport("kernel32.dll")]
public static extern bool Beep(int frequency, int duration); static void Main(string[] args)
{
Random random = new Random(); for (int i = 0; i < 10000; i++)
{
Beep(random.Next(10000), 100);
}
}
}
}