开发者

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 n开发者_JAVA技巧ame
    '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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜