locked
WPF app crashes launching via double click RRS feed

  • Question

  • I am working ona small, simple application.  The data for the application is stored in xml files (that if have changed to .ord files).  In my setup project, I added .ord extensions via the File Types Editor, to allow uses to double click a .ord file, and have this app launch and open the file.  In my Loaded event for the only window of the application, I check the command line args via Environment.GetCommandLineArgs() and look for an argument ending with ".ord" to handle loading the file.

    However, whenever the application is launched via the double click on a data file method, it just crashes and I get the famous "Send / Don't Send" dialog.  If I launch the application normally (double click it's shortcut or executable), it works fine.  If I open the application, and drag my data file onto it, it opens fine (using the same load file method).

    I don't think it has anything to do with my handling / checking of the command line args, because it crashes even if I remove all of those handlers, and just have the application open without doing anything.  It seems to have something to do with the simple fact that the application is being launched via a double click.  I have also removed all the file association setups from my setup project, and manually added a "open with" in windows for .ord files, and it still crashes.  Has anyone else experienced this problem?
    Tuesday, February 19, 2008 5:48 PM

Answers

  • OK, I think I have tracked it down.  In my code, I have some static properties that are filled by loading data from xml files.  They are loaded by calling Environment.CurrentDirectory.  However, when double clicking the data file, CurrentDirectory returns as the location of the double clicked data file, not the application executable, causing my static properties loading procedure to blow up.
    Tuesday, February 19, 2008 6:13 PM