Question

I have created a custom file type that is recognized by my application, and I would like to know what event is triggered when I open my application by double-clicking a file of this type. I have placed breakpoints at the beginning of handlers for Form.Shown and Form.Load, as well as at the beginning of the form's constructor, but the application never hits the breakpoints.

Was it helpful?

Solution

If you're opening the application by double-clicking on the file in your computer's filesystem the debugger built in to Visual Studio won't be attached to the application's process and so won't break at your breakpoints. You can attach the debugger to a running process, but what you're talking about happens fairly quickly, so you will almost certainly not be able to attach to the process fast enough to set your breakpoints and catch the execution as it passes them.

Ultimately, the events triggered when you open your application via a file association is no different to opening the application by running its executable file.

OTHER TIPS

For using that file : Just get your file from commandline args and process it on which event you want. My.Application.CommandLineArgs

After this if you want to debug: You can put that arguments inside Properties-Debug- Start Options -Commandline arguments (argument will be your file) and put breakpoint on the event where you were processing that file

Happy debuggings

If you're creating your program as a Single Instance Application, then you'll receive the Startup event for your first instance, and the StartupNextInstance event for each subsequent invocation.

Each of these events hangs off of My.Application and provides the command line parameters that were passed to each invocation.

If you're not using a Single Instance Application, the Startup event is still available.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top