简体   繁体   中英

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

On my Windows 7 workstation, I have a variety of compilers installed - including MSVC9 and MSVC10. I recently noticed the following strange problem which only occurs in my MSVC10 environment.

In my MSVC9 shell (I use the one from the start menu), running csc.exe shows that it's using the C# 2008 compiler version 3.5.30729.4926 (.NET 3.5). In the MSVC10 shell, it's compiler version 4.0.30128.1. Now, the following little sample program builds with csc.exe as of MSVC9, but it fails with MSVC10:

using System;
using System.Windows.Automation;

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

I use the following command line (with MSVC9 as well as MSVC10) to build the program:

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

With MSVC9, this succeeds (no output is printed and Hello.exe is built). With MSVC10, the build fails with this error message:

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

Does anybody know why that is?

I noticed that I can make the build work with MSVC10 if I modify the command line so that /r:UIAutomationClient.dll becomes /r:WPF\\UIAutomationClient.dll . 我注意到,如果我修改命令行,使/r:UIAutomationClient.dll变为/r:WPF\\UIAutomationClient.dll ,则可以使构建与MSVC10 /r:WPF\\UIAutomationClient.dll

Where is this UIAutomationClient.dll file located relative to your cs files?

Try passing the full path of UIAutomationClient.dll.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM