簡體   English   中英

C#編譯器找不到dll; VS2010中編譯的解決方案

[英]C# compiler does not find dlls ; solution compiled in VS2010

我有一個C#解決方案和一些引用的dll-s。 即使在Visual Studio(vs2010)中進行編譯時,它看起來像是成功,但在使用C#編譯器時卻失敗了:顯然缺少dll。

csc /t:library /out:test.dll test.cs


test.cs(22,10): error CS0246: The type or namespace name
    'Attribute' could not be found (are you missing a using directive
    or an assembly reference?)

有人知道為什么會這樣嗎?

由於您沒有提供代碼,因此尚不清楚Attribute是什么類型。 如果它是System.Attribute ,我希望可以通過默認的程序集引用自動找到它。 如果它是另一個程序集中的類型,則需要從命令行中顯式引用它:

csc /t:library /out:test.dll /r:OtherAssembly.dll test.cs

CSC對包含test.cs的項目一無所知,也對該項目所引用的任何庫一無所知。

您必須使用/ r開關才能引用其他程序集。 請注意,包含csc.exe的文件夾中有一個名為csc.rsp的文件,該文件指定默認命令行開關。 它包含大多數常用的.NET Framework程序集,因此,例如,您不必顯式引用mscorlib.dll。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM