【发布时间】:2017-06-14 00:26:52
【问题描述】:
所以我有 3 个 WPF 应用程序,它们功能齐全,可以在 Visual Studio 中使用调试器正常运行。然而,如果没有调试器,这三个中的两个根本不会运行(也就是 .exe 什么都不做)。它不会崩溃或给我错误,它只会给我一秒钟的加载轮,然后什么也没有。我不明白为什么它可以与调试器一起正常运行,而在没有它的情况下运行时根本无法运行。我已经尝试了调试和发布版本,但没有任何区别。我尝试重新启动 Visual Studio 和我的计算机并清理和重建解决方案。我提到了运行良好的应用程序,因为它让我相信我的视觉工作室运行良好。我正在使用 Visual Studio 2013。
我不知道要显示什么代码 sn-ps,因为我不知道是什么导致了问题。如果您想查看某些功能/文件,请在 cmets 中告诉我,如果可以,我会将它们添加到帖子中。
您知道什么可能导致这种情况发生吗?我需要采取哪些步骤才能让我的 .exe 文件以 .vshost.exe 与调试器一起运行的方式运行?
编辑:该应用程序确实抛出了我在事件日志中发现的错误。虽然我仍然不确定是什么导致了错误 这是错误:
Application: OrderFinderTool.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Windows.Markup.XamlParseException
Stack:
at System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader, Boolean, System.Object, System.Xaml.Permissions.XamlAccessLevel, System.Uri)
at System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream, System.Windows.Markup.ParserContext, System.Object, Boolean)
at System.Windows.Application.LoadComponent(System.Object, System.Uri)
at SupportWizard.App.InitializeComponent()
at SupportWizard.App.Main()
编辑 2: 我的同事运行 .exe 并收到更详细的错误消息:
Application: OrderFinderTool.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
at System.Reflection.RuntimeAssembly._nLoad(System.Reflection.AssemblyName, System.String, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean)
at System.Reflection.RuntimeAssembly.nLoad(System.Reflection.AssemblyName, System.String, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(System.Reflection.AssemblyName, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean)
at System.Reflection.Assembly.Load(System.Reflection.AssemblyName)
at System.Windows.Navigation.BaseUriHelper.GetLoadedAssembly(System.String, System.String, System.String)
at MS.Internal.AppModel.ResourceContainer.GetResourceManagerWrapper(System.Uri, System.String ByRef, Boolean ByRef)
at MS.Internal.AppModel.ResourceContainer.GetPartCore(System.Uri)
at System.IO.Packaging.Package.GetPartHelper(System.Uri)
at System.IO.Packaging.Package.GetPart(System.Uri)
at System.IO.Packaging.PackWebResponse+CachedResponse.GetResponseStream()
at System.IO.Packaging.PackWebResponse.GetResponseStream()
at System.IO.Packaging.PackWebResponse.get_ContentType()
at MS.Internal.WpfWebRequestHelper.GetContentType(System.Net.WebResponse)
at MS.Internal.WpfWebRequestHelper.GetResponseStream(System.Net.WebRequest, MS.Internal.ContentType ByRef)
at System.Windows.ResourceDictionary.set_Source(System.Uri)
at System.Windows.Baml2006.WpfSharedBamlSchemaContext+<>c.<Create_BamlProperty_ResourceDictionary_Source>b__342_0(System.Object, System.Object)
at System.Windows.Baml2006.WpfKnownMemberInvoker.SetValue(System.Object, System.Object)
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(System.Xaml.XamlMember, System.Object, System.Object)
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(System.Object, System.Xaml.XamlMember, System.Object)
Exception Info: System.Windows.Markup.XamlParseException
at System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader, Boolean, System.Object, System.Xaml.Permissions.XamlAccessLevel, System.Uri)
at System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream, System.Windows.Markup.ParserContext, System.Object, Boolean)
at System.Windows.Application.LoadComponent(System.Object, System.Uri)
at OrderFinderTool.App.InitializeComponent()
at OrderFinderTool.App.Main()
编辑 3: 感谢用户 Jay T 的帮助,我发现使用调试器运行时正在加载 aero 程序集,但并非没有它,因为我在 Windows 8 机器上运行并且他们切换到了新的 aero2 程序集。删除程序集和对其的引用允许 .exe 运行而不会崩溃
【问题讨论】:
-
是否必须附加调试器才能使其工作?你能在没有 Visual Studio 的情况下运行调试版本吗?
-
您的应用程序有任何类型的日志记录吗?您是否尝试过使用 Fusion 日志来验证您的应用程序及其依赖项是否都已加载?有关 Fusion 日志的帮助,请参阅 stackoverflow.com/questions/255669/…。
-
我用谷歌搜索了你的标题:stackoverflow.com/questions/4206941/… 他检查的那个人是应用程序事件日志,发现程序抛出了一个异常,由于未知原因没有在调试模式下抛出.如果您转到“Project->{your project} Properties”,您可以找到调试/发布之间的差异,例如“命令行参数”。
-
@empi 是的,必须附加调试器,即使对于 .exe 在 .vshost.exe 上运行的程序,如果没有 vs 也无法运行,我认为这是应该的方式
-
@Quantic 我搜索了一段时间并没有看到这篇文章,我现在正在运行建议的解决方案,看看它们是否有效
标签: c# wpf visual-studio-2013