我開發了一個C#WPF應用。在VS17調試器中運行它 - 一切優秀WPF應用發佈行爲
雙擊在發行文件夾中的.exe - 所有罰款
我部署在多個設備上的軟件,雙擊該.exe - 所有罰款
啓動部署的應用程序通過PowerShell與 Start-Process -FilePath "C:\Users\krueperj\Desktop\Release\PrometheusStartup.exe"
- 所有罰款
現在它變得很奇怪。
我想在登錄時啓動應用程序。當我在Windows任務計劃程序中創建任務時,應用程序將因異常而無法啓動。 當我安排powershell(打開.exe)並啓動時,應用程序不會啓動,因爲有相同的異常。 當我通過代碼將我的應用程序放入註冊表以自動啓動時,同樣的異常。
以下是事件日誌說:
System.UnauthorizedAccessException的貝System.IO .__ Error.WinIOError(的Int32,System.String)貝System.IO.FileStream.Init(System.String,System.IO .FileMode,System.IO.FileAccess,的Int32,布爾值,System.IO.FileShare,的Int32,System.IO.FileOptions,SECURITY_ATTRIBUTES,System.String,布爾值,布爾,布爾值)貝System.IO.FileStream..ctor(系統.String,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,Int32,System.IO.FileOptions,System.String,Boolean,布爾值,布爾型)bei System.IO.File.InternalWriteAllBytes(System。 String,Byte [],Boolean)bei System.IO.File.WriteAllBytes(System.String,Byte [])bei PrometheusStartup.FileCache.AfterAccessNotificatio n(Microsoft.IdentityModel.Clients.ActiveDirectory.TokenCacheNotificationArgs)bei Microsoft.IdentityModel.Clients.ActiveDirectory.TokenCache.OnAfterAccess(Microsoft.IdentityModel.Clients.ActiveDirectory.TokenCacheNotificationArgs)bei Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenHandlerBase.NotifyAfterAccessCache()bei Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenHandlerBase + d__53.MoveNext()bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks .Task)bei Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext + d__48.MoveNext()bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System .Threading.Tasks.Task)bei Microsoft.IdentityModel.Clients.ActiveDirectory.Authen ticationContextIntegratedAuthExtensions + d__0.MoveNext()貝System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)貝System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)貝PrometheusStartup.MainWindow + d__18.MoveNext()貝System.Runtime.CompilerServices.AsyncMethodBuilderCore + <> c.b__6_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的) bei System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Object,Boolean)bei System.Threading.ExecutionContext.Run(Sys tem.Threading.ExecutionContext,System.Threading.ContextCallback,System.Object的,布爾值)貝System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Object的)貝MS.Internal.CulturePreservingExecutionContext。潤(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)bei MS.Win32.HwndWrapper。WndProc(IntPtr,Int32,IntPtr,IntPtr,布爾ByRef)bei MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate,System.Object,Int32)bei System。 Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object,System.Delegate,System.Object,Int32,System.Delegate)bei System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority,System.TimeSpan,System .Delegate,System.Object,Int32)bei MS.Win32.HwndSubclass.SubclassWndProc(IntPtr,Int32,IntPtr,IntPtr)bei MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)bei System.Windows.Threading .Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)bei System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)bei System.Windows.Application.RunDispatcher(System.Object)bei System.Windows。 Application.RunInternal(System.Windows.Window)bei System.Window s.Application.Run(System.Windows.Window)bei PrometheusStartup.App.Main()
你的應用需要提升的權利才能運行? – Alex
System.UnauthorizedAccessException 您可能需要以管理員身份運行 – ArcSet