How to reference these packages with Mono in order to compile - c#

I'm trying to compile a C# script with Mono on Debian by command line, like this:
gmcs Main.cs
However, I get the following error:
Main.cs(6,14): error CS0234: The type or namespace name `Drawing' does not exist in the namespace `System'. Are you missing an assembly reference?
Main.cs(7,14): error CS0234: The type or namespace name `Drawing' does not exist in the namespace `System'. Are you missing an assembly reference?
Main.cs(12,7): error CS0246: The type or namespace name `iTextSharp' could not be found. Are you missing a using directive or an assembly reference?
Main.cs(13,7): error CS0246: The type or namespace name `iTextSharp' could not be found. Are you missing a using directive or an assembly reference?
Main.cs(1526,31): error CS0246: The type or namespace name `Bitmap' could not be found. Are you missing a using directive or an assembly reference?
Main.cs(6,14): error CS0234: The type or namespace name `Drawing' does not exist in the namespace `System'. Are you missing an assembly reference?
Main.cs(7,14): error CS0234: The type or namespace name `Drawing' does not exist in the namespace `System'. Are you missing an assembly reference?
Main.cs(12,7): error CS0246: The type or namespace name `iTextSharp' could not be found. Are you missing a using directive or an assembly reference?
Main.cs(13,7): error CS0246: The type or namespace name `iTextSharp' could not be found. Are you missing a using directive or an assembly reference?
Compilation failed: 9 error(s), 1 warnings
These the references at the top of Main.cs:
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using iTextSharp.text;
using iTextSharp.text.pdf;
I understand that I have to tell Mono which libraries to include by adding -pkg:whatever. My problem is that I do not know what these libraries are called, so I don't know what command is used to include them. Actually, I don't even know whether I have to download these libraries from somewhere or whether they come with Mono.
Note also that the last 2 are the iTextSharp library, for which I have itextsharp.dll just placed in the same directory as the script, since I don't know what else to do with it.
Please could someone explain to me how to get the file to compile!

Try this:
gmcs /reference:System.Drawing.dll /reference:itextsharp.dll Main.cs
With newer versions of mono, try this.
mcs /reference:System.Drawing.dll /reference:itextsharp.dll Main.cs

Here's another solution that's worked for me in a similar case where I got this error:
Eventdemo.cs(2,14): error CS0234: The type or namespace name `Drawing' does not exist in the namespace `System'. Are you missing `System.Drawing' assembly reference?
Eventdemo.cs(3,14): error CS0234: The type or namespace name `Windows' does not exist in the namespace `System'. Are you missing an assembly reference? │
Eventdemo.cs(8,19): error CS0246: The type or namespace name `Form' could not be found. Are you missing an assembly reference?
I had those references in my program:
using System;
using System.Drawing;
using System.Windows.Forms;
I got the solution from ubuntuforums:
gmcs -pkg:dotnet *.cs

I got this error, and when I just needed to use System.Net.Http, I used:
$mcs /reference:System.Net.Http.dll Program.cs
and it worked fine for me. When I tried to include the full path to System.Net.Http.dll, it didn't work. That is to say, heads up, mono keeps track of paths. Also, I have the latest version of mono.

Related

Xamarin.Essentials "The type or namespace name 'UsesPermission' could not be found are you mission a using directive or an assembly reference?

using Xamarin.Forms.Xaml;
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Essentials;
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
[assembly: UsesPermission(Android.Manifest.Permission.Vibrate)]
It seems the last line of code is not working, however after reading this > https://learn.microsoft.com/en-us/xamarin/essentials/vibrate?tabs=android. It states that all I have to add is the last line to my AssemblyInfo.cs file. Not sure how to fix it. It states that im required to add the last line for any android device. However it seems that it does not recognize the UsesPermission. How can I fix this?
Here is the actual error:
Error CS0246 The type or namespace name 'UsesPermissionAttribute' could not be found (are you missing a using directive or an assembly reference?)
You are missing reference to Android.App namespace - UsesPermissionAttribute is in there. Try adding using Android.App;.

Error CS0234 The type or namespace name 'CSharp' does not exist in the namespace 'Microsoft.CodeAnalysis'

I was about to try to make runtime scripting in UI in Unity and after adding all Microsoft.CodeAnalysis and Roslyn.Compilers packages my code still isn't compiling, saying "Error CS0234 The type or namespace name 'CSharp' does not exist in the namespace 'Microsoft.CodeAnalysis' (are you missing an assembly reference?)".
What am I missing?

Fixing error The type of namespace of name 'Cloud' does not exist in the namespace 'Google'. Are you missing an assembly reference?

I'm setting up Firestore through Unity right now, and the documentation says to include
using Google.Cloud.Firestore;
in the Program.cs file. I'm getting this error however when I do so. Any idea how to fix this?
The type of namespace of name 'Cloud' does not exist in the namespace 'Google'. Are you missing an assembly reference?

The type or namespace name 'Net' does not exist in the namespace 'System'

My C# file shows 3 different errors related to missing assembly references.
I am using Xamarin studio and not sure where the references are located. The assembly browser?
Here is where the errors are:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management;
using System.Net;
using System.IO;
using System.Threading;
using System.Diagnostics;
using System.Collections.Specialized;
using Microsoft.Win32;
using System.Windows.Forms;
Errors:
Error CS0234: The type or namespace name 'Net' does not exist in the namespace 'System' (are you missing an assembly reference?) (CS0234) (class)
Error CS0234: The type or namespace name 'Specialized' does not exist in the namespace 'System.Collections' (are you missing an assembly reference?) (CS0234) (class)
Error CS0234: The type or namespace name 'Windows' does not exist in the namespace 'System' (are you missing an assembly reference?) (CS0234) (class)
Try to eliminate the errors by adding references one by one. If the error is thrown try to right click on the References in your project in Solution Explorer and add reference which seems to match to the one which causes error. If this won't help the cause is somewhere else, then post more data about the problem.
I don't know if you're still having this problem, but I fixed a similar issue (System.Collections.Specialized does not exist) in Xamarin Studio 6.3 by adding a reference to System through the Edit References dialog.
1_Go to your error giving project.
2_Right click>Add>Reference.
3_Search for 'Net' in Reference Manager window.
4_Find "System.Net" check the box right left to it and click OK.
I use visual studio 2019
when I get this errors,
the fixes is this
1)go to solution explorer. 2) right click on your solution. 3) Add. 4) Reference... 5) In reference manager window search for System.Net 6) check the box. 7) OK
This worked for me.
1
2
3
4
5

Using XDocument in XNA on Windows Phone

I have some perfectly working code using XDocument, XMLWriter etc but when I try to add it to my XNA 4.0 game it doesn't work.
I get the following compilation errors, even though I have all the required references referenced and usings used as shown here:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.IO;
The type or namespace name 'XmlTextWriter' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'XmlNodeList' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'XmlDocument' could not be found (are you missing a using directive or an assembly reference?)
Any help?
If you developing a Windows Store App, you may want to check the following thread...
How to rectify Namespace errors in a Windows Store class library in Windows 8 and Visual Studio 2012?

Categories

Resources