Monthly Archives: January 2008

Having C# Code Launch the debugger

Sometimes you have a library running outside of your traditional debug mode, but would like to call into it with a debugger. I specifically ran into this with a custom installer dll called by a custom action in my MSI. The following code will allow the process itself to request debugging. Then you can specify your favorite debugger, and you’re on your way.


(The #if DEBUG / #endif, tells this only to be apart of the debug builds.)

LINQ “gotchas”

I am using VS 2008 and LINQ (specifically LINQ to SQL) for a project at work right now. As I jump into this, I am going to document some of the pros, cons, and “gotchas” that I come across. Any articles in this series will have the label “LINQ” .

Here is my first list of LINQ Gotchas:

EntitySet completely loads.
Be aware that when you reference a property on an EntitySet such as Count, you will cause the entire EntitySet to be populated. For Example: Order.Products.Count will cause all the Products for that Order to be returned from the database.

Add and Remove renamed for RTM.
In previous releases (through Beta 2) of LINQ, entities had Add and Remove methods. To help better describe what the methods do, for the official release, Microsoft renamed these to InsertOnSubmit and DeleteOnSubmit, respectively. So if you use code from a Beta, be careful. For a list of key changes see this forum: .

Mixing Entities from different DataContexts.
We have created a framework where business objects load themselves using LINQ. One gotcha here is if you get objects from different DataContexts, you can’t mix references. For instance if an object (a) from table A and one (b) from table B that come from different contexts, you can’t say A.Bs.Remove(b). Or b.A = a. (with a foreign key relationship between those tables). I have more testing to do here, but sometimes an exception is thrown, other times, a new “clone” object has been inserted into the DB. Either way…it’s not a good idea. In another post, I will describe our framework and discuss how we avoided this problem.

Manual VM Ware MAC Addresses

VMWare workstation will automatically generate MAC addresses for your virtual machines to keep them from colliding.

If you need to set it manually you must change a few lines in the .vmx configuration file.

change: ethernet[number].addressType to “static”
change: ethernet[number].generatedAddress to: ethernet[number].address and set your address.

delete any other ethernet[number].generated*

for more information:

MS SQL Server Editions

Microsoft has several different versions of SQL Server 2005. If you are looking for a truly enterprise solution, you’ll have to shell out the money for that one. Otherwise, many times one of the lighter versions can be sufficient. Here is a link to a Microsoft page outlining the specific differences between each version:

And here’s the link to the pricing:

Building big projects in Visual Studio

For a project at work we were building deployment projects for some fairly large web applications. 300-600 MB after compression on disk. When the deployment project would build, it would fail with the following result:

“ERROR: Could not find file ‘ ‘Not enough storage is available to complete this operation.'”

After googling around, I found this was an out of memory error, which surprized me, as we were building the project on machines with 4 GB of physical RAM and > 100 GB free on a hard drive. Surely a 600 MB install shouldn’t max out those limits even using temporary space during compression!

Some suggested rebooting, or restarting Visual Studio, which did help with some of the smaller builds, but the bigger ones still failed.

Finally, a coworker of mine, Kevin (way to go!), tracked down what was really going on. There is apparently a hard limit of memory per process in windows of 2 GB. And between everything else that was going on in visual studio and our compression process, we were just barely crossing this threshold. The following resolution solved our problem by increasing the limit to 3 GB.

  1. Backup the boot.ini file. Then, put the /3GB switch in your boot.ini For more information on the /3GB option, please check the following article: Memory Support and Windows Operating Systems:
  2. Make DEVENV large address aware.
    1. Open up a VS 2005 command prompt
    2. Change directory to the Microsoft Visual Studio 8Common7IDE directory.
    3. Backup devenv.exe file.
    4. Type and execute the following command line: “editbin /LARGEADDRESSAWARE devenv.exe”
  3. Reboot Windows and Build.

After doing this, the build succeeded with no problem.

FTP access to pages

Comcast provides free basic hosting for html pages to its users on service. They have designed it such that you can use fancy web pages to manage your pages, but this is a pain in the neck if you already know what you want to do and are more than a beginner.

On their help pages, it mentions that admin users can ftp to their account, but it took quite a bit of digging to find the exact address you use.

Give it your username and password (different from your account username and password) and you’re good to go.

I use FileZilla, and it seems to work like a charm. It has a very short timeout / disconnect, but other than that it allows me access to my pages without having to use their html interface.