添加程序集引用以使用开发控制台进行编译 [英] Adding assembly references for compiling with developement console

查看:26
本文介绍了添加程序集引用以使用开发控制台进行编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 System.Numerics 编译文件,但我必须添加程序集引用.长话短说 Visual Studio 无法正常工作,现在在开发命令提示符中进行编译不再那么简单.我该怎么做才能让程序集参考为命令提示符工作.我一直在寻找,但我发现的只是如何在 Visual Studio 中添加引用.

I'm trying to compile a file using System.Numerics but I have to add the assembly reference. Long story short Visual Studio isn't working and it's now less simply problematic to do the compiling in the Dev Command Prompt. What would I have to do get the assembly reference working for the command promt. I've been looking but all I've found was how to add the reference in Visual Studio.

编译器版本为 Microsoft (R) Visual C# Compiler version 2.2.0.61624开头的using语句如下

The compiler version is Microsoft (R) Visual C# Compiler version 2.2.0.61624 The using statements in the beginning are as follows

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Task;

using System.Numerics;

错误代码是:Ctst2.cs(7,14):错误 CS0234:命名空间System"中不存在类型或命名空间名称Numerics"(您是否缺少程序集引用?)

The error code is: Ctst2.cs(7,14): error CS0234: The type or namespace name 'Numerics' does not exist in the namespace 'System' (are you missing an assembly reference?)

推荐答案

我将假设您正在尝试使用命令行 C# 编译器 csc.exe.

I am going to assume that you are trying to use the command-line C# compiler csc.exe.

如果您键入 csc.exe/?,编译器将显示所有可用选项的列表.其中,您会发现 -reference 选项允许您在命令行中添加程序集引用.

If you type csc.exe /? the compiler will show you the list of all available options. Among them, you will find the -reference option that allows you to add assembly references on the command line.

例如,在您的特定情况下:

Example, in your specific case:

csc Ctst2.cs -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.Numerics.dll"

上面是一个很长的命令行,你可以输入到最后而不按 [enter].您可能需要更改 System.Numerics.dll 的路径以对应于您的 .NET Framework 版本.

The above is all one long command line that you would type without hitting [enter] until the very end. You may have to change the path to System.Numerics.dll to correspond to your version of the .NET Framework.

另外,看看https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/reference-compiler-option 深入讨论 -reference 选项.

Also, take a look at https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/reference-compiler-option for an in-depth discussion of the -reference option.

这篇关于添加程序集引用以使用开发控制台进行编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆