民间,
我正在使用 Shell(“LPR -P”& IP&“-S”& IP&“c:\ label.txt”,AppWinStyle.Hide) 在我的代码中我的代码中将打印发送到打印机。突然间它停止了工作。我开始收到文件未找到错误。然后我把我的代码交给下面,但仍然没有显示。现在我得到以下错误发现了System.ComponentModel.Win32Exception ErrorCode = -2147467259 Message =系统找不到该文件 指定NativeErrorCode = 2 Source = System StackTrace:at System.Diagnostics.Process.StartWithCreateProcess(的ProcessStartInfo startInfo)在System.Diagnostics.Process.Start()at xxxxxx.LPRProcess(String pstrFilePath,String pstrQueue,String ps:\ Visual Studio 2010 \ Projects \ xxxxxx \ ScanInSn.vb中的pstrPrinter:行 201 InnerException:
新代码
Private Function LPRProcess(ByVal pstrFilePath As String, ByVal pstrQueue As String, ByVal pstrPrinter As String)
Dim prcLprInfo As New ProcessStartInfo
prcLprInfo.FileName = "Lpr"
prcLprInfo.CreateNoWindow = True
prcLprInfo.WindowStyle = ProcessWindowStyle.Hidden
prcLprInfo.UseShellExecute = False
prcLprInfo.RedirectStandardOutput = True
prcLprInfo.Arguments = "-S " & pstrPrinter & " -P " & pstrQueue & " """ & pstrFilePath & """"
Dim prcLpr As New Process
Dim strOutput As String
Try
'Stage = "Run Process.Start( )"
prcLpr.StartInfo = prcLprInfo
prcLpr.Start()
strOutput = prcLpr.StandardOutput.ReadToEnd()
'Stage = "Process started, wait for it to exit"
If Not prcLpr.HasExited Then prcLpr.WaitForExit()
Catch ex As Exception
Throw New Exception("Error running LPR process: " & ex.Message)
Finally
prcLpr.Close()
prcLpr.Dispose()
End Try
If strOutput.Length > 0 Then
Throw New Exception("LPR ERROR: " & strOutput)
End If
End Function
有什么想法吗? (使用.net 4.0)
答案 0 :(得分:0)
通过更改Visual Studio Project Prpperties中的设置解决了该问题。
Visual Studio>项目>属性>编译>目标CUP。
将设置更改为“AnyCPU”。
设置为64位。
谢谢Tom和Steve的帮助..