Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Files.App.CsWin32/NativeMethods.txt
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,4 @@ WINTRUST_DATA
HCERTSTORE
CERT_QUERY_ENCODING_TYPE
CertGetNameString
MessageBox
8 changes: 8 additions & 0 deletions src/Files.App/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,5 +282,13 @@ public static class Distributions
"FilesDev", // dev
};
}

public static class Startup
{
// These strings are intentionally hardcoded and cannot be moved to resource files.
// The Windows App Runtime (which powers the resource loading system) may itself be unavailable at this point
public const string MissingRuntimeMessage = "Files failed to start. A required Windows component could not be loaded. Try reinstalling Files from the Microsoft Store or from https://files.community/download";
public const string MissingRuntimeTitle = "Files - Startup Error";
}
}
}
20 changes: 19 additions & 1 deletion src/Files.App/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
using Microsoft.UI.Xaml;
using Microsoft.Windows.AppLifecycle;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using Windows.Win32.UI.WindowsAndMessaging;
using Windows.ApplicationModel.Activation;
using Windows.Storage;

Expand Down Expand Up @@ -101,7 +103,23 @@ static bool ProcessPathPredicate(Process p)
//Server.AppInstanceMonitor.StartMonitor(Environment.ProcessId);

var OpenTabInExistingInstance = ApplicationData.Current.LocalSettings.Values.Get("OpenTabInExistingInstance", true);
var activatedArgs = AppInstance.GetCurrent().GetActivatedEventArgs();

AppActivationArguments activatedArgs;
try
{
activatedArgs = AppInstance.GetCurrent().GetActivatedEventArgs();
}
catch (COMException ex) when (ex.HResult == unchecked((int)0x80040154))
{
Windows.Win32.PInvoke.MessageBox(
default,
Constants.Startup.MissingRuntimeMessage,
Constants.Startup.MissingRuntimeTitle,
MESSAGEBOX_STYLE.MB_ICONERROR);

throw new InvalidOperationException(Constants.Startup.MissingRuntimeMessage, ex);
}

var commandLineArgs = GetCommandLineArgs(activatedArgs);

if (commandLineArgs is not null)
Expand Down
Loading