views:

299

answers:

1

csc /target:library /reference:System.dll,System.Web.dll,System.Web.Mvc.dll Foo.cs

Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1 Copyright (C) Microsoft Corporation. All rights reserved.

error CS0006: Metadata file 'System.Web.Mvc.dll' could not be found

(Note - it does exist in the GAC under GAC_MSIL folder)

A: 

You cannot use the assemblies in the GAC as reference assemblies. In order to reference an assembly you will need to put it in some folder and specify the full path to it. Visual Studio solves this by keeping a local copy of each referenced assembly. Click on a referenced assembly in your project and you will see the full path to the file used by Visual Studio to when compiling. For example on my machine System.Web.Mvc.dll is stored in C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 2\Assemblies\System.Web.Mvc.dll. So the command looks like this:

csc /target:library /r:"C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 2\Assemblies\System.Web.Mvc.dll" Foo.cs
Darin Dimitrov