1

Folks,

I was using Shell("LPR -P " & IP & " -S " & IP & "c:\label.txt", AppWinStyle.Hide) in my code earlier in my code to send print to printer. suddenlt it stopped working. i started getting file not found error. then i chanegd my code to below, but still no show. now i an getting the following error

System.ComponentModel.Win32Exception was caught
ErrorCode=-2147467259 Message=The system cannot find the file specified NativeErrorCode=2 Source=System StackTrace: at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at xxxxxx.LPRProcess(String pstrFilePath, String pstrQueue, String pstrPrinter) in I:\Visual Studio 2010\Projects\xxxxxx\ScanInSn.vb:line 201 InnerException:

New code

 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 

Any ideas? (using .net 4.0)

4

1 回答 1

1

通过更改 Visual Studio 项目 Prpperties 中的设置解决了该问题。

Visual Studio > 项目 > 属性 > 编译 > 目标 CUP。

将设置更改为“AnyCPU”。

它被设置为 64 位。

谢谢汤姆和史蒂夫的帮助..

于 2013-07-03T09:21:50.693 回答