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");
}

解决方案 »

  1.   

    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");
    }
      

  2.   

    不好使啊,VSLangProj,  References都找不到??
      

  3.   

    VSLangProj是一个什么项目?先通过项目浏览器中的添加引用,加进去
    using时,要加全部的命名空间,例如Microsoft.Win32;