此代码在我的 WP8 应用程序中运行良好:
void App_UnhandledException(object sender, UnhandledExceptionEventArgs args)
{
string appName;
string appVersion;
var xmlReaderSettings = new XmlReaderSettings
{
XmlResolver = new XmlXapResolver()
};
using (var xmlReader = XmlReader.Create("WMAppManifest.xml", xmlReaderSettings))
{
xmlReader.ReadToDescendant("App");
appName = xmlReader.GetAttribute("Title");
appVersion = xmlReader.GetAttribute("Version");
}
WAMS_EXCEPTIONLOG wamsel = new WAMS_EXCEPTIONLOG
{
appNameAndVersion =
string.Format("{0} {1}", appName,
appVersion),
ExceptionMsg =
args.ExceptionObject.Message,
InnerException =
args.ExceptionObject
.InnerException.ToString(),
ExceptionToStr =
args.ExceptionObject.ToString(),
dateTimeOffsetStamp =
DateTimeOffset.UtcNow
};
await MobileService.GetTable<TASLS_WAMS_EXCEPTIONLOG>().InsertAsync(wamsel);
}
...但在我的补充 Windows 商店应用程序中,几个班级和班级成员无法识别,即:
XmlResolver
XmlXapResolver
args.ExceptionObject
(更不用说不允许等待的事实,并且将“异步”添加到事件处理程序会导致事件处理程序的分配“变红”)......
那么,回到重点:如何通过 Windows Store 应用程序实现与 WP8 应用程序相同的功能?