Search code examples
c#visual-studio-2012sql-server-data-toolsfirst-chance-exceptionbuildmanager

BuildManager.Build Encounters First Chance Exceptions in SQL Server Data Tools Project


I am using the BuildManager.Build method to build a SQL Server Data Tools/Data-Tier Application Framework/Visual Studio Database Project. The same project, when built in the same configuration manually via Visual Studio builds without exception and in a relatively short period of time, about 10 seconds. However, when built programatically via BuildManager.Build, I encounter a whole slew of first chance exceptions, all of which seem to occur in the antlr namespace. This makes the build process extremely slow. Is this occurring because the program that is executing BuildManager.Build is running in debug mode? Does anyone know how to get rid of the first chance expections and hopefully speed up the build process?


Solution

  • The first chance exceptions are thrown in both cases it is just when you are doing it, for some reason, you are attached as a debugger to the child process which causes the process to freeze for each exception, pass control to your process which probably ignores it and restarts the app - running as a debugger when there are lots of first chance exceptions is very very slooooooooooooooow.

    The exceptions are thrown because SSDT uses Antlr (as you have probably guessed) to parse the T-SQL and it has found something it doesn't like.

    The key to this is finding out why you are attached as a debugger, is that normal with BuildManager.Build?? The msdn article isn't particularly helpful. If you can find a way to run the build without attaching as a debugger it will get it back to normal speed.

    FYI - The release / debug build shouldn't make any difference in this case.