Reputation: 738
I'm deploying a C# .NET application using ClickOnce and I have written code to update the application programatically (not using the option in the publish settings of the project).
However I want to test the functionality of this code before deploying (for obvious reasons). How do I do this? The code has a check to see if the application is network deployed and when running debugging sessions this flag is false. And accessing ApplicationDeployment.CurrentDeployment results in an exception being thrown.
Upvotes: 7
Views: 2909
Reputation: 1209
You can to debug it after adding such code:
System.Diagnostics.Debugger.Launch();
This will show you a dialog that allows you to select your debugger to attach to.
Upvotes: 10
Reputation: 1062745
I wonder if you could publish it to your dev server, run it from there (so it counts as network-deployed), and then attach your IDE to the process? (Debug -> Attach to Process)
If your update code runs early in the system, you can introduce a pause; for example, I tend to use boiler-plate that checks (in Main
) for ctrl+alt and displays an additional debugging console (for example, showing web-service calls as they happen, making it easy to debug connectivity issues on a live system by walking users through "hold these keys... now what does it say when the bug happens?"). By the same logic you could show a MessageBox
("debug moode; attach your debugger now").
Upvotes: 4