简体   繁体   English

Silverlight OOB应用程序在脱机启动时未捕获异常

[英]Silverlight OOB application uncaught exception on offline startup

I've got a Silverlight 5 application that can work in browser and out of browser. 我有一个Silverlight 5应用程序,它可以在浏览器中运行,也可以在浏览器外运行。 When run out of browser, it should be able to use previously downloaded data (XMLs and JPGs) to work without an Internet connection. 当浏览器用完时,它应该能够使用以前下载的数据(XML和JPG)在没有Internet连接的情况下工作。

Currently it works, but I've got an unhandled exception during startup (that gets caught by my Application's UnhandledException event handler) that is shown to the user with a frightening message - something like 'Internal error - the application may crash now.' 当前它可以正常工作,但是在启动过程中我遇到了一个未处理的异常(该异常被我的应用程序的UnhandledException事件处理程序捕获),并向用户显示了一条令人震惊的消息-类似于“内部错误-该应用程序现在可能崩溃”。 with optional details being 'E_UNEXPECTED'. 可选的详细信息为“ E_UNEXPECTED”。 The error occurs both on my dev machine and on others, including a client using MacOS X. 该错误在我的开发机和其他机器(包括使用MacOS X的客户端)上均发生。

Of course, I could change the message, but that's not the point. 当然,我可以更改消息,但这不是重点。

So my question: what could be causing an error only when starting offline, error which, when caught by an UnhandledException handler, doesn't seem to affect application stability? 所以我的问题是:什么仅在脱机启动时才可能导致错误,而在被UnhandledException处理程序捕获时似乎不会影响应用程序稳定性的错误呢?

I found the culprit (by logging my startup steps): it's the check for updates. 我找到了罪魁祸首(通过记录启动步骤):检查更新。

If I call Application.CheckAndDownloadUpdateAsync() when there is no connection available, I get this exception. 如果在没有可用连接时调用Application.CheckAndDownloadUpdateAsync() ,则会收到此异常。 If I check whether a connection is available(*) before launching the check for updates, the exception disappear. 如果在启动更新检查之前检查连接是否可用(*),则异常消失。

This is not documented in http://msdn.microsoft.com/en-us/library/dd730310%28VS.95%29.aspx so it looks like a bug in the Silverlight runtime. http://msdn.microsoft.com/zh-cn/library/dd730310%28VS.95%29.aspx中未记录此文件,因此它看起来像是Silverlight运行时中的错误。

(*) Based mostly on NetworkInterface.GetIsNetworkAvailable() , plus some custom checks. (*)主要基于NetworkInterface.GetIsNetworkAvailable()以及一些自定义检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM