Using VSLangProj
void AddExample()
{
// This example assumes that the first project in the solution is
//either a Visual Basic or C# project.
VSProject aVSProject =
TypeOf(DTE.Solution.Projects.Item(1).Object);
References refs = 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");
}
void AddExample()
{
// This example assumes that the first project in the solution is
//either a Visual Basic or C# project.
VSProject aVSProject =
TypeOf(DTE.Solution.Projects.Item(1).Object);
References refs = 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");
}
void AddExample()
{
// This example assumes that the first project in the solution is
//either a Visual Basic or C# project.
VSProject aVSProject =
TypeOf(DTE.Solution.Projects.Item(1).Object);
References refs = 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");
}
using时,要加全部的命名空间,例如Microsoft.Win32;