【发布时间】:2012-12-31 12:45:10
【问题描述】:
这段代码在我的 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
(更不用说 await 是不允许的,在事件处理程序中添加“async”会导致事件处理程序的分配“变红”)...
所以,回到重点:我如何才能通过我的 WP8 应用程序和我的 Windows 应用商店应用程序实现相同的功能?
【问题讨论】:
标签: c# exception-handling xml-parsing windows-phone-8 windows-store-apps