即使在给出参考后,使用 NANT 编译 C# 项目时仍会出现汇编参考错误
我的解决方案有多个项目,内部相互引用。项目名称 DataAccess 引用 Objects 项目。在我的 NANT 脚本中,我首先编译成功的 Objects 文件夹,然后当我尝试编译 DataAccess 项目时,出现程序集引用错误,如下所示;
错误 CS0246:找不到类型或命名空间名称“CustomerProfile”(是否缺少 using 指令或程序集引用?)
CustomerProfile 类是对象项目的一部分,我明确提到了 NANT 中的引用,如下所示;
<csc target="library" output="${OutputFolder}\bin\Objects.dll" debug="${debug}">
<references />
<sources basedir="${SourceCodeFolder}">
<include name="Objects\\**\*.cs" />
</sources>
</csc>
<csc target="library" output="${OutputFolder}\bin\DataAccess.dll" debug="${debug}" >
<references>
<lib>
<include name="${OutputFolder}\bin" />
</lib>
<include name="Objects.dll" />
</references>
<sources basedir="${SourceCodeFolder}">
<include name="DataAccess\\**\*.cs" />
</sources>
</csc>
奇怪的是,如果我从参考部分中删除
,我会收到以下错误;
错误CS0234:类型或命名空间名称“对象”在命名空间“”中不存在(您是否缺少程序集引用?)
这证实了程序集引用应该按照我在上面的代码片段中给出的方式进行。但我无法理解,如果程序集引用正确完成,那么为什么该程序集的类(“CustomerProfile”)没有被拾取,
有人可以帮忙吗?
My solution has multiple projects with Internal reference to each other. Project name DataAccess references Objects project. In my NANT script I first compile the Objects folder which succeeds and then when I try to compile DataAccess project I get the assembly reference error which is as below;
error CS0246: The type or namespace name 'CustomerProfile' could not be found (are you missing a using directive or an assembly reference?)
CustomerProfile Class is part of the Objects project and I am clearly mentioning the reference in the NANT as shown below;
<csc target="library" output="${OutputFolder}\bin\Objects.dll" debug="${debug}">
<references />
<sources basedir="${SourceCodeFolder}">
<include name="Objects\\**\*.cs" />
</sources>
</csc>
<csc target="library" output="${OutputFolder}\bin\DataAccess.dll" debug="${debug}" >
<references>
<lib>
<include name="${OutputFolder}\bin" />
</lib>
<include name="Objects.dll" />
</references>
<sources basedir="${SourceCodeFolder}">
<include name="DataAccess\\**\*.cs" />
</sources>
</csc>
Weird thing is if I remove the <include name="Objects.dll" />
from the reference section I get the below error;
error CS0234: The type or namespace name 'Objects' does not exist in the namespace '' (are you missing an assembly reference?)
Which confirms that the assembly references should b given the way I have given in the above code snippet. But I fail to understand that if the assembly refernce is done correctly then how come the class ('CustomerProfile') withing that assembly is not getting picked up
Can any one please help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在前同事的帮助下问题得到了解决。在参考部分中应提及 dll 的完整路径。修复后的代码片段下方;
Got the issue resolved with the help of my ex colleague. In the references section full path to the dll should be mentioned. Below the code snippet after the fix;