Reputation: 631
I have developed a program for Windows 7 and it runs on my computer as it should (in release mode). However, when I copy and paste the project folder to my external HDD and try it on a different computer, it 'runs' but nothing really shows up. I will try to post relevant code:
class App : Application
{
[STAThread()]
static void Main()
{
new App();
}
/// <summary>
/// Starts application with splash screen
/// </summary>
public App()
{
StartupUri = new System.Uri("SplashScreen.xaml", UriKind.Relative);
Run();
}
}
Even though this screen is never visible, my MessageBox is shown.
//constructor
public SplashScreen()
{
//generated method
InitializeComponent();
System.Windows.MessageBox.Show("WHY ME??");
mw = new MainWindow();
mw.Show();
}
After the splash screen, the main window should open, but it doesn't AND this MessageBox never shows up.
public MainWindow()
{
//Windows generated
InitializeComponent();
System.Windows.MessageBox.Show("WHY ME??");
}
As I mentioned, the program runs as it is supposed to in both release and debug mode, but then when I bring it to another computer it only shows "WHY ME??" once instead of twice like it should. Any ideas?
Upvotes: 2
Views: 1166
Reputation: 631
Turns out there was a lot wrong with my code. One of the largest problems I had was hard-coded file paths to the computer it was running on. However, what really helped me with all computer-migration related problems was adding the following code to each class:
In Constructor:
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Create handling function:
void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
System.Windows.MessageBox.Show(e.ExceptionObject.ToString());
}
It is slow and tetious however it does a pretty good job of assisting in locating source of problems. So there was multiple things wrong with my program, but adding the above code helped solve a lot of issues.
Upvotes: 2