简体   繁体   中英

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

I have a C# solution and some referenced dll-s. Even though when compiling in visual studio(vs2010) it appears as it succeeded, when using the C# compiler it fails: missing dll apparently..

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?)

Does anyone know why is this happening?

As you haven't given the code, it's not clear what type Attribute is meant to be. If it's System.Attribute , I'd expect that to be found automatically via the default assembly references. If it's a type in another assembly, you need to explicitly reference it from the command line:

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

CSC knows nothing about the project containing test.cs, nor any libraries which that project is referencing.

You have to use the /r switch in order to reference other assemblies. Note that there is a file called csc.rsp in the folder containing csc.exe, which specifies default command line switches. This contains most of the usual .NET framework assemblies, which is why you do not have to explicitly reference mscorlib.dll, for example.

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