Need to send email notification on visual studio run - visual-studio

I'm executing a test-execution project using visual studio 2005 (using the pnunit framework and C# but its not relevant). The total execution time is more than 40 hours. In between if there are any environment problems on the network (external factors like remote server is down, db is down etc) the code stops executing. This creates a problem because when I notice the error I'll have to manually set external factors right and again resume the run. So it becomes important to keep checking the execution progress frequently to make sure we are not losing time due to halted execution, which is troublesome.
I looking for a way to somehow either triggering an email/batch script/exe/anything when the code stops running. Is there any way I could achieve this? Any ideas?
Thanks,
Mugen

If you only need to trigger an email at the end of the application, then I would suggest putting the code here at the end of your execution.

Related

Stop iisexpress site when I stop debugging it? VS 2010

I have a VS2010 web project that I debug with iisexpress.
Sometimes when stepping code I notice something wrong that would have undesirable effects, e.g. in my 70 Gigabyte database, so I want to stop the code.
My reflex action is to stop debugging in VS2010, but this has the effect that the debugger detaches from the process, and that causes the code to continue running at full speed and do that thing I wanted to avoid.
So, is there any way to get the site to stop instead of continue running at full speed, when I stop debugging in VS?
Note: I don't lose any data or anything - it's safe test data. But due to the large database size, restoring a new test database is a big waste of time.
Note 2: I know I can stop iisexpress in various ways instead of stoppping the debugger in VS. The problem is that I keep forgetting this, and remember only after the damage is done.
So, please, no suggestions that tell med how to stop iisexpress manually or how to protect my database. Only try to answer the actual question: how to AUTOMATICALLY stop the site from executing when I hit "stop debugging" inside VS. That's it.
Other than with a third party or otherwise bespoke program (or script configured to run on debugger attachment (?)), let me disregard your demand to only answer the question exactly and provide another thought at least...
In an emergency, step through the code with the debugger and upon noticing the potential detriment manually move the execution scope to, say the end of the method, essentially skipping the code you don't want to run.
So, say if a page does something in the load event, move to the closing brace of the event handler code and then continue, the page will load minus the code having been executed.

Visual studio process Unable to copy file

i have a visual studio 2010 , when i run project normal runs, and when i close window then make some changes and run, they says
"Error 5 Unable to copy file "obj\x86\Debug\Passport.exe" to "bin\Debug\Passport.exe". The process cannot access the file 'bin\Debug\Passport.exe' because it is being used by another process. Passport"
as i see in Passport.exe still in task manager. why?
(when i end that process again i can build project)
NOTE for my other projects no that problem, only for this.
Many thanks who can help :)
There are many reasons why this could happen, but basically it boils down to your passport process or a child process of it, not closing as soon as you "close the window".
Things to check:
1. Extra threads not being terminated (worker threads not complete etc.)
2. Debug, breakpoints causing closure process to hang.
First I would remove all breakpoints and then look at what processes you may be running that could be holding up process closure e.g. worker threads, file writing, hardware access.
Sometimes it's best to kill processes using the stop button in Visual Studio.

program to monitor other programs

EDIT:::
I wonder if anyone has ever given this some thought or have some ideas about it. Like most of you I have multiple programs running at the same time. I have set up alert methods in each such that I get email alerts when a program stops or runs into errors. Now some of these programs use visual studio TaskFactory class to create parallel tasks and I have coded exception handling to handle errors. But I am sure some of you have encountered instances where a program /process will halt for some reason and unless you are constantly sitting at your pc and checking some log file, there is no way to know if the program is running at that time or not.
so before many answer with...."Task Manager"...I wanted some intelligent ideas on ways of having your program notify you when it is stuck in some process or fails with some error an exception handler has not caught...if nobody runs into these types of cases then I guess I will just forget about it. Is there a way to interact with the task manager processes using visual studio, vb/C#?
How does this differ from the basic Task Manager included in Windows?
If you want to make your own metrics to monitor you can create Performance Counters: http://www.blackwasp.co.uk/SetPerformanceCounters.aspx
Do you mean Task Manager? Ctrl+Shift+Esc in Windows.

What's the advantage for 'attach to process' compared with 'Start Debugging'?

I am new to programming.
I know only Start debug before. Maybe start debug suit for some small application develop better.
I found Visual studio IDE provide another method of attach to process for using.
When & Why must I use the attach debugging?
Such as multi-threading application debugging. Client/Service application debugging. etc. Thank you.
Sometimes you need to debug a process started by another program.
For example you need a reliable solution and in order to protect against access violations, memory leaks and other barely recoverable stuff, you have a master program and several worker programs. The master program starts the worker program and passes parameters to it. How do you debug a worker program which is not intended to be started by anything except the master program?
You use "attach to process for that".
Typically you do it this way: insert a statement that blocks the worker program for some time - for example, call Sleep() for 15 seconds. Then you kindly ask the master program to start the worker program. When the worker program is started it blocks and you now have 15 seconds to attach to it.
This way you can debug almost any issues - problems at early startup stages, wrong parameters, etc, which you wouldn't reliably reproduce with "run with debugging".
Attaching to a process is useful if you don't want to debug right from starting the process. For example, debugging usually slows down execution, so it can be quicker to start the app, get it to a state where a bug appears, and then attach a debugger.
It's also useful if you already have an external means of launching the process that you don't want or can't to import into the IDE.
Start debugging from VS launches an instance of the VS webserver and attaches the debugger to it.
Attach to process allows you to attach to any process and debug it, usually you'd do this to your instance of w3wp.exe running your code in IIS
Attach to process is mostly used when you can't run the application from Visual Studio.
For example, if it's a service or if it is a process that has run for a long time and now you want to start debugging it.
Sometimes you also want to debug a remote process, not on your machine - and you can do that using attach to process.

Retain Windows Error Reporting Dumps from Hung Application

An application is hanging occasionally, and I would like to see the dump at the time to figure it out. I had written an application that the user can run to automatically create a dump that I can look at. However I can't seem to get the users to remember to run it when it hangs, no matter what I try. They always end up closing the program, which invokes Windows Error Reporting.
WER will create dumps in the temp directory, but unfortunately they are deleted as soon as the dialog for sending the info to Microsoft or not is closed.
Becoming an ISV and getting this info from Microsoft's error reporting servers is one solution.. but not one that is realistic at the moment.
I can't imagine that I am the only one faced with this issue. The software is used concurrently by dozens upon dozens of staff, so reaching them all and getting them to run an application or not click close on that dialog until running some other application or etc has not been working out.
The app is running on Windows Server 2003. Too bad, since I know Server 2008 has some LocalDumps options that will let me retain them.
Any ideas for somehow keeping these dumps around so I can analyze them? The obstacle is the user, in the sense that I've accepted to their stubbornness and do not expect them to run any other application or do anything special.
Thanks for any advice!
You could opt for an automatic solution. I believe there're multiple options at your disposal for detecting if you're hung.
One would be the use of SendMessageTimeout (also pay attention to SMTO_ABORTIFHUNG as one of the fuFlags values) from a separate thread in your app. Once you have determined the main thread is not responding you can save a dump file wherever you want.
There's also a IsHungAppWindow() (user32.dll) available since w2k.

Resources