私の標準的な免責事項:私はこの製品の開発者です。
私が働いている会社(PreEmptive Soltutions)によって作成された製品(Runtime Intelligence)を使用すると、エラーレポートだけでなく、ユーザーがアプリケーションを使用している時期と、最小限のコーディングで使用している機能を追跡する機能も注入できます。
Dotfuscatorを使用してコードインジェクション(またはILウィービング)を実行し、アプリケーションバイナリに新しいコードを挿入して、使用状況データを施設でホストされているサーバー(またはオプションで他の任意のURL)に送り返します。あなたが私たちにデータを送るならば、私たちはあなたに多くの強力な分析ツールと使用法に関するレポートを提供します。
この機能の基本バージョンは、Visual Studio 2010に含まれ、無料のデータレポートポータルにアクセスできます(ただし、SLA、データ保持の保証、またはデータのプライバシーはありません)。
使用情報とともに任意のデータを送り返す機能は商用製品に限定されていますが、完全に機能する無料の時間制限付き評価バージョンについては、PreEmptiveSoltutionsにお問い合わせください。
以下のサンプルコードを使用して、エラー報告を実行できます。
public partial class app : Application {
// field to temporarily store exception data
private Exception exp;
void AppStartup(object sender, StartupEventArgs args) {
// add a handler to catch any unhandled exceptions
this.DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(ErrorHandler);
Window1 mainWindow = new Window1();
mainWindow.ShowDialog();
}
// this will prompt the user if they want to report the exception
void ErrorHandler(object sender, DispatcherUnhandledExceptionEventArgs e) {
this.exp = e.Exception;
if (MessageBox.Show("A " + exp.Message + " exception happened, should I report it?", "Error Occurrend", MessageBoxButton.YesNo) == MessageBoxResult.Yes) {
ErrorHappened();
e.Handled = true;
}
}
// this method is called by the above ErrorHandler method and when run through Dotfuscator additional code will be injected into this method that will send a usage data message back to the server and the data in the dictionary (which will be exception data) returned by the ErrorData method will be included into the message and be stored and reported on the server
[Feature("Exception", EventType = FeatureEventTypes.Tick, ExtendedKeySourceElement = SourceElements.Method, ExtendedKeySourceName = "ErrorData")]
private void ErrorHappened() {
// This is here as a placeholder for the exception feature attribute which will exit the application when executed
AppShutdown(true);
}
// this method takes the exception data from the exp field and returns it as a dictionary of name/value pairs
public Dictionary<string, string> ErrorData() {
var retval = new Dictionary<string,string>();
if (null != exp) {
retval.Add("Error Message",exp.Message);
retval.Add("Stack Trace",exp.StackTrace);
}
return retval;
}
}