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?)
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.
Related
I generate cs files ( classes ) with the same namespace (EDR_Config). After I generate them, I compile them using Developer Command Prompt for VS2012.
The command line is :
csc /target:library /out:EDR_Config.DLL AssemblyInfo.cs
EdrClassInitializator_CFG.cs EdrEquationsDecoder_CFG.cs EdrTreeCreator_CFG.cs
Everything looks great till I add a reference to the c# project. When I try to write
using EDR_Config;
it tell me: Error 1 The type or namespace name 'EDR_Config' could not be found (are you missing a using directive or an assembly reference?)
Why is that happening? Or how can I solve it?
I am still learning c# and have been following a tutorial where I use Visual Studio to connect MySQL. I want to compile the file using csc on the command line this time and error cs0246 came out6 where its ays "The type or namespace name 'MySqlConnection' could not be found (are you missing a using directive or assembly reference?)".
I am just using the command "csc MyFile.cs". I know that I should be using some form of directive but I'm not sure how to use it? In Visual Studio, all I have to do is add the MySql.Data and MySql.Data.Entity into the Reference under the project. How do I use the csc command?
csc /? contains all answers... Also covered in Working with the C# 2.0 Command Line Compiler.
Will be something like (not sure what is the name/path of assembly you need to link):
csc /reference:MySqlConnection.dll MyFile.cs
I am trying to run a C# program in linux using mono gmcs compiler. I need to include a namespace Microsoft.Boogie. I have the source code for the C# package which defines Boogie namespace. But when I try to use
using Microsoft.Boogie;
the compiler (gmcs) complains that
boogieTrace.cs(2,17): error CS0234: The type or namespace name `Boogie' does not
exist in the namespace `Microsoft'. Are you missing an assembly reference?
Compilation failed: 1 error(s), 0 warnings
Does anyone know how to include custom namespaces in a C# program?
I am attempting to build a single cs file from the command line using mcs. I am using an external library in the c# code:
using SomeLib
However, I can't find out how to specify the required library to mcs. How do I resolve this error?
The solution was to use gmcs and pass the library using the r specifier as follows:
gmcs filename.cs -r:libthirdparty
This is probably a very basic error on my part. Here's what I did:
Created a new C# Smart Device Project in Visual Studio 2008.
Added a C# project (Bouncy Castle) to this solution.
Created a dependency: my Smart Device Project depends on crypto, the Bouncy Castle project.
Added some using statements to my project:
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Security;
using Org.BouncyCastle.Utilities.Encoders;
Compiling the project gives me four CS0246 errors:
The type or namespace name 'Org' could not be found (are you missing
a using directive or an assembly reference?)
I pulled the C# code into the project directly, so I don't know what I'm missing.
Thanks!
Created a dependency
Nobody ever says that. Which I'd have to guess is the source of the problem, you "add a reference". Project + Add Reference.