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
Related
Command line:
mcs -out:Test.exe *.cs
Error:
error cs0246: The type or namespace name 'Newtonsoft' could not be found. Are you missing an assemly reference
I have tried to compile a C# code that has line - " using Newtonsoft.Json; ",
because I want to use JSON commands inside, from that I know, I have to install JSON files or add it to the project. Yea, in Microsoft Visual Studio i would have just add it to the project and it's working. My question is how do I do that on Ubuntu using Terminal only? I have installed mono-complete. (To be exact - VPS, so I can compile a code anytime on my phone.) Code is for learning purposes. I just want to know how do I make the JSON repository/assembly or whatever it's called working using mcs command.
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.
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 trying to run a C# console application on my server which is running Ubuntu Server 12.04. I have installed Mono JIT version 2.10.8.1 (Debian 2.10.8.1-1ubuntu2.2) and additional packages like gmcs and MonoDevelop. The file that I am trying to execute is called Program.cs and when I run the command $gmcs Program.cs I get the following errors:
error CS0234: The type or namspace name 'Tasks' does not exist in the namespace 'system.Threading'. Are you missing assembly reference?
error CS0246: The type or namespace name 'MySql' could not be found. Are you missing a using directive or an assembly reference?
error CS0246: The type or namespace name 'MySqlConnection' could not be found. Are you missing a using directive or an assembly reference?
I have researched into referencing the .dll files for the above namespaces but have not been able to find an answer that is clear. Most forum links suggest that I install mono - trunk, but I want to know if I should uninstall the existing mono package and then install mono-trunk.
I am new to the Unix platform and researching every step of my way. Your help will be much appreciated.
If you are compiling from the command line, you will need to pass the referenced assemblies as a series of /r or /pkg switches, such as:
mcs /r:MySql.Data.dll Program.cs
Obviously you will need to have the required assemblies installed too.
Also note that gmcs is an (old) alias for the .net 2.0 compiler, that's why it doesn't see System.Threading.Tasks (which is a .net 4 feature). See the -sdk switch of mcs.
You should probably install monodevelop to have a user-friendly IDE to help you.
I am pretty new to mono and C# so this is probably a simple question, but i cannot find the answer.
I need to compile a C# visual studio console application on my mac. I thought mono would be right for that purpose. I don't know which file to compile and took program.cs (where my main function is) or should i compile Project.csproj.
When i run
gmcs Program.cs
I get
Program.cs(17,16): error CS0246: The type or namespace name `Oplossing' could not be found. Are you missing an assembly reference?
Program.cs(129,54): error CS0246: The type or namespace name `Order' could not be found. Are you missing an assembly reference?
What en how should i compile?
Via xbuild, you should be able to compile csproj directly,
http://www.mono-project.com/Microsoft.Build
Unless you are working on a system without a ui, (since you are targetting macos you have a ui) download and install Monodevelop and open the visual studio project with that.
Otherwise check the (g) mcs documentation
The way to use it is already in te comments here
Note: you do NOT have to recompile your app on MacOs to run it on MacOS, just copy the exe (assembly) to your mac and execute it with mono