0

I have a C# .NET WPF (MVVM Lite) Application that runs on Windows 7 machines. It is combiled for .NET 4.5.

While .NET 4.5.2 was installed on the clients, it run as it should. After an client update to .NET 4.7 and uninstalling .NET 4.5.2 (!) the application hangs on start:

Frameworkversion: v4.0.30319 Beschreibung: DThe process was terminated by an unhandled exception. exception information: System.Runtime.InteropServices.COMException bei MS.Win32.Penimc.UnsafeNativeMethods.CoCreateInstance(System.Guid ByRef, System.Object, Int32, System.Guid ByRef) bei MS.Win32.Penimc.UnsafeNativeMethods.CreatePimcManager() bei MS.Win32.Penimc.UnsafeNativeMethods..cctor()

exception information: System.TypeInitializationException bei MS.Win32.Penimc.UnsafeNativeMethods.CreateResetEvent(IntPtr ByRef) bei System.Windows.Input.PenThreadWorker..ctor() bei System.Windows.Input.PenThreadPool.GetPenThreadForPenContextHelper(System.Windows.Input.PenContext) bei System.Windows.Input.PenThreadPool.GetPenThreadForPenContext(System.Windows.Input.PenContext) bei System.Windows.Input.StylusWisp.WispTabletDeviceCollection.UpdateTabletsImpl() bei System.Windows.Input.StylusWisp.WispTabletDeviceCollection.UpdateTablets() bei System.Windows.Input.StylusWisp.WispTabletDeviceCollection..ctor() bei System.Windows.Input.StylusWisp.WispLogic.get_WispTabletDevices() bei System.Windows.Input.StylusWisp.WispLogic.RegisterHwndForInput(System.Windows.Input.InputManager, System.Windows.PresentationSource) bei System.Windows.Interop.HwndStylusInputProvider..ctor(System.Windows.Interop.HwndSource) bei System.Windows.Interop.HwndSource.Initialize(System.Windows.Interop.HwndSourceParameters) bei System.Windows.Window.CreateSourceWindow(Boolean) bei System.Windows.Window.CreateSourceWindowDuringShow() bei System.Windows.Window.SafeCreateWindowDuringShow() bei System.Windows.Window.ShowHelper(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.DispatcherOperation.InvokeImpl() bei 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(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) bei System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) bei MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object) bei System.Windows.Threading.DispatcherOperation.Invoke() bei System.Windows.Threading.Dispatcher.ProcessQueue() bei System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) bei MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean 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.Windows.Application.Run(System.Windows.Window) bei ApplicationName.App.Main()

App.xaml.cs is modified:

public partial class App : Application, ISingleInstanceApp 
{

    private static string Unique = "Test_xx";

    [STAThread]
    public static void Main()
    {    
        for (int i = 1; i < Environment.GetCommandLineArgs().Length; i++)
            Unique += Environment.GetCommandLineArgs()[i];

        if (SingleInstance<App>.InitializeAsFirstInstance(Unique))
        {
            var application = new App();
            application.InitializeComponent();
            application.Run();

            // Allow single instance code to perform cleanup operations
            SingleInstance<App>.Cleanup();
        }
    }

    public bool SignalExternalCommandLineArgs(IList<string> args)
    {
        if(args.Count < 3 || args[2].ToUpper() != "AUTOSTART")            
            MessageBox.Show("Program already runs!","Error!",MessageBoxButton.OK,MessageBoxImage.Warning);

            Current.MainWindow.WindowState = WindowState.Maximized;                
            return true;
    }

    protected override void OnStartup(StartupEventArgs e)
    {            
            this.StartupUri = new System.Uri("MainWindow.xaml", System.UriKind.Relative);


    }

Any ideas?

Peter
  • 1,655
  • 22
  • 44
Matthias G
  • 51
  • 4

0 Answers0