我在应用程序中使用SmartAssembly进行通用代码混淆和错误报告。
如果我的应用程序遇到一个未处理的异常,我希望将异常记录下来,然后在没有任何用户交互的情况下终止应用程序。是否有可能创建一个允许这样做的SmartAssembly项目?
我尝试过在SmartAssembly图形用户界面中以及在命令行上设置这个项目,但没有成功。下面是我尝试过的命令和参数,但到目前为止,我还无法确定如何让它终止应用程序,并在没有用户输入的情况下记录错误。
创建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发布于 2013-10-14 16:10:58
SmartAssembly包含了一些自定义ErrorReportingTemplates的示例,
位于Red Gate/SmartAssembly 6/SDK/Exception Reporting/
这些例子被归纳为几个类别:
Without UI Standard Custom UI Via Email Secured Proxy Silverlight Silverlight Basic
在每个文件夹中,都有一个.csproj文件,可以对其进行扩展以获得所需的结果。在Without UI文件夹中是我们要寻找的项目,名为Sample 01 - Without User Interface.csproj
如果您只是想使用一个.dll而不关心一个可重用的解决方案,那么直接编辑这个文件并使用生成的.dll文件(另一种方法是创建一个新项目,并引入对SmartAssembly.SmartExceptionsCore的引用)。
编辑OnReportException函数如下所示:
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();
}这是最终结果的要点,如果你很困惑的话。
使用GUI或通过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"使用GUI或通过cmd构建:
"C:\Program Files\Red Gate\SmartAssembly 6\SmartAssembly.com" /build shell.saproj发布于 2013-10-11 15:00:11
根据UsingTheCommandLine网站上的例子
你应该把“标准”改为“自动”,这应该是在没有出现用户对话框的情况下发送错误报告。
https://stackoverflow.com/questions/19319997
复制相似问题