1

我将SmartAssembly用于一般代码混淆以及应用程序中的错误报告。

如果我的应用程序遇到未处理的异常,我希望记录该异常,然后在没有任何用户交互的情况下终止应用程序。是否可以创建一个允许这样做的 SmartAssembly 项目?

我尝试在 SmartAssembly GUI 以及命令行中设置项目,但没有成功。下面是我尝试过的命令和参数,但到目前为止,我无法确定如何让它在没有用户输入的情况下终止应用程序并记录错误。

创建 SA 项目:

"C:\Program Files\Red Gate\SmartAssembly 6\SmartAssembly.com" 
/create shell.saproj  input=C:\Repositories\MyApp\src\shell.exe 
/output=shell.exe 
/reportappname="MyTestApp" 
/errorreportingtemplate=standard;continueonerror=false,email:"my@email.com"
/reportprojectname="Shell" 
/reportcompanyname="My Company"

构建项目:

"C:\Program Files\Red Gate\SmartAssembly 6\SmartAssembly.com" /build shell.saproj
4

2 回答 2

2

SmartAssembly includes a few examples of custom ErrorReportingTemplates,
located in Red Gate/SmartAssembly 6/SDK/Exception Reporting/

The examples are lumped into a few categories:

Without UI Standard Custom UI Via Email Secured Proxy Silverlight Silverlight Basic

In each of these folders, there is a .csproj file that one can extend to get their desired results. Inside the Without UI folder is the project we're after, titled Sample 01 - Without User Interface.csproj

If you're just after a .dll to use and don't care about a re-usable solution, edit this file directly and use the resulting .dll file (the alternative being to create a new project, and pull in the reference to SmartAssembly.SmartExceptionsCore).

Edit the OnReportException function to look like the following:

protected override void OnReportException(ReportExceptionEventArgs e)
    {
        for (int i=0; i<3; i++)
        {
            if (e.SendReport()) break;
        }
        e.TryToContinue = false;
        System.Diagnostics.Process proc = System.Diagnostics.Process.GetCurrentProcess();
        proc.Kill();
    }

Here's a Gist of the final result, if you're confused.

Create the project file with the GUI or via cmd:

"C:\Program Files\Red Gate\SmartAssembly 6\SmartAssembly.com" 
/create shell.saproj  input=C:\Repositories\MyApp\src\shell.exe 
/output=shell.exe 
/reportappname="MyTestApp" 
/errorreportingtemplate=MySmartAssemblyLogger.dll;continueonerror=false,email:"my@email.com"
/reportprojectname="Shell" 
/reportcompanyname="My Company"

Build with the GUI or via cmd:

"C:\Program Files\Red Gate\SmartAssembly 6\SmartAssembly.com" /build shell.saproj
于 2013-10-14T16:10:58.340 回答
0

根据网站http://www.red-gate.com/supportcenter/Content/SmartAssembly/help/6.7/SA_UsingTheCommandLine上的示例

您应该将“标准”替换为“自动”,并且应该在不出现用户对话框的情况下发送错误报告。

于 2013-10-11T15:00:11.140 回答