我已经实现了代码(Elmah Everywhere)来捕获Silverlight-4中的Unhandled异常,如下面的链接所示
https://github.com/vincoss/vinco-logging-toolkit
我还下载了代码示例表单链接,但是,我无法找到存储未处理异常的地方。
我已经在asp.net中实现了Elmah,我们通常可以在domainname / elmah.axd上看到所有未处理的异常(如web.config中所示)。
请帮助我找到所有未处理的异常存储在silverlight中的地方。
或者任何人都可以向我建议任何可以达到同样效果的图书馆。
提前致谢
答案 0 :(得分:2)
Silverlight中引发的异常存储在数据库中。请查看文档如何配置Silverlight异常处理。
您可以在项目文件夹“Vinco.Elmah.Everywhere \ Source \ ErrorWebSite \ App_Data \ Elmah.Everywhere.mdf”中找到该数据库。
将此数据库附加到MS SQL Server。
Elmah.Everywhere代码库最近更新了新功能和更好的样本。
请尝试运行示例,然后浏览此
上的已记录错误网址:http:// localhost:11079 / elmah
注意:Elmah.Everywhere日志旨在将错误记录到远程站点。要获得Elmah.Everywhere日志的全部好处,请创建一个网站,或者从将记录错误的示例中使用现有的“ErrorWebSite”。这允许您有多个项目将错误记录到中央数据库中。只需在ExceptionDefaults中更改ApplicationName即可区分不同的项目。
示例Silverlight配置
您可以配置错误日志记录,如以下示例所示。
private static void SetUpExceptionHandler()
{
Uri uri = Application.Current.Host.Source;
string currentHost = string.Format("{0}{1}{2}:{3}", uri.Scheme, Uri.SchemeDelimiter, uri.Host, uri.Port);
// Configure
var writter = new ClientHttpExceptionWritter
{
// NOTE: Possible to pass URI by startup arguments.
RequestUri = new Uri(string.Format("{0}/error/log", currentHost), UriKind.Absolute)
};
var defaults = new ExceptionDefaults
{
Token = "Silverlight-Test-Token",
ApplicationName = "Silverlight-Sample",
Host = string.Format("{0}{1}{2}:{3}", uri.Scheme, Uri.SchemeDelimiter, uri.Host, uri.Port)
};
ExceptionHandler.Configure(writter, defaults);
}
在Application构造函数调用处理程序设置方法中。
public App()
{
SetUpExceptionHandler();
}
将处理程序日志添加到Application_UnhandledException方法
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
ExceptionHandler.Report(e.ExceptionObject, null);
}
此配置将针对Silverlight主机URL记录错误。确保您在bin文件夹中有Elmah.Everywhere.dll,Elmah.dll以及Web.config文件中的配置详细信息。
要在浏览器中查看错误,请参阅“ErrorWebSite”示例。网址应如下所示。 http://yourdomain.com/elmah
有关详细信息,请参阅提供的样本。