1

皆さん、

コードの前半でShell( "LPR -P"&IP& "-S"&IP& "c:\ label.txt"、AppWinStyle.Hide)を使用して、印刷物をプリンターに送信していました。突然動作を停止しました。ファイルが見つからないというエラーが発生し始めました。次に、コードを以下に変更しましたが、まだ表示されません。今、私は次のエラーを取得しています

System.ComponentModel.Win32Exceptionがキャッチされました
ErrorCode=-2147467259メッセージ=システムは、指定されたファイルを見つけることができませんNativeErrorCode = 2 Source = System StackTrace:at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)at System.Diagnostics.Process.Start() I:\ Visual Studio 2010 \ Projects \ xxxxxx \ ScanInSn.vb:line 201 InnerException:のxxxxxx.LPRProcess(String pstrFilePath、String pstrQueue、String pstrPrinter)

新しいコード

 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を使用)

4

1 に答える 1

1

Visual Studio Project Prppertiesの設定を変更することで、この問題を解決しました。

VisualStudio>プロジェクト>プロパティ>コンパイル>ターゲットCUP。

設定を「AnyCPU」に変更します。

64ビットに設定されました。

トムとスティーブに助けてくれてありがとう。

于 2013-07-03T09:21:50.693 に答える