microsoft / InsiderDevTour18-Labs

Source for additional lab material
MIT License
16 stars 26 forks source link

Modernize - App working under debug, but not when installed. #73

Closed mt025 closed 6 years ago

mt025 commented 6 years ago

For the Modernize project, I created the appxbundle installed it. However, the application doesn't launch. I've tried it twice and it asked for a certificate to be installed. Clean install of Visual Studio 2017: 15.7.3 and Windows Build: 1803 - 17682

The app works when under debugging mode in Visual Studio, but when debugging the packged project, I get this error:

System.IO.FileNotFoundException: 'Could not find file 'C:\WINDOWS\SysWOW64\Products.json'.'

The streamreader on FileHelper.cs:27 is only getting the filename not the path.

Why is my app working in SysWOW64?

Below is from the event log when running the installed package.

Application: Microsoft.Knowzy.WPF.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.FileNotFoundException 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, Int32, System.IO.FileOptions, System.String, Boolean, Boolean, Boolean) at System.IO.StreamReader..ctor(System.String, System.Text.Encoding, Boolean, Int32, Boolean) at System.IO.StreamReader..ctor(System.String) at Microsoft.Knowzy.WPF.Helpers.FileHelper.ReadTextFile(System.String) at Microsoft.Knowzy.DataProvider.JsonDataProvider.GetData() at Microsoft.Knowzy.WPF.ViewModels.MainViewModel.OnViewAttached(System.Object, System.Object) at Caliburn.Micro.ViewAware.Caliburn.Micro.IViewAware.AttachView(System.Object, System.Object) at Caliburn.Micro.ViewModelBinder+<>c.<.cctor>b__10_3(System.Object, System.Windows.DependencyObject, System.Object) at Caliburn.Micro.View.OnModelChanged(System.Windows.DependencyObject, System.Windows.DependencyPropertyChangedEventArgs) at System.Windows.DependencyObject.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs) at System.Windows.FrameworkElement.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs) at System.Windows.DependencyObject.NotifyPropertyChange(System.Windows.DependencyPropertyChangedEventArgs) at System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.EntryIndex, System.Windows.DependencyProperty, System.Windows.PropertyMetadata, System.Windows.EffectiveValueEntry, System.Windows.EffectiveValueEntry ByRef, Boolean, Boolean, System.Windows.OperationType) at System.Windows.DependencyObject.SetValueCommon(System.Windows.DependencyProperty, System.Object, System.Windows.PropertyMetadata, Boolean, Boolean, System.Windows.OperationType, Boolean) at System.Windows.Data.BindingOperations.SetBinding(System.Windows.DependencyObject, System.Windows.DependencyProperty, System.Windows.Data.BindingBase) at Caliburn.Micro.ConventionManager+<>c.<.cctor>b15_6(System.Type, System.String, System.Reflection.PropertyInfo, System.Windows.FrameworkElement, Caliburn.Micro.ElementConvention, System.Windows.DependencyProperty) at Caliburn.Micro.ConventionManager.SetBindingWithoutBindingOverwrite(System.Type, System.String, System.Reflection.PropertyInfo, System.Windows.FrameworkElement, Caliburn.Micro.ElementConvention, System.Windows.DependencyProperty) at Caliburn.Micro.ElementConvention+<>c.<.ctor>b5_0(System.Type, System.String, System.Reflection.PropertyInfo, System.Windows.FrameworkElement, Caliburn.Micro.ElementConvention) at Caliburn.Micro.ViewModelBinder+<>c.<.cctor>b__10_0(System.Collections.Generic.IEnumerable`1, System.Type) at Caliburn.Micro.ViewModelBinder+<>c.<.cctor>b10_3(System.Object, System.Windows.DependencyObject, System.Object) at Caliburn.Micro.WindowManager.CreateWindow(System.Object, Boolean, System.Object, System.Collections.Generic.IDictionary2<System.String,System.Object>) at Caliburn.Micro.WindowManager.ShowWindow(System.Object, System.Object, System.Collections.Generic.IDictionary2<System.String,System.Object>) at Caliburn.Micro.BootstrapperBase.DisplayRootViewFor(System.Type, System.Collections.Generic.IDictionary2<System.String,System.Object>) at Caliburn.Micro.BootstrapperBase.DisplayRootViewFor[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IDictionary2<System.String,System.Object>) at Microsoft.Knowzy.WPF.AppBootstrapper.OnStartup(System.Object, System.Windows.StartupEventArgs) at System.Windows.Application.OnStartup(System.Windows.StartupEventArgs) at System.Windows.Application.<.ctor>b__1_0(System.Object) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) at System.Windows.Threading.DispatcherOperation.InvokeImpl() at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object) at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.ProcessQueue() at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr) at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef) at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame) at System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame) at System.Windows.Application.RunDispatcher(System.Object) at System.Windows.Application.RunInternal(System.Windows.Window) at System.Windows.Application.Run(System.Windows.Window) at System.Windows.Application.Run() at Microsoft.Knowzy.WPF.App.Main()

Faulting application name: Microsoft.Knowzy.WPF.exe, version: 1.0.0.0, time stamp: 0x5b132b68
Faulting module name: KERNELBASE.dll, version: 10.0.17682.1000, time stamp: 0x20a6b8fe
Exception code: 0xe0434352
Fault offset: 0x0011f0b2
Faulting process ID: 0x2438
Faulting application start time: 0x01d3facc5483668d
Faulting application path: C:\Program Files\WindowsApps\666e9562-6de5-4871-8e47-80fe369675b6_1.0.1.0_neutral__v2eq8qs7wm15j\Microsoft.Knowzy.WPF\Microsoft.Knowzy.WPF.exe
Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
Report ID: 23f845ad-759a-4213-aab6-64878fef8104
Faulting package full name: 666e9562-6de5-4871-8e47-80fe369675b6_1.0.1.0_neutral__v2eq8qs7wm15j
Faulting package-relative application ID: App

cbarkerms commented 6 years ago

thank you for raising - a fix from another branch failed to make it in here so apologies for the inconvenience. I have now merged the fix for the file reader path problem.

the certificate prompt (at install time) is by design if you are using a test certificate - you will need to manually install into the trusted root / people store on the target machine (see https://docs.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-distribute) - i'd recommend removing once you have completed the lab.

closing - but please re-open if it does not resolve.