如何在不使用Imports的情况下包含“System.io”库

时间:2013-12-19 05:50:07

标签: vb.net io pipe

我的客户端工作站在访问此程序之前已确认已安装框架4.0,但它返回如下错误。有人可以说明如何解决这个问题。

有关调用的详细信息,请参阅此消息的结尾 实时(JIT)调试而不是此对话框。

************** Exception Text **************
System.UnauthorizedAccessException: Access to the path is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.Pipes.NamedPipeClientStream.Connect(Int32 timeout)
at System.IO.Pipes.NamedPipeClientStream.Connect()
at WindowsApplication1.Form1.Form1_Load(Object sender, EventArgs e) in  C:\Client_Pipe(New)\Client_Pipe(New)\client(new).vb:line 9
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

在System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)

我的代码如下:

Imports System.IO

Public Class Form1
Dim clientpipe As System.IO.Pipes.NamedPipeClientStream


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    clientpipe = New System.IO.Pipes.NamedPipeClientStream("192.168.1.1", "soohhead", Pipes.PipeDirection.InOut, Pipes.PipeOptions.None)
    clientpipe.Connect()

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim len As String, recLen As String = 0
    Dim testString() As Byte = System.Text.Encoding.GetEncoding("windows-1256").GetBytes(Me.TextBox1.Text)
    Dim recBytes(1000) As Byte, rec

    len = testString.Length

    clientpipe.WriteByte(len)

    ReDim Preserve testString(0 To len)

    clientpipe.Write(testString, 0, len)

    recLen = clientpipe.ReadByte()

    ReDim Preserve recBytes(0 To recLen)

    clientpipe.Read(recBytes, 0, recLen)

    rec = System.Text.ASCIIEncoding.ASCII.GetString(recBytes)

    rec = Mid(rec, 1, recLen)
    MsgBox("check received line Number :" & rec & " at Length: " & recLen)

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)   Handles Button2.Click

    clientpipe.Close()

End Sub
End Class

我无法通过客户端计算机执行此程序,但它只会抛出异常处理的错误消息。感谢适合任何帮助。

0 个答案:

没有答案