Helixoft Blog

Peter Macej - lead developer of VSdocman - talks about Visual Studio tips and automation

Running a Visual Studio macro with long execution time

Recently, I needed to test some VS automation concepts in VS 2010. A simple task should be performed on several thousand files in a web site project. Loading the files in a web site is very slow so executing the macro takes a long time. I first tried it with only a few files and it worked correctly.

Then I tried with about 2000 files. And there was a problem. After several minutes, the macro crashed. Visual Studio only showed a message with COM error with some HRESULT code without any other details. I've placed a Try...Catch block around whole macro, hoping that I could catch the exception. No luck.

Obviously, I watched memory and GDI objects usage (GDI objects leaks are known problem when you programatically open files in web site projects). I found no problem with that.

Finally, I noticed one thing during one of the tests. Immediately before the macro crashed, an "Auto Save Layout ..." message was shown for a second in VS status bar. Bingo! It seemed that auto saving feature of VS caused the crash when the macro was executing. And really, when I disabled AutoRecover option, the macro successfully executed for 50 minutes.

So if you encounter the same problem, just go to Tools - Options - Environment - AutoRecover and disable the Save AutoRecover information option.

Comments are now closed for this entry

 

Start generating your .NET documentation now!
DOWNLOAD
Free, fully functional trial