gpt4 book ai didi

c# - 启用浏览器外的 Silverlight 会中断浏览器内的应用程序

转载 作者:太空宇宙 更新时间:2023-11-03 16:43:33 26 4
gpt4 key购买 nike

我目前正在 Silverlight 中开发一个小型应用程序,最近为了试用它,我为我的应用程序启用了浏览器外部署。但是,现在在我禁用该设置后,运行应用程序现在会在加载完成后立即抛出异常。

未处理的异常('silverlight 应用程序中的未处理错误代码:4004类别:ManagedRuntimeError消息:System.Reflection.TargetInvocationException:操作期间发生异常,导致结果无效。

但是,如果我只是在浏览器中打开 TestPage.html,应用程序仍然可以正常工作。

有什么想法吗?谢谢

最佳答案

例如,尝试在 App.Xaml.cs(App.Xaml 的代码隐藏)的 Application_UnhandledException 方法中输入以下行“MessageBox.Show(e.ExceptionObject.Message);”。这可以让您了解当调试器尚未连接到浏览器时出了什么问题。购买方式,在 Visual Studio 中,您可以在调试菜单中手动将调试器附加到浏览器 -> 附加到进程...,然后选择类型为“Silverlight,x86”的进程。

    private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
MessageBox.Show(e.ExceptionObject.Message);
// If the app is running outside of the debugger then report the exception using
// the browser's exception mechanism. On IE this will display it a yellow alert
// icon in the status bar and Firefox will display a script error.
if (!System.Diagnostics.Debugger.IsAttached)
{

// NOTE: This will allow the application to continue running after an exception has been thrown
// but not handled.
// For production applications this error handling should be replaced with something that will
// report the error to the website and stop the application.
e.Handled = true;
Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); });
}
}

关于c# - 启用浏览器外的 Silverlight 会中断浏览器内的应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6664466/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com