Труба закрыта исключением ⇐ C#

Место общения программистов C#
Anonymous
Труба закрыта исключением

Сообщение Anonymous »

Иногда на некоторых машинах клиенты, которые используют мою программу, получают исключение «труба». Это происходит на именованном виде, который находится на .waitforConnection (). После этого приложение полностью вылетает и выпускает исключение Windows. Это происходит, когда именованная именная информация передает информацию в автономное приложение. Автономное приложение также имеет именованное именное средство.
Панель инструментов и стартер. Служба тогда с автономным приложением. На каждом названном pipipeclientSteam я делаю WaitForpipeDrain, если Pipeclient.ISCONNED BE FOR IS IS COMIPLIET .. < /p>
Спасибо за помощь < /p>
РЕДАКТИРОВАТЬ: Здесь пример клиента < /p>
using (NamedPipeClientStream pipeClient =
new NamedPipeClientStream(".", pipename, PipeDirection.Out))
{
// Wait for a client to connect
try
{
pipeClient.Connect(3000);

// send params to the form
using (StreamWriter sw = new StreamWriter(pipeClient))
{
sw.AutoFlush = true;
sw.WriteLine(sendtext);
}
}
// Catch the IOException that is raised if the pipe is
// broken or disconnected.
catch (Exception e)
{
if (sid != "")
{
connections.Remove(conName);
}
eventLog1.WriteEntry("SendText Fehler 1 " + e.Message);
}
finally
{
if (pipeClient.IsConnected)
{
pipeClient.WaitForPipeDrain();
}
pipeClient.Close();
pipeClient.Dispose();
}
< /code>
Пример трубопровода (который работает в потоке Seperad) < /p>
NamedPipeServerStream pipeServer;
PipeSecurity pipe_security = CreateSystemIoPipeSecurity();
do
string pipename = global::TOfficeCenter.Properties.Settings.Default.pipename;
string aText = "";
pipeServer = new NamedPipeServerStream(pipename, PipeDirection.In, ONE_INSTANCE, PipeTransmissionMode.Byte,
PipeOptions.None, IN_BUF_SIZE, OUT_BUF_SIZE, pipe_security);
try
{
// Verbindung zu TOfficeCenter.exe aufbauen
try
{
IsWaiting = true;
pipeServer.WaitForConnection();
IsWaiting = false;

using (StreamReader sr = new StreamReader(pipeServer))
{
string temp;
while ((temp = sr.ReadLine()) != null)
{
aText = aText + temp;
}
}

try
{
if (aText == "")
{
empfang(null);
}
else
{
if (aText != "KillPipe")
{ // XML empfangen
XmlDocumentTC xml = new XmlDocumentTC();
xml.LoadXml(aText);
empfang(xml);
}
}
}
catch (Exception)
{
empfang(null);
}
}
catch
{...........
}
}

catch (Exception e)
{...........
}

} while (running);

pipeServer.Close();


Подробнее здесь: https://stackoverflow.com/questions/917 ... -exception

Вернуться в «C#»