通过命令行编译c#代码时如何使用引用

2

本文介绍了通过命令行编译c#代码时如何使用引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

谁能帮我通过命令行编译一些 c# 文件?我有 4 个文件要编译,Main、Form1(使用 2.cs 文件)和项目中使用的另一个类.

Could anyone help me compile via command line some c# files? I have 4 files to compile, Main, Form1 (which uses 2.cs file) and another class used in the project.

我想在命令行中编译这个项目,这样我就可以添加/t:library 开关(就像在本教程中一样:http://dotnetslackers.com/articles/csharp/WritingAnActiveXControlInCSharp.aspx).

I would like to compile this project in command line so I could add the /t:library switch (like in this tutorial: http://dotnetslackers.com/articles/csharp/WritingAnActiveXControlInCSharp.aspx).

但是,在使用csc/t:library Program1.cs MainForm.cs MainForm.Designer.cs EigenObjectRecognizer.cs"后,我得到了缺少程序集引用的错误,例如:

However after using "csc /t:library Program1.cs MainForm.cs MainForm.Designer.cs EigenObjectRecognizer.cs" I get missing assembly reference errros such as these:

ProjectFaceRecProOVaspVerFaceRecProOVMainForm.cs(14,15): error CS0234: The type or namespace name 'Structure' does not exist
    in the namespace 'Emgu.CV' (are you missing an assembly reference?)

我确实安装了 EMGU 二进制文件.我认为我需要使用该文件夹中的一些 .dll,例如 EMGU.CV.dll?

I do have installed EMGU binaries installed. I would think I need to use some .dll's from that folder like EMGU.CV.dll?

推荐答案

要在命令行上引用库,您需要使用 /r: 编译器选项并将相对路径传递给库.假设它在同一目录中,您可以执行以下操作

To reference a library on the command line you need to use the /r: compiler option and pass the relative path to the library. Assuming it's in the same directory you can do the following

csc/r:EMGU.CV.dll/t:library Program1.cs MainForm.cs MainForm.Designer.cs EigenObjectRecognizer.cs

csc /r:EMGU.CV.dll /t:library Program1.cs MainForm.cs MainForm.Designer.cs EigenObjectRecognizer.cs

文档:http://msdn.microsoft.com/en-us/library/yabyz3h4.通过指定 /? 可以直接从命令行获得简短版本的文档:C:WindowsMicrosoft.NETFrameworkv4.0.30319csc/?

Documentation: http://msdn.microsoft.com/en-us/library/yabyz3h4. Short version of documentation available directly from command line by specifying /?: C:WindowsMicrosoft.NETFrameworkv4.0.30319csc /?

这篇关于通过命令行编译c#代码时如何使用引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

C# 中的多播委托奇怪行为?
Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)...
2023-11-11 C#/.NET开发问题
6

参数计数与调用不匹配?
Parameter count mismatch with Invoke?(参数计数与调用不匹配?)...
2023-11-11 C#/.NET开发问题
26

如何将代表存储在列表中
How to store delegates in a List(如何将代表存储在列表中)...
2023-11-11 C#/.NET开发问题
6

代表如何工作(在后台)?
How delegates work (in the background)?(代表如何工作(在后台)?)...
2023-11-11 C#/.NET开发问题
5

没有 EndInvoke 的 C# 异步调用?
C# Asynchronous call without EndInvoke?(没有 EndInvoke 的 C# 异步调用?)...
2023-11-11 C#/.NET开发问题
2

Delegate.CreateDelegate() 和泛型:错误绑定到目标方法
Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)...
2023-11-11 C#/.NET开发问题
14