When I try to launch my program with a shortcut or Process.Start it is running my if's saying that my files are missing and it is not launching the WPF windows. The picture below is what I am trying to launch via shortcut/process.start
if (!File.Exists(Environment.CurrentDirectory + "\\Multimanager.dll") && !File.Exists(Environment.CurrentDirectory + "\\Multimanager.dll"))
{
MessageBox.Show("You are missing the 'Multimanager.dll' and the 'Updater.dll'. Please re-run the MMInstaller.exe to re-download these files", "Missing files", MessageBoxButton.OK, MessageBoxImage.Warning);
Application.Current.Shutdown();
}
else if (!File.Exists(Environment.CurrentDirectory + "\\Multimanager.dll"))
{
MessageBox.Show("You are missing the 'Multimanager.dll'. Please re-run the MMInstaller.exe to re-download these files", "Missing files", MessageBoxButton.OK, MessageBoxImage.Warning);
Application.Current.Shutdown();
}
else if (!File.Exists(Environment.CurrentDirectory + "\\Updater.dll"))
{
MessageBox.Show("You are missing the 'Updater.dll'. Please re-run the MMInstaller.exe to re-download these files", "Missing files", MessageBoxButton.OK, MessageBoxImage.Warning);
Application.Current.Shutdown();
}
else
{
string MMV = Multimanager.MMShared.version().ToString();
string UV = Updater.UShared.version().ToString();
var u = new Updater.UpdaterWPF(MMV);
u.ShowDialog();
var mm = new Multimanager.UUpdater(UV);
mm.Show();
u.Close();
}
Edit: If I launch the program manually with the .exe it opens fine (Oh and IDK if it being a 64-bit application has anything to do with it)
Edit: This is my process.start Process.Start(path.Text + "\\Multimanager Launcher.exe");
and the path.text is the directory in the screenshot.
The shortcut was made using the code on this website here
Do not use Environment.CurrentDirectory
for dealing with DLLs. That's a horrible security flaw. Your application is searching for DLLs in the current directory, rather than the application directory. Hopefully, it's not loading them from the current directory, but this is something to be very careful about.
To get the application directory, you can use AppDomain.CurrentDomain.BaseDirectory
instead. This will not change depending on the (user configurable!) current directory.