wpf应用程序在调试模式下运行,但在没有调试的情况下不会运行

2024-03-24

我的 WPF 应用程序在 VS2015 中以调试模式成功运行。但是,在不调试的情况下启动时,应用程序启动并立即完成。从 Debug/Release 文件夹启动 exe 文件时也会发生同样的情况。 事件查看器显示以下 .Net 运行时错误:

应用程序:Cisco.exe 框架版本:v4.0.30319 说明: 由于未处理的异常,进程被终止。异常信息: System.InvalidOperationException 位于 MS.Internal.Data.PropertyPathWorker.CheckReadOnly(System.Object, 系统.对象)位于 MS.Internal.Data.PropertyPathWorker.ReplaceItem(Int32,System.Object, 系统.对象)位于 MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32, System.ComponentModel.ICollectionView、System.Object、布尔值)位于 MS.Internal.Data.ClrBindingWorker.AttachDataItem() 位于 System.Windows.Data.BindingExpression.Activate(System.Object) 在 System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt) 在 System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(布尔值) 在 MS.Internal.Data.DataBindEngine+Task.Run(Boolean) 处 MS.Internal.Data.DataBindEngine.Run(System.Object) 位于 System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object,Int32)位于 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate、System.Object、Int32、System.Delegate)位于 System.Windows.Threading.DispatcherOperation.InvokeImpl() 在 System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object) 在 MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(System.Object) 在 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback、System.Object、布尔值)位于 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback、System.Object、布尔值)位于 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback、System.Object)位于 MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback、System.Object)位于 System.Windows.Threading.DispatcherOperation.Invoke() 在 System.Windows.Threading.Dispatcher.ProcessQueue() 在 System.Windows.Threading.Dispatcher.WndProcHook(IntPtr,Int32,IntPtr, IntPtr,布尔 ByRef)在 MS.Win32.HwndWrapper.WndProc(IntPtr,Int32, IntPtr、IntPtr、布尔 ByRef)位于 MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)位于 System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object,Int32)位于 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate、System.Object、Int32、System.Delegate)位于 System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan、System.Delegate、System.Object、Int32)位于 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr) 在 MS.Win32.UnsafeNativeMethods.MessageBox(System.Runtime.InteropServices.HandleRef, 系统.String、系统.String、Int32)位于 System.Windows.MessageBox.ShowCore(IntPtr, System.String, System.String、System.Windows.MessageBoxButton、 系统.Windows.MessageBoxImage、系统.Windows.MessageBoxResult、 System.Windows.MessageBoxOptions)位于 System.Windows.MessageBox.Show(System.String) 位于 Cisco.App.OnStartup(System.Windows.StartupEventArgs) 位于 System.Windows.Application.<.ctor>b__1_0(System.Object) 位于 System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object,Int32)位于 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate、System.Object、Int32、System.Delegate)位于 System.Windows.Threading.DispatcherOperation.InvokeImpl() 在 System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object) 在 MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(System.Object) 在 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback、System.Object、布尔值)位于 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback、System.Object、布尔值)位于 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback、System.Object)位于 MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback、System.Object)位于 System.Windows.Threading.DispatcherOperation.Invoke() 在 System.Windows.Threading.Dispatcher.ProcessQueue() 在 System.Windows.Threading.Dispatcher.WndProcHook(IntPtr,Int32,IntPtr, IntPtr,布尔 ByRef)在 MS.Win32.HwndWrapper.WndProc(IntPtr,Int32, IntPtr、IntPtr、布尔 ByRef)位于 MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)位于 System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object,Int32)位于 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate、System.Object、Int32、System.Delegate)位于 System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan、System.Delegate、System.Object、Int32)位于 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr) 在 MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG 通过参考)在 System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame) 在 System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame) 在 System.Windows.Application.RunDispatcher(System.Object) 处 System.Windows.Application.RunInternal(System.Windows.Window)位于 System.Windows.Application.Run(System.Windows.Window)位于 Cisco.App.Main()

我知道有很多问题都有同样的问题,但还没有解决方案可以解决我的问题。

在运行期间主窗口甚至不出现。因此,我将所有 OnStartup 方法移至 try catch 块,尝试使用 MessageBox 识别此异常,但 MessageBox 也没有出现。

    public partial class App : Application
{
    void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
    {
        e.Handled = true;
    }


    protected override void OnStartup(StartupEventArgs e)
    {
        try
        {
            base.OnStartup(e);

            Ioc.Setup();

            Current.MainWindow = new MainWindow();

            Current.MainWindow.Show();
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }
}

我已经上传完整版了solution https://drive.google.com/open?id=16USjjKwxsQsmOOhacY2uilwfXWkBZVOx到谷歌驱动器。也许它会更有用。


终于我找到了原因。 该问题与使用私有 setter 绑定到公共变量有关。使此 setter 公共应用程序成功运行后。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

wpf应用程序在调试模式下运行,但在没有调试的情况下不会运行 的相关文章

随机推荐

  • python在加载模块时捕获NameError

    我试图捕获无法加载模块时发生的任何异常 当前的结果是 except 块没有被执行 import sys def loadModule module try import module except print Cannot load s F
  • 如何在DBeaver中使用sqlcmd GO批量分隔符?

    我需要使用GO1 https learn microsoft com en us sql t sql language elements sql server utilities statements goDBeaver IDE 中的熟食器
  • 获取属于任意类型的单元名称(TRttiType)

    我需要获取任何单元的名称 命名空间 TRttiType http docwiki embarcadero com CodeSamples en Category 3aRtti TRttiType 到目前为止 我已经尝试了以下方法 1 使用P
  • iTunes Connect 预发布版本无效。

    当尝试提交应用程序存档时 我在 Xcode 中收到以下错误 错误 ITMS 9000 预发布列车无效 列车版本 2 1 5 已关闭以提交新版本 有人有解决方案吗 该版本已经等待审核 我拒绝了它 现在正在尝试提交新版本 版本号相同 但我增加了
  • 覆盖 Primefaces 特定小部件的方法

    我想覆盖 Primefaces 数据表组件的函数 根据这个问题 如何在基于 widgetVar 的 Primefaces 组件中查找和 或覆盖 JavaScript https stackoverflow com questions 275
  • 如何强制内联div保持在同一行?

    我正在尝试制作三列布局 我希望左列和右列的宽度仅与其子项内容一样宽 我希望中心柱能够扩大以填充剩余空间 我正在尝试以下操作 概述 下面包含 jsfiddle 链接 colLeft display inline float left colC
  • 在 .NET 异常中保留原始 StackTrace/LineNumbers

    了解之间的区别throw ex and throw 为什么在这个例子中保留了原来的StackTrace static void Main string args try LongFaultyMethod catch System Excep
  • Windows Phone 应用程序缺少 EventToCommand

    我正在使用 MVVM Light 构建 Windows Phone 8 应用程序 到目前为止 一切都很好 但是 当我使用 EventToCommand 时 出现多个错误 一个类似的问题在这里迁移到 SL5 的 v4 时 EventToCom
  • 为什么 C++ 中不允许初始化整型成员变量(不是 const static)?

    当我尝试在类定义中初始化 int 成员变量时 我的 C 编译器会抱怨 它告诉我们 只有静态常量整型数据成员才能在类中初始化 您能否解释一下此限制背后的理由 如果可能的话 举例说明 因为目前的标准是不允许的 根据比亚恩的说法 http www
  • WP7 在地图上拖动图钉

    有谁知道如何在运行 Mango 的 WP7 客户端上的地图上实现可拖动图钉 我有一个图钉绑定到地图上的地理位置 我希望用户能够将其拖动到地图上并记录其新位置 我见过一些资源 但它们用于非 WP7 Bing 地图控制 任何帮助 将不胜感激 T
  • 如何使用 Asset Pipeline 从非标准目录传送字体

    我正在尝试将 Fontawesome 包含在 Rails 4 应用程序中 但资产并未进入资产管道 然而 这些字体并没有在生产中使用 我不明白为什么 文件结构组织 我所有的资产都存储在 assets components因此 Fontawes
  • Node.js 公牛队列中的作业陷入“等待”状态

    我有一堆工作在公牛队列中 其中一个被卡住了 1 个多小时 通常需要大约 2 分钟才能运行 但没有失败 我无法使用我使用的 bull arena UI 将作业从活动状态中删除 因此我删除了 Redis 中活动作业的密钥 这消除了卡住的活动作业
  • php 中的图像验证码

    下面是一个程序的源代码 谁能帮我弄清楚程序的工作原理
  • 在 Android 手机中打开键盘时图像大小调整问题

    感谢您的阅读 我是cordova开发的新手 我正在使用framework7使用cordova开发混合应用程序 我将背景放在登录表单上 但在移动设备中 当打开键盘进行书写时 背景图像会调整大小 我想要修复打开 Android 键盘时未调整大小
  • r-将列表列转换为字符向量,其中列表是字符

    我正在尝试将列表转换为单个字符值 或者基本上从这里开始 test lt data frame a c 1 1 1 2 2 2 b c a b c d e f gt group by a gt summarise b list b to th
  • 在 Elasticsearch 和 Lucene 4.4 中使用 Shingles 和停用词

    在我正在构建的索引中 我有兴趣运行查询 然后 使用方面 返回该查询的带状疱疹 这是我在文本上使用的分析器 settings analysis analyzer shingleAnalyzer tokenizer standard filte
  • 如何检查 AlarmManager 是否已经设置了闹钟?

    当我的应用程序启动时 我希望它检查特定警报 通过 AlarmManager 注册 是否已设置并正在运行 谷歌的结果似乎表明没有办法做到这一点 这仍然正确吗 我需要执行此检查 以便在采取任何操作创建新警报之前向用户提供建议 跟进 ron 发表
  • 如何将数据直接写入显存?

    程序员有什么办法可以直接将数据写入显存吗 我知道操作系统对此非常严格 但是某些类型的应用程序 例如视频播放器或电脑游戏 如何将其数据直接写入视频内存 我知道有很多知名的库 例如 OpenGL 但它们毕竟只是普通的库 它们和我和你写的程序没有
  • 有没有办法在不修改 Yocto 的情况下为机器 ID 创建链接?

    我正在运行使用 Yocto Zeus 3 0 0 构建的 Linux 4 14 149 我正在运行只读文件系统 最近发现一个问题 我的 UID etc machine id 每次启动都会发生变化 这个问题的结果 https superuse
  • wpf应用程序在调试模式下运行,但在没有调试的情况下不会运行

    我的 WPF 应用程序在 VS2015 中以调试模式成功运行 但是 在不调试的情况下启动时 应用程序启动并立即完成 从 Debug Release 文件夹启动 exe 文件时也会发生同样的情况 事件查看器显示以下 Net 运行时错误 应用程