簡體   English   中英

如何解決“找不到元數據foo.dll!” 命令行上編譯C#代碼時出錯?

[英]How can I resolve 'Metadata foo.dll not found!' errors when compiling C# code on the command line?

在Windows 7工作站上,我安裝了各種編譯器-包括MSVC9和MSVC10。 我最近注意到以下奇怪的問題,僅在我的MSVC10環境中會發生。

在我的MSVC9 Shell(我從開始菜單中使用一個)中,運行csc.exe顯示它正在使用C#2008編譯器版本3.5.30729.4926(.NET 3.5)。 在MSVC10 Shell中,它是編譯器版本4.0.30128.1。 現在,以下小示例程序從MSVC9開始使用csc.exe生成,但在MSVC10上失敗:

using System;
using System.Windows.Automation;

namespace UIAutomationTest
{
    class Program
    {
        static void Main()
        {
        }
    }
}

我使用以下命令行(與MSVC9和MSVC10一起)來構建程序:

csc Hello.cs /r:UIAutomationClient.dll /nologo

使用MSVC9,此操作成功(不輸出任何輸出並構建Hello.exe )。 使用MSVC10,構建失敗並顯示以下錯誤消息:

C:\src>csc Hello.cs /r:UIAutomationClient.dll /nologo
error CS0006: Metadata file 'UIAutomationClient.dll' could not be found

有人知道為什么嗎?

更新:我注意到,如果我修改命令行,使/r:UIAutomationClient.dll變為/r:WPF\\UIAutomationClient.dll ,則可以使構建與MSVC10 /r:WPF\\UIAutomationClient.dll

此UIAutomationClient.dll文件相對於CS文件位於哪里?

嘗試傳遞UIAutomationClient.dll的完整路徑。

暫無
暫無

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

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