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#代码时如何使用引用
基础教程推荐
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- SSE 浮点算术是否可重现? 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 如何激活MC67中的红灯 2022-01-01