更新3
这实际上是由我包含的使用 ILMerge
的构建后操作引起的。请参阅here了解更多详情
更新2
这似乎不是由添加命令行支持直接引起的,但我仍然不知道是什么原因导致的。请参阅SO question了解更多详情。
更新
进行以下更改以允许命令行支持后,我无法在所有断点上使用此消息单步调试程序:
The breakpoint will not currently be hit. No symbols have been loaded for this document
我检查了this SO answer并发现我丢失了文件 Microsoft.VisualStudio.Debugger.Runtime.pdb
但我不知道它去了哪里..
是否有任何原因会因为 App.xaml
更新而发生这种情况?
我有一个 WPF
应用程序,我需要为其实现命令行参数。
遵循 this SO question 的答案,我修改了 App.xaml
以删除 StartUpUri
属性:
<Application x:Class="WpfFileDeleter.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfFileDeleter"
>
<Application.Resources>
</Application.Resources>
</Application>
然后我向 App.xaml.cs
添加了一个重写方法:
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
e.Args.Contains("MyTriggerArg")
{
// Do some stuff
}
}
但是在 OnStartUp
顶部插入断点并在 Visual Studio 中调试应用程序后,它只是挂起在 Ready 状态,但实际上从未允许我单步执行该程序。
我尝试了以下 StartUpUri
值:
StartUpUri = "App.xaml"
StartUpUri = "App.xaml.cs"
StartUpUri = "App.xaml.cs.OnStartUp"
但是应用程序只是抛出“无法定位资源”IOException
最佳答案
根据ethicallogics的回答,在中定义启动参数就足够了 app_start 事件处理程序。如果您从 xaml 中删除 starupuri,则需要在 sratup 处理程序中定义其他内容而不是该内容
关于c# - 尝试添加命令行支持后无法使用断点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39369343/