locked
Open File With Program Crashes RRS feed

  • Question

  • I understand that when you open a file with a program, the file name is sent to Environment.CommandLine. I have not been able to test as my program crashes whenever I click on a file that is associated with my program. I created an installer and setup a file association using Visual Studio's setup project. For starters, how can I debug this? Can I specify a debug session that starts in a program? Or is there a known issue with how setup projects creates file associations?

    Thanks,
    David

    • Moved by Neddy Ren Tuesday, August 23, 2011 8:17 AM (From:Visual C# General)
    Sunday, August 21, 2011 1:19 AM

Answers

All replies


  • See this blog on how to pass the filename as a command argument in the debugger: http://csharp.2000things.com/2010/06/30/specify-command-line-arguments-in-visual-studio-2010/

    --
    Mike
    Sunday, August 21, 2011 11:24 AM
  • I was able to open with by sending the file name to the command line. But it works fine in the debugger. Is there something wrong with file associations in the setup project? My program works fine after being installed, it just crashes when I try to open its file with the program by clicking on the file in Explorer.
    Monday, August 22, 2011 9:45 PM
  • System.Diagnostics.Debugger.Launch();
    • Marked as answer by DavidBr101 Saturday, August 27, 2011 3:14 PM
    Monday, August 22, 2011 9:49 PM
  • Hi David,

    please attatch to AppDomain.CurrentDomain.UnhandledException and Application.Current.Exit events to catch unhandled exceptions and to get mor info.

    I hope this is helpful, please let us know if you found out something.


    "It's time to kick ass and chew bubble gum... and I'm all outta gum." - Duke Nukem
    Monday, August 22, 2011 10:04 PM
  • Hi DavidBr101,

    Welcome to the MSDN Forum.

    On how to debug a windows Installer file, see the answered thread below:

    http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/e91e098a-96c3-4810-b641-22070d44b302/ 

    On how to registry file type when installing, See the following articles on MSDN:

    File Types Management in Deployment:
    http://msdn.microsoft.com/en-us/library/s3a0ddk6(v=VS.100).aspx 

    If you have any questions, please feel free to tell us.

    Best Regards


    Neddy Ren [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by DavidBr101 Saturday, August 27, 2011 3:15 PM
    Tuesday, August 23, 2011 8:24 AM
  • Hi David,

    any update on this? Did you catch the unhandled exceptions?


    "It's time to kick ass and chew bubble gum... and I'm all outta gum." - Duke Nukem
    Friday, August 26, 2011 3:44 PM
  • Ya I got it. I've just been away from internet for a while. Debugging revealed that the command line changes so that I cannot load content. Anyway I worked around it by specifying the program directory for content instead of wherever the program starts.
    Saturday, August 27, 2011 3:14 PM