- Home /
convert c# code for unity return errors
I try to run c# in unity but I got errors:
error CS0234: The type or namespace name
Pipes' does not exist in the namespace
System.IO'. Are you missing an assembly reference?error CS0234: The type or namespace name
Unix' does not exist in the namespace
Mono'. Are you missing an assembly reference?
How I can to convert the code to something that run on Unity? code:
using System;
using System.IO;
using System.IO.Pipes;
using System.Net;
using System.Net.Sockets;
using System.Xml;
#if __MonoCS__
using Mono.Unix;
#endif
namespace Mumble {
public class Mumble {
protected NamedPipeClientStream pipe;
protected StreamReader sr;
protected StreamWriter sw;
public Mumble() {
#if __MonoCS__
Socket s = new Socket(AddressFamily.Unix, SocketType.Stream, 0);
UnixEndPoint ue = new UnixEndPoint(Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + "/.MumbleSocket");
s.Connect(ue);
NetworkStream pipe = new NetworkStream(s);
#else
pipe = new NamedPipeClientStream("Mumble");
pipe.Connect();
#endif
sr = new StreamReader(pipe);
sw = new StreamWriter(pipe);
}
private bool OutputStringReply() {
String line;
while ((line = sr.ReadLine()) != "") {
Console.WriteLine(line);
}
return true;
}
private bool ReadReply() {
bool reply;
using (XmlReader xr = XmlReader.Create(sr)) {
xr.MoveToContent();
xr.ReadToDescendant("succeeded");
reply = xr.ReadElementContentAsBoolean();
}
return reply;
}
public bool Mute(bool state) {
sw.WriteLine("<self mute='{0}' />", state);
sw.Flush();
return ReadReply();
}
public bool Deaf(bool state) {
sw.WriteLine("<self deaf='{0}' />", state);
sw.Flush();
return ReadReply();
}
public bool Focus() {
sw.WriteLine("<focus />");
sw.Flush();
return ReadReply();
}
public bool OpenUrl(String url) {
Uri u;
Uri.TryCreate(url, UriKind.Absolute, out u);
sw.WriteLine("<url><href>{0}</href></url>", u);
sw.Flush();
return ReadReply();
}
public String QueryUrl() {
sw.WriteLine("<url />");
sw.Flush();
String reply;
using (XmlReader xr = XmlReader.Create(sr)) {
xr.MoveToContent();
xr.ReadToDescendant("href");
reply = xr.ReadString();
}
return reply;
}
/*
public static void Main(String[] args) {
Mumble m = new Mumble();
m.Deaf(true);
}
*/
}
}
I have same problem, anyone know reply? I have windows 8
Answer by Bunny83 · Apr 01, 2012 at 03:04 AM
Just take a look on the MonoCompatibility page to see what namespaces and / or classes are supported on which platforms. The page is huge and my take a while to fully load. You your browsers search function to fine a specific namespace.
The error speaks for itself. Those two namespaces are not supported in Unity, so you can't use this code (which wasn't written for Unity) in Unity. Yes you can find alternatives, but that's not our job...
Answer by Inhuman Games · Apr 08, 2013 at 08:58 AM
For "using System.IO.Pipes" you first must change this setting:
Project Settings->Player->Api Compatibily Level: set this to ".Net 2.0" (not subset).
Pipes and other rarely used stuff are removed by default, probably as a disk space optimization.
Your answer
![](https://koobas.hobune.stream/wayback/20220612123036im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Conversion help - c# to javacript 1 Answer
Convert this from JavaScript to C# 1 Answer
Cannot implicitly convert type string to list - Why is this? 1 Answer