0

tlbExp.exeを使用して C#から呼び出そうとしていますProcess.Start。コマンド文字列を引数として渡しますが、その文字列の種類に関係なく、常にエラー メッセージが表示されます。

The system cannot find the file specified

   at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start(String fileName)

デバッグ中にコマンド ウィンドウでコマンド文字列を個別に実行しようとすると、本来の動作 (dll から生成された tlb) が実行されます。ただし、コードから機能させることはできません。

string tlb;
...
tlb += @"C:\Program files\Microsoft SDKs\Windows\v6.0A\bin\tlbExp.exe";
tlb += @""""; tlb += @" """; tlb += outputDllPath;
tlb += @""" /out:"""; tlb += outputTlbPath; tlb += @"""";
Process.Start(tlb); 
4

1 に答える 1

2

ProcessStartInfoオブジェクトを受け入れるオーバーロードを使用する必要があります。

var programPath = @"""C:\Program files\Microsoft SDKs\Windows\v6.0A\bin\tlbExp.exe""";
var info = new ProcessStartInfo(programPath);
info.Arguments = string.Format("\"{0}\" /out:\"{1}\"", outputDllPath, outputTlbPath);

Process.Start(info);

一般的にするには、最初の行を次のように変更します。

var programFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
var programPath = string.Format("\"{0}\"", Path.Combine(programFiles, @"Microsoft SDKs\Windows\v6.0A\bin\tlbExp.exe"));
于 2012-12-10T11:41:21.783 に答える