Jesper Niedermann's .NET Blog
about .NET and related technologies RSS 2.0
# Wednesday, 11 March 2009

Currently I am looking into taking over a huge enterprise legacy system written mostly in C#, but also some C++. The numbers are staggering several million lines of code, 1200 GUI screen, mostly WinForms, about 750 C# projects, 150 solution files, just to mention a few. In all about 4 times larger than the largest enterprise system I have previously been working on.

Just building and deploying the system is a pretty big task since due to events beyond my control I basicly only have the sourcecode and nothing else. Not quite true because there are some documentation, but buried in the thousands of files.

When I managed to modify a build file and build the entire monster with it, it took 2½ hours to complete.

I won't even try to include all projects in a single Visual Studio file. I wonder if it would load ? This gives me a problem though. How about debugging ? I cannot press F5 for any of the visual studio projects because the build process using the build file set up a ton of config files with IP adresses, connection strings and the like. So it doesn't make sense to run the thing from Visual Studio.

But if I start up the exe assembly how do I attach a debugger ? Well, I decided to use a simple trick. I added a line of code in the top of the main() method:

static void Main(string[] args) 
{
Debugger.Break();
...

Debugger.Break() is basicly a programmatic breakpoint, but it is more than that. If no debugger is attached it asks the user for a debugger. Smart! And for the process to debug I can just choose the Visual Studio process with the project containing the exe assembly. Henceforth the control is mine.

I could even consider writing this method and using it instead:

[Conditional("DEBUG")]
private static void DebuggerBreak()
{
if(!Debugger.IsAttached)
Debugger.Break();
}

This gives me the advantage that the IL code is only build in DEBUG mode and that the Debugger is only attached if one is not attached already.

Wednesday, 11 March 2009 06:23:39 (GMT Standard Time, UTC+00:00)  #    Comments [0] -
.NET | Tips & Tricks
Comments are closed.
Archive
<2017 June>
SunMonTueWedThuFriSat
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678
About the author/Disclaimer
I am a software architect with focus on Microsoft Technologies. I have been working with these in different large companies since 1995. I am currently employed at UVdata A/S.
Here is my View Jesper Niedermann's profile on LinkedIn

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Privacy policy
The privacy policy of this site.

© Copyright 2017
Jesper Niedermann
Sign In
Statistics
Total Posts: 28
This Year: 0
This Month: 0
This Week: 0
Comments: 32
All Content © 2017, Jesper Niedermann
DasBlog theme 'Niedermann' created by Jesper Niedermann, based on 'Business' created by Christoph De Baene (delarou)