南特没有看到参考 [英] Nant does not see reference
本文介绍了南特没有看到参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用c#代码通过nant脚本杀死所有IE实例:
I want to kill all IE instances by nant script with c# code:
<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>
执行此脚本时,出现以下错误:
When I execute this script I get the following error:
错误CS0234:类型或名称空间名称'Process'在以下位置不存在 命名空间"System.Diagnostics"(您是否缺少程序集 参考?)
error CS0234: The type or namespace name 'Process' does not exist in the namespace 'System.Diagnostics' (are you missing an assembly reference?)
这是怎么了?
推荐答案
我遇到了类似的问题,最终在NAnt代码中添加了以下引用:
I had a similar issue and I ended up adding the following reference to the NAnt code:
<script ... >
<references>
<include name="System.dll"/>
...
</references>
<code>
...
</code>
</script>
您应明确添加System.dll
-它不在列表中默认包含的程序集数量.
You should add System.dll
explicitly - it is not in the list of assemblies included by default.
这篇关于南特没有看到参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文