Outlook 2007と2010を対象にC#で記述されたOutlook VSTOアドインを持っているこの奇妙な状況があります。アドインは2007年の環境で正常に動作します。また、startを押すとVisual Studio(2010)のOutlook 2010でデバッグモードで正常に動作します。しかし、UATにデプロイすると、関数の1つが評価されません。関数が全く評価されない不思議なバグ
機能の1つは、
private static bool HTTPTransmitEmailItem(string username, string email_file_name)
{
// DEBUG
Utils.LogDebug("Got into HTTPTransmitEmailItem");
try
{
Stopwatch timer = new Stopwatch();
timer.Start();
try
{
Utils.LogDebug("Msg saved as : " + full_file_name_and_path);
if (HTTPPostDataToEP(username, temp_path, email_file_name))
{
File.Delete(full_file_name_and_path);
return true;
}
else
{
Utils.LogWarn("Trans Fail, Storing for later sending. " + email_file_name);
//if need start resend timer
TransmitFailed();
}
}
catch (Exception ex)
{
Utils.HandleException("OFE HHTP Ex", ex);
TransmitFailed();
}
timer.Stop();
Utils.LogDebug("Email File Thread took " + timer.ElapsedMilliseconds.ToString() + "(ms)");
}
catch (Exception ex)
{
}
return false;
}
ある犯人は一部です:
if (HTTPPostDataToEP(username, temp_path, email_file_name))
{
File.Delete(full_file_name_and_path);
return true;
}
else
{
Utils.LogWarn("Trans Fail, Storing for later sending. " + email_file_name);
//if need start resend timer
TransmitFailed();
}
アプリケーションがメソッドHTTPPostDataToEP
に入ることはありません...メソッド定義が
private static bool HTTPPostDataToEP(string username, string path, string name)
{
// DEBUG
Utils.LogDebug("Got into HTTPPostDataToEP");
try
{
var content = new MultipartFormDataContent();
content.Add(new StringContent(username), "userAddress");
content.Add(new StreamContent(File.Open(path + name, FileMode.Open)), "msg", name);
// DEBUG
Utils.LogDebug("In Line 174 in OutlookTransmitRaw");
var client = new HttpClient();
HttpResponseMessage result = client.PostAsync(Utils.configEndPoint, content).Result;
// DEBUG
Utils.LogDebug("In Line 178 in OutlookTransmitRaw. Result is " + result);
if (result.IsSuccessStatusCode)
Utils.LogDebug("Msg Transmit Response : " + result.ToString());
else
Utils.LogInfo("Msg Fail Transmit Response: " + result.ToString());
return result.IsSuccessStatusCode;
}
catch (Exception ex)
{
throw new Exception("Failed to dispatch email to API. Caused by ", ex);
}
}
ですアプリケーションは例外を発生させません。単にif
ブロックを通過して実行します。Utils.LogDebug("Email File Thread took " + timer.ElapsedMilliseconds.ToString() + "(ms)");
これは、プロジェクトを公開してset.exeファイルを使用してインストールする場合にのみ発生します。デバッグモードでは、期待どおりに動作します。
exactlyy理由を知ることは難しい、あなたの空のキャッチはあまり役に立ちません。おそらく、2番目のLogDebug 'Utils.LogDebug(" + full_file_name_and_path);という名前で保存されたメッセージは失敗しますか?次の行がなぜ実行されないのか説明できます。適切な例外処理を記述してください。 – bradbury9
'Utils.HandleException(" OFE HHTP Ex "、ex);それ以外のものは何も示していません。 TransmitFailed(); 'が実行されたか実行されていませんか?これらのメソッドのいずれかが別の例外をスローしない限り、あなたはまだ何も起こらないかのようにあなたの例外を飲み込んでいきます。 – oerkelens