1、编译时使用reference参数引用你的dll程序集 2、在 Visual Studio 开发环境中设置此编译器选项,“添加引用” 3、以编程方式设置此编译器选项 [C#] Reference Add(string bstrPath);bstrPath 是COM 或 .NET Framework 引用的路径。 该参数可采用三种形式: (1)简单的 .NET Framework 对象名,例如“System”。 (2).NET Framework 文件名(.tlb、.dll 或 .ocx 文件)。-----你所说的情况 (3)COM 库文件(.tlb、.dll、.ocx 或 .exe 文件)。对于 COM 对象,路径需要包含完整路径和文件名,比如“D:\SomeApplication\SomeApp.dll”。请参见下面的“COM 引用”一节中对添加 COM .exe 文件引用的限制。示例 ' Macro Editor Imports VSLangProj Sub AddExample() ' This example assumes that the first project in the solution is ' either a Visual Basic or C# project. Dim aVSProject As VSProject = _ CType(DTE.Solution.Projects.Item(1).Object, VSProject)
Dim refs As References = aVSProject.References ' Adds a reference to a compiled .NET project. refs.Add("C:\path\program.dll") ' Adds a reference to an installed ActiveX control. refs.Add("C:\WINNT\system32\msmask32.ocx") ' Adds a reference to System.dll as an example of adding a ' reference using just the simple name. refs.Add("System") End Sub参见 ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/vbcon/html/vblrfaddmethodreferences.htm
using MyClasses.Data;
using MyClasses.Data;
csc /reference:MyClasses.dll /out:out.exe input.cs
2、在 Visual Studio 开发环境中设置此编译器选项,“添加引用”
3、以编程方式设置此编译器选项
[C#]
Reference Add(string bstrPath);bstrPath 是COM 或 .NET Framework 引用的路径。
该参数可采用三种形式:
(1)简单的 .NET Framework 对象名,例如“System”。
(2).NET Framework 文件名(.tlb、.dll 或 .ocx 文件)。-----你所说的情况
(3)COM 库文件(.tlb、.dll、.ocx 或 .exe 文件)。对于 COM 对象,路径需要包含完整路径和文件名,比如“D:\SomeApplication\SomeApp.dll”。请参见下面的“COM 引用”一节中对添加 COM .exe 文件引用的限制。示例
' Macro Editor
Imports VSLangProj
Sub AddExample()
' This example assumes that the first project in the solution is
' either a Visual Basic or C# project.
Dim aVSProject As VSProject = _
CType(DTE.Solution.Projects.Item(1).Object, VSProject)
Dim refs As References = aVSProject.References
' Adds a reference to a compiled .NET project.
refs.Add("C:\path\program.dll")
' Adds a reference to an installed ActiveX control.
refs.Add("C:\WINNT\system32\msmask32.ocx")
' Adds a reference to System.dll as an example of adding a
' reference using just the simple name.
refs.Add("System")
End Sub参见
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/vbcon/html/vblrfaddmethodreferences.htm