簡體   English   中英

Wpf應用程序不是在啟動時啟動而是手動運行嗎?

[英]Wpf Application Does not start at startup but run manually?

我已經在WPF中創建了一個僅輪詢應用程序的應用程序。 現在,我想在Windows Startup(用戶登錄后)上啟動該應用程序。 我還使用Wix Toolset創建了一個安裝程序包,該包將注冊表項添加到Software \\ Microsoft \\ Windows \\ CurrentVersion \\ Run 程序實際上嘗試運行,但沒有給出錯誤。 我能夠從Windows 事件查看器中獲取錯誤,並且我不明白在哪里生成此錯誤。

堆棧跟蹤:

Application: icBlync.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.DirectoryNotFoundException
   at System.IO.__Error.WinIOError(Int32, System.String)
   at System.IO.FileStream.Init(System.String, System.IO.FileMode, System.IO.FileAccess, Int32, Boolean, System.IO.FileShare, Int32, System.IO.FileOptions, SECURITY_ATTRIBUTES, System.String, Boolean, Boolean, Boolean)
   at System.IO.FileStream..ctor(System.String, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare)
   at System.Windows.Media.Imaging.BitmapDecoder.SetupDecoderFromUriOrStream(System.Uri, System.IO.Stream, System.Windows.Media.Imaging.BitmapCacheOption, System.Guid ByRef, Boolean ByRef, System.IO.Stream ByRef, System.IO.UnmanagedMemoryStream ByRef, Microsoft.Win32.SafeHandles.SafeFileHandle ByRef)
   at System.Windows.Media.Imaging.BitmapDecoder.CreateFromUriOrStream(System.Uri, System.Uri, System.IO.Stream, System.Windows.Media.Imaging.BitmapCreateOptions, System.Windows.Media.Imaging.BitmapCacheOption, System.Net.Cache.RequestCachePolicy, Boolean)
   at System.Windows.Media.Imaging.BitmapFrame.CreateFromUriOrStream(System.Uri, System.Uri, System.IO.Stream, System.Windows.Media.Imaging.BitmapCreateOptions, System.Windows.Media.Imaging.BitmapCacheOption, System.Net.Cache.RequestCachePolicy)
   at System.Windows.Media.Imaging.BitmapFrame.Create(System.Uri, System.Net.Cache.RequestCachePolicy)
   at System.Windows.Media.Imaging.BitmapFrame.Create(System.Uri)
   at icBlync.Windows.SettingWindow..ctor()
   at icBlync.App..ctor()
   at icBlync.App.Main()

請幫助。

當App從啟動啟動時,工作目錄不是安裝目錄。 因此,當應用嘗試加載圖標時,它會給出System.IO.DirectoryNotFoundException

我只是使用以下方法將工作目錄更改為Installed目錄:

Environment.CurrentDirectory = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM