我写了一个.aspx网页来测试我的网络服务。 Web服务将调用外部exe来进行加密。
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "pgp.exe";
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.Start();
pgp.exe可以成功启动。但在以下
发生例外try
{
BinaryWriter inBinWriter = new BinaryWriter(p.StandardInput.BaseStream);
inBinWriter.Write(PlainText);
inBinWriter.Flush();
inBinWriter.Close();
}
catch (Exception e)
{
m_evt.WriteEntry("PGP Encrypt: Cannot Stream the Plain Text into PGP, " + m_pgpExecutable + " " + pgpEncryptCommand + ":" + e.ToString(), EventLogEntryType.Error);
m_evt.WriteEntry(PlainText.Length.ToString(), EventLogEntryType.Error);
throw new PGPException(PGPErrorCode.PGPProcessError, e.Message);
}
事件日志显示:
PGP Encrypt: Cannot Stream the Plain Text into PGP, pgp.exe :System.IO.IOException: The pipe has been ended.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.WriteCore(Byte[] buffer, Int32 offset, Int32 count)
at PGPServer.PGPWrapper.doEncrypt(String UserName, String ChannelName, Byte[] PlainText, Byte[]& CipherText, String SenderName) in ...
我得到的全部,我不知道会发生什么,任何帮助都会受到赞赏!谢谢!