1
我正在测试使用COM端口的应用程序。该应用程序在Virtual PC中运行。我已经设置了虚拟PC设置,以使用命名管道\。\ pipe \ mypipe作为COM1-Port。与虚拟PC的COM端口通信
现在我正在尝试使用C#与此命名管道进行通信。
using (var pipe = new NamedPipeServerStream(@"\\.\pipe\mypipe"))
{
pipe.WaitForConnection();
using (var reader = new StreamReader(pipe))
{
// Do some communication here
}
}
尽管Virtual PC正在运行,并且我正在尝试与COM端口通信,但程序正在等待WaitForConnection()。
我也试过以下内容,因为我不确定是否必须在我的程序中创建命名管道,或者命名管道是由Virtual PC创建的。
var p = new NamedPipeClientStream(@"pipe\mypipe");
p.Connect();
我在做什么错在这里?
谢谢!那样做了。虽然沟通仍然无法正常工作。也许你也知道这里的答案? http://stackoverflow.com/questions/4907079/com-port-communication-with-virtual-pc-part-2 – PetPaulsen 2011-02-05 13:24:11