Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding assembly references for compiling with developement console

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.

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;

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?)

like image 311
Texadecimal Avatar asked Jun 12 '26 06:06

Texadecimal


1 Answers

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

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"

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.

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

like image 50
Optimax Avatar answered Jun 13 '26 18:06

Optimax