簡體   English   中英

WPF COMException在啟動時崩潰應用程序(今天開始)

[英]WPF COMException Crashes Application At Startup (Started Today)

我今天才剛剛開始使用已經生產了3年的應用程序在應用程序啟動中看到這種異常。

 System.TypeInitializationException: The type initializer for 'MS.Win32.Penimc.UnsafeNativeMethods' threw an exception. ---> System.Runtime.InteropServices.COMException: Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)) at MS.Win32.Penimc.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid) at MS.Win32.Penimc.UnsafeNativeMethods.CreatePimcManager() at MS.Win32.Penimc.UnsafeNativeMethods..cctor() --- End of inner exception stack trace --- at MS.Win32.Penimc.UnsafeNativeMethods.CreateResetEvent(IntPtr& handle) at System.Windows.Input.PenThreadWorker..ctor() at System.Windows.Input.PenThreadPool.GetPenThreadForPenContextHelper(PenContext penContext) at System.Windows.Input.PenThreadPool.GetPenThreadForPenContext(PenContext penContext) at System.Windows.Input.StylusWisp.WispTabletDeviceCollection.UpdateTabletsImpl() at System.Windows.Input.StylusWisp.WispTabletDeviceCollection.UpdateTablets() at System.Windows.Input.StylusWisp.WispTabletDeviceCollection..ctor() at System.Windows.Input.StylusWisp.WispLogic.get_WispTabletDevices() at System.Windows.Input.StylusWisp.WispLogic.RegisterHwndForInput(InputManager inputManager, PresentationSource inputSource) at System.Windows.Interop.HwndStylusInputProvider..ctor(HwndSource source) at System.Windows.Interop.HwndSource.Initialize(HwndSourceParameters parameters) at System.Windows.Window.CreateSourceWindow(Boolean duringShow) at System.Windows.Window.CreateSourceWindowDuringShow() at System.Windows.Window.SafeCreateWindowDuringShow() at System.Windows.Window.ShowHelper(Object booleanBox) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.DispatcherOperation.InvokeImpl() at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.ProcessQueue() at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) at System.Windows.Application.RunDispatcher(Object ignore) at System.Windows.Application.RunInternal(Window window) at System.Windows.Application.Run(Window window) at APSSSentinel.App.Main() 

顯然,一些使用VS2017的開發人員安裝了Windows Update並安裝了.NET 4.7,也已崩潰,目前看來,建議的解決方法是關閉觸摸支持。

https://developercommunity.visualstudio.com/content/problem/55303/visual-studio-may-terminate-unexpectedly-when-runn.html

對於我的應用程序,這不是理想的。 有沒有其他人遇到這個問題,並且找到了其他解決方法?

更新:Microsoft現在已經通過手動更新解決了此問題 (如Jürgen所言), 我個人會堅持使用變通辦法,直到該修復程序處於自動更新中為止,因為要使每個用戶安裝手動更新都將花費很多工作。


這顯然是.Net 4.7中的錯誤,會影響具有觸摸輸入設備的Windows 7和8 / 8.1系統。 因此,我們可以希望Microsoft在以后的更新中解決此問題。 同時,保留全部功能的唯一方法是卸載並隱藏更新。

其他選項是在app.config(如您的鏈接中)或代碼(如果應用程序使用4.6或更高版本編譯)中禁用麥粒腫和觸摸支持。 您沒有指定為什么這不是理想選擇,但我認為需要這些功能? 請注意,禁用並不意味着每個應用程序都不能在觸摸設備上使用,而是它們僅使用鼠標可訪問的功能。 更新:顯然,沒有鼠標的觸摸設備用戶將無法使用需要滾動的UI。

這是那些來這里尋求快速修復的人的代碼示例:

在App.config中(適用於使用任何框架版本編譯的應用程序)

 <configuration> <runtime> <AppContextSwitchOverrides value="Switch.System.Windows.Input.Stylus.DisableStylusAndTouchSupport=true" /> </runtime> </configuration> 

在代碼中(使用.Net Framework> = 4.6編譯時)

 protected override void OnStartup(StartupEventArgs e) { AppContext.SetSwitch("Switch.System.Windows.Input.Stylus.DisableStylusAndTouchSupport", true); base.OnStartup(e); } 

暫無
暫無

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

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