Over the past couple of days myself and a colleague, Tim Haines, have been grappling with what seemed like an surmountable problem at times. I say we...its been more Tim - he's done a great job in uncovering some inherent problem in Visual Studio (seemingly).
A bit of background. We are building some .net web services that consume and make available data as provided by SSIS packages. This means that the packages are executed from within .net. We were seeing a problem where this code would work on a given machine and then could be ported onto another machine, run in exactly the same way, and cause some inexplicable errors within the SSIS package. To make it even worse we saw examples of running code successfully, making some changes and then CTRL-Zing to get back to the original code - and that same code then failing. On the same machine!!! Bizarre.
Well after much trial and error Tim finally found the problem. It seems that the code would run successfully in Visual Studio until such time as you make an innocent change that causes a failure (e.g. We were passing parameters to the package on which we sometimes got the syntax wrong) and thereafter the package would never again get successfully executed - even by rolling back to the previous successful version of the code. We eventually learned that the only way to fix the problem was to simply shut down Visual Studio and start it up again. The code would then execute successfully again until such time an error occurs and thereafter the code would never work again until a shutdown of Visual Studio.
We certainly can't begin to explain why this should be the case but we are happy that we have uncovered the problem and, crucially, a solution. Perhaps Visual Studio somehow caches execution state, perhaps there's a bug in Visual Studio - who knows? But it works for us now and that's all that matters.
If you experience similar problems - please let me know!
-Jamie