Nant无法找到引用。

4
我想使用c#代码在nant脚本中杀死所有IE实例:
<target name="clean">  
   <script language="C#" prefix="Cleaning">          
          <references>
              <include name="System.Diagnostics.dll" />
          </references>
                <imports>
                    <import namespace="System.Diagnostics" />
                </imports>
          <code>
            <![CDATA[

              [Function("Delete")]
              public static void KillIe() 
              {                     

                foreach (var process in Process.GetProcessesByName("iexplore"))
                {
                  process.Kill();
                }         

              }
            ]]>
          </code>
      </script>
 <echo message="Calling function: ${Cleaning::KillIe()}"/> 
  </target>    
</project>

当我执行这个脚本时,出现了以下错误:

错误 CS0234:名称空间“System.Diagnostics”中不存在类型或命名空间名称“Process”(是否缺少程序集引用?)

这是什么问题?
1个回答

4

我曾遇到类似的问题,最终在NAnt代码中添加了以下引用:

<script ... >
  <references>
    <include name="System.dll"/>
    ...
  </references>
  <code>
    ...
  </code>
</script>

您需要明确添加System.dll——它不在默认包含的程序集列表中


2
更具体地说,他们应该使用文档来了解他们想要使用的类所包含的程序集。 命名空间!=程序集。 - Damien_The_Unbeliever

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接