.NET 개발/C#
NamedPipeClientStream 에러 : System.UnauthorizedAccessException
Hoya0415
2015. 11. 17. 09:20
NamedPipeServerStream와 NamedPipeClientStream Pipe 로 연결 시 에러가 낫다.
테스트 환경에서 에러가 나지 않았는데 왜 그럴까..
구글링을 통해 찾아냈고, 먼저 찾아내신 개발자 분이 계셔서 기록을 남기게 되었다.
클라이언트쪽에서 연결시 에러가 났는데, 서버쪽 코드는 아래와 같다.
1 2 3 4 5 | var pipeServer = new NamedPipeServerStream(pipeName, PipeDirection.In, numThreads); var threadId = Thread.CurrentThread.ManagedThreadId; pipeServer.WaitForConnection(); | cs |
PipeDirection.In 으로 한 이유는 서버쪽에서는 클라이언트에게 데이터를 넘길 필요가 없어서였다.
그런데 양쪽 방향으로 해줘야 연결이 된다..
1 2 3 | var pipeServer = new NamedPipeServerStream(pipeName, PipeDirection.InOut, numThreads); var threadId = Thread.CurrentThread.ManagedThreadId; pipeServer.WaitForConnection(); | cs |
이건 단지 해결방법이었고, 원인은 추가적으로 올릴 기회가 있으면 올리겠습니다.~
출처 : http://adventuresindevelopment.blogspot.kr/2008/07/named-pipes-issue-systemunauthorizedacc.html