How to use references when compiling c# code via command line(通过命令行编译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#代码时如何使用引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:通过命令行编译c#代码时如何使用引用
基础教程推荐
- C# 从 List<List<int>> 中删除重 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- WPF 模态进度窗口 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
