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应用程序在调试模式下运行,但在没有调试的情况下不会运行 的相关文章

  • GLKit的GLKMatrix“列专业”如何?

    前提A 当谈论线性存储器中的 列主 矩阵时 列被一个接一个地指定 使得存储器中的前 4 个条目对应于矩阵中的第一列 另一方面 行主 矩阵被理解为依次指定行 以便内存中的前 4 个条目指定矩阵的第一行 A GLKMatrix4看起来像这样 u
  • Web 客户端和 Expect100Continue

    使用 WebClient C NET 时设置 Expect100Continue 的最佳方法是什么 我有下面的代码 我仍然在标题中看到 100 continue 愚蠢的 apache 仍然抱怨 505 错误 string url http
  • 为什么两个不同的 Base64 字符串的转换会返回相等的字节数组?

    我想知道为什么从 base64 字符串转换会为不同的字符串返回相同的字节数组 const string s1 dg const string s2 dq byte a1 Convert FromBase64String s1 byte a2
  • Asp.NET WebApi 中类似文件名称的路由

    是否可以在 ASP NET Web API 路由配置中添加一条路由 以允许处理看起来有点像文件名的 URL 我尝试添加以下条目WebApiConfig Register 但这不起作用 使用 URIapi foo 0de7ebfa 3a55
  • BitTorrent 追踪器宣布问题

    我花了一点业余时间编写 BitTorrent 客户端 主要是出于好奇 但部分是出于提高我的 C 技能的愿望 我一直在使用理论维基 http wiki theory org BitTorrentSpecification作为我的向导 我已经建
  • 用于登录 .NET 的堆栈跟踪

    我编写了一个 logger exceptionfactory 模块 它使用 System Diagnostics StackTrace 从调用方法及其声明类型中获取属性 但我注意到 如果我在 Visual Studio 之外以发布模式运行代
  • 在 Windows 窗体中保存带有 Alpha 通道的单色位图会保存不同(错误)的颜色

    在 C NET 2 0 Windows 窗体 Visual Studio Express 2010 中 我保存由相同颜色组成的图像 Bitmap bitmap new Bitmap width height PixelFormat Form
  • HTTPWebResponse 响应字符串被截断

    应用程序正在与 REST 服务通信 Fiddler 显示作为 Apps 响应传入的完整良好 XML 响应 该应用程序位于法属波利尼西亚 在新西兰也有一个相同的副本 因此主要嫌疑人似乎在编码 但我们已经检查过 但空手而归 查看流读取器的输出字
  • 关于 C++ 转换:参数 1 从“[some_class]”到“[some_class]&”没有已知的转换

    我正在研究 C 并且遇到了一个错误 我不知道确切的原因 我已经找到了解决方案 但仍然想知道原因 class Base public void something Base b int main Base b b something Base
  • 创建链表而不将节点声明为指针

    我已经在谷歌和一些教科书上搜索了很长一段时间 我似乎无法理解为什么在构建链表时 节点需要是指针 例如 如果我有一个节点定义为 typedef struct Node int value struct Node next Node 为什么为了
  • 重载<<的返回值

    include
  • 如何设计以 char* 指针作为类成员变量的类?

    首先我想介绍一下我的情况 我写了一些类 将 char 指针作为私有类成员 而且这个项目有 GUI 所以当单击按钮时 某些函数可能会执行多次 这些类是设计的单班在项目中 但是其中的某些函数可以执行多次 然后我发现我的项目存在内存泄漏 所以我想
  • 控件的命名约定[重复]

    这个问题在这里已经有答案了 Microsoft 在其网站上提供了命名指南 here http msdn microsoft com en us library xzf533w0 VS 71 aspx 我还有 框架设计指南 一书 我找不到有关
  • 如何序列化/反序列化自定义数据集

    我有一个 winforms 应用程序 它使用强类型的自定义数据集来保存数据进行处理 它由数据库中的数据填充 我有一个用户控件 它接受任何自定义数据集并在数据网格中显示内容 这用于测试和调试 为了使控件可重用 我将自定义数据集视为普通的 Sy
  • 使用 x509 证书签署 json 文档或字符串

    如何使用 x509 证书签署 json 文档或字符串 public static void fund string filePath C Users VIKAS Desktop Data xml Read the file XmlDocum
  • C# 成员变量继承

    我对 C 有点陌生 但我在编程方面有相当广泛的背景 我想做的事情 为游戏定义不同的 MapTiles 我已经像这样定义了 MapTile 基类 public class MapTile public Texture2D texture pu
  • 是否可以在 .NET Core 中将 gRPC 与 HTTP/1.1 结合使用?

    我有两个网络服务 gRPC 客户端和 gRPC 服务器 服务器是用 NET Core编写的 然而 客户端是托管在 IIS 8 5 上的 NET Framework 4 7 2 Web 应用程序 所以它只支持HTTP 1 1 https le
  • 如何在文本框中插入图像

    有没有办法在文本框中插入图像 我正在开发一个聊天应用程序 我想用图标图像更改值 等 但我找不到如何在文本框中插入图像 Thanks 如果您使用 RichTextBox 进行聊天 请查看Paste http msdn microsoft co
  • C++ 标准是否指定了编译器的 STL 实现细节?

    在写答案时this https stackoverflow com questions 30909296 can you put a pimpl class inside a vector我遇到了一个有趣的情况 这个问题演示了这样一种情况
  • 对来自流读取器的过滤数据执行小计

    编辑问题未得到解答 我有一个基于 1 个标准的过滤输出 前 3 个数字是 110 210 或 310 给出 3 个不同的组 从流阅读器控制台 问题已编辑 因为第一个答案是我给出的具体示例的字面解决方案 我使用的实际字符串长度为 450 个

随机推荐

  • 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 运行时错误 应用程