Open Command Window Here Power Toy

If you liked the idea of quickly launching command windows, but want the window separate from your explorer shell you should look into Microsoft’s free “Open Command Window Here” Power Toy.

You can find it and other power toys for XP at http://www.microsoft.com/windowsxp/downloads/powertoys/xppowertoys.mspx or http://shrinkster.com/kuy. The description is about halfway down, on the right side of the page are links to the downloads.

If you are a Visual Studio developer, you’d probably like to have a version of this to create a VS Command Window. No problem, Scott Hanselman has created some inf files you can use to create these. Find them on his blog at http://www.hanselman.com/blog/VisualStudioCommandPromptHereAndSearchUnknownFileExtensions.aspx or http://shrinkster.com/kuz.

Coding Standards

Every development organization should have a set of coding standards they follow. A clearly defined, written set of guidelines their developers follow. Things that will make it easier for one developer to read another’s code.

The fine folks at subMain have scored another hit by releasing their coding standards to the general public. (http://submain.com/?nav=products.guidelines) On their site they are now giving away in PDF form a copy of their own corporate coding standards.

I really like their document, as it goes far beyond the traditional “use pascal case” type documents. Their standards document gets into advanced topics such as design patters, security, threading, and even code reviews. It’s applicable to both VB.Net and C#.

While no coding guideline will ever be on the best seller list like Vince Flynn or Richard Marcinko, I found this to be well written and organized. It was easy to find what I wanted, each point laid out distinctly. I do wish there was a little more example code, even if was examples of what not to do. However, I consider that a minor nitpick for an otherwise complete document.

If your company has a standard already, you should check it against the subMain one to ensure you didn’t miss anything. And if you don’t, you should seriously consider the adoption of these standards for your own.

Be sure to check back with them in the January / February 2007 time frame, as Serge (subMain’s President) indicates an update will be available with a rewrite of the Control Naming Guidelines, and possibly some updates to the database section as well.

All in all another great contribution to the .Net community for subMain.

Note I last mentioned subMain on November 27th, writing about their Smart Outliner for VS.Net free add-in. (https://arcanecode.wordpress.com/2006/11/27/vs-add-ins-smartoutline2005/)

Installing Ubuntu on VirtualPC Step by Step

Update: October 18, 2007 – Version 7.10 is now out. Complete step by step instructions on installing 7.10 can be found at:
https://arcanecode.wordpress.com/2007/10/18/installing-ubuntu-710-under-virtual-pc-2007/


Update: I’ve now determined how to get Ubuntu 6.10 working on VirtualPC 2007. If you are interested in the latest version, see my new post on February 26th, 2007 at https://arcanecode.wordpress.com/2007/02/26/installing-ubuntu-610-on-virtual-pc-2007-step-by-step/ or http://shrinkster.com/mff. Note there is still value in installing 6.06, as it’s the version of Ubuntu that will have long term support, and thus be the Linux of choice by many corporations. Also note that while the instructions below were written with 6.06 and VirtualPC 2004, the instructions are the same for 6.06 under Virtual PC 2007. So you’ve decided you’d like to try a Linux distribution, but don’t have a computer to dedicate to it. Further you’re understandably reluctant to mess around with your partitions and try and get dual booting to work. No problem, Virtual PC to the rescue.

First, you will need to obtain a copy of a Linux distribution. One of the most popular today is Ubuntu. Ubuntu uses the Gnome desktop for an “Apple like” feel. There’s a variant called Kbuntu which has a much more Windows like look and feel. If you are interested in Mono development (Mono is the open source implementation of the .Net Framework) be aware you will want to use a Gnone desktop, and thus Ubuntu, as my understanding is all of the Mono tools were designed for Gnome.

For this tutorial we’ll be using Ubuntu. To obtain your copy of Ubuntu, simply go to http://www.ubuntu.com , click on the downloads link, and select Ubuntu. I would recommend you use version 6.06, which is the long term supported version. I attempted to use the current version, 6.10, and had major issues with the graphics.

Key Point: Use Version 6.06, not 6.10.

Be aware the image is around 650 Meg in size, so have a good high speed connection. If you are on a dial up, check your newsstands for various Linux magazines. Each month ever one of the Linux magazines comes with a DVD loaded with a variety of distos (Linux speak for distribution).

Once you’ve downloaded the ISO image, you have two choices. First you can simply burn to a CD, using your favorite CD burning software. Make sure you tell it you want to burn from an image, if you just write the ISO file you’ll have a disk with an ISO image, but it will not boot.

Your second choice, the one I’d suggest is to use the Microsoft Virtual CD drive. I blogged about it back on September 13th (https://arcanecode.wordpress.com/2006/09/13/virtualization/ ). Read this post to see how to use it, then jump back here.

Back? Cool. Launch the Virtual CD app, with a drive letter assigned to your Ubuntu image. For this tutorial I’ve mapped my Ubuntu to drive Z.

Now that you have Ubuntu ready, you need to go read my VirtualPC Step by Step post (https://arcanecode.wordpress.com/2006/09/20/virtual-pc-step-by-step/ ). Keep it handy as I will be referring to it frequently for this tutorial.

In Step 1 you are instructed to create a new machine, do so. I’ve named mine “Ubuntu 6.06”. In step 2, you are prompted for your OS. You will need to pick Other. In step 3, you are asked about Ram. Ubuntu will run OK under 256 megs, however if you have the available space I’d suggest upping it to 512, especially if you intend to get into doing some graphics or mono coding.

In step 4 you will want to create a new hard disk, and in step 5 confirm what you’ve selected. OK, now you are up to step 6, installing the OS, which is where this tutorial picks up.

Launch your new Ubuntu 6.06 VPC. (Click on it in the VPC and click Start). When it starts, click on CD, Use physical drive Z: in the menu. In a moment you’ll see a menu that looks like this:

[Ubuntu VPC 1]

Select the “Start Ubuntu in safe graphics mode” option. It’s very important you pick this option, if you take the default “Start or install Ubuntu” you will get garbled graphics under VPC.

OK, now you have watched the Ubuntu screen flash as it loads, now you should see a screen like this:

[Ubuntu VPC 2]

While it looks like it, be aware you have not installed Ubuntu. Instead, you are running in what is known as “Live Mode”. This is a feature that is common to most CD distributions of Linux. In Live Mode you can boot your computer and use a Linux distribution without having to install.

Installing is just what we want to do, and Live Mode makes it easy. By now you’ve probably noticed the big icon that says “Install”. Let’s double click this.

[Ubuntu VPC 3a]

The first thing you are prompted for is the language you want to use. Select the language most comfortable to you, then click Forward.

[Ubuntu VPC 3]

Next you are asked for the city near where you live. You can select your city by either clicking on the map, or selecting from the list. After doing so you will want to set the time, just click on the Set Time… button to do so.

[Ubuntu VPC 5]

In step 3 we are prompted for the keyboard layout. Since my default is already selected, all I have to do is click Forward, otherwise you should pick your layout and click Forward.

[Ubuntu VPC 6]

Now Ubuntu needs to get some personal information. Just your name, what you want your login name to be, and the name for your computer. Enter your own information here, then write them down! OK, now you can click Forward.

[Ubuntu VPC 7]

Getting close, now in step 5 we’re asked about the disk space. Your two options are to install to the entire partition, or manually edit. Since this is a virtual machine, we’ll just take the default of “Erase entire disk:IDE1 master (hda) 17.2 GB Virtual HD” and click Forward.

[Ubuntu VPC 8]

OK, we’ve finally reached the final step of our install wizard. Just assure yourself that your selections are correct, then click the Install button.

[Ubuntu VPC 9]

As Ubuntu installs you’ll be able to monitor it via a progress bar:

[Ubuntu VPC 10]

When the install is done, you are asked if you want to restart, or continue using the Live CD. Let’s pick Restart Now.

[Ubuntu VPC 11]

Now during the reboot I got to the Ubuntu logo screen, then the VPC just sort of stopped. I wound up clicking the red Cancel x to close the window, and picked turn off. I then returned to my VPC console and clicked Start to restart my Ubuntu machine.

Once Ubuntu is running, you are first prompted for your Username. Enter the user name you provided during the install and press enter when done. Then do the same with your password, pressing enter when you’re done. Ubuntu will crank and grind, then come up to the desktop, and you’re ready to go!

I’m not going to go into details on how to use Ubuntu, but I will point out a few things. Let’s take a quick look at the desktop.

[Ubuntu VPC 12]

Starting in the upper left, you’ll see the menu:

[Ubuntu VPC 13]

The Applications menu is where your programs reside. Preinstalled is the Open Office suite, Gimp photo editor, and lots of neat games.

Places is sort of like My Computer, through it you can get to your personal folder, the network, CD / DVD drives, and more.

Through the System menu you can tweak your system settings, similar to Control Panel.

Next to the System menu is a little globe, this will launch the Firefox web browser. To it’s right is an open envelope, you’ve probably guessed this will launch an e-mail program.

By now, you’ve probably noticed this little announcement:

[Ubuntu VPC 14]

If it went away, just click on the orange icon you see on the screen. This is the notification icon, and will let you know of updates, system messages and more. Through the internet you can download the latest updates to Ubuntu. By the way, next to it you’ll see a little speaker icon, this is the Volume control.

Finally, you’re probably asking yourself how the heck you shutdown in Ubuntu. You can exit safely in one of two ways. First, on the upper right you probably noticed this red icon:

[Ubuntu VPC 15]

This is the shutdown icon. You can also select System, Quit from the System menu.

There you go, all the steps you need to get up and running with Ubuntu. Both it and Virtual PC are free, so you have no excuse to start experimenting with Ubuntu today.

Adding a Second Hard Drive to VirtualPC Step by Step

Microsoft Virtual PC defaults the hard disks for it’s virtual machines to 16 gig in size. For most instances that’s large enough, but you could have cases where you simply need more disk space. Or, perhaps you’d like to keep your demo or project code in a separate virtual hard disk than the main virtual disk your applications run on. Regardless of your reason, creating a second hard drive for your virtual machine is fairly easy.

A few up front points, in these instructions I’ll be doing what I believe to be the most common scenario for most folks and be using Windows XP for my guest system.

First, before you launch your Virtual PC click on it once and select the settings button. Now go to Hard Disk 2. Change the option button from “None” to “Virtual hard disk file”. Next, click on Virtual Disk Wizard.

The first screen is simply the welcome screen, just click next.

[Second VHD 1]

On the next screen it asks about disk options. Take the default of “Crate a new virtual disk” and click next.

[Second VHD 2]

You are now asked about what type of disk you’d like to create, a hard or floppy disk. Take the default of “A virtual hard disk” and click next.

[Second VHD 3]

Now you are prompted for the name and location. I stored this with my other VHD files, so enter the path and location you want and click next.

[Second VHD 4]

The next screen asks what type of drive you want to select. The default, “Dynamically expanding” is the default, and is what we’ll be using. This is a great option as it puts a small file on your drive and lets it slowly expand as you need it to grow.

“Fixed size” creates just what it sounds like, a fixed size hard disk. The one main use I could think of is to create a virtual disk the same size as a DVD. You can then store your files on it prior to burning to a DVD. Downside is that the drive always takes the same amount of disk space.

“Differencing” is a big topic, but in brief a differencing drive is based on another VHD file. Once you create a differencing drive, the original is locked and cannot be changed; all changes are written to the differencing disk. Why would you want to do this?

Well let’s say you were teaching a class and wanted to let the students work on labs. You’d create your base image with your software loaded, and then create a differencing disk. Your students would write their changes to the differencing disk. After that class was done all you have to do is create a new differencing disk instead of having to recreate your entire disk image.

Final is linked to a hard disk. It saves your info out to the real hard drive. This is considered an advanced option, and to be honest I haven’t experimented much with it so that’s all I’ll say for now.

As I said, we’ll go with the default for now, and pick “Dynamically expanding”. Click Next to continue.

[Second VHD 5]

Next we are prompted for the maximum size of the VHD. In this demo we’ll take the default of 16 gig and click next, however if you’d like to change it go ahead, enter the maximum number of megabytes you want, when you’re done click Next.

[Second VHD 6]

OK, you’re up to the final screen, this just asks you to confirm your choices. Click on Finish to complete the process.

[Second VHD 7]

You should see a small message saying you’ve created the disk. Just click Close to close this message.

[Second VHD 8]

Now that you’ve created your drive, you need to tell Virtual PC to use it. If you recall, in the settings window we’ve already selected the “Virtual hard disk file” option. Now click the Browse button and pick the vhd file we just created.

[Second VHD 9]

OK, now we’ve got Virtual PC all setup. Click on OK to close the settings, then click on Start to start the Virtual PC. Once you’ve logged in, open up a My Computer window. Here’s a snapshot of mine.

[Second VHD 10]

OK, I can hear you now. “Hey, I created another drive, where’d it go?” Well, it’s there, the problem is you haven’t formatted it yet so Windows XP doesn’t know what to do with it. Let’s fix that now.

Open up Control Panel, and go into Administrative Tools. Now double click on Computer Management. Now click on Disk Management under Storage in the tree. The minute you do, you’ll be presented with the “Initialize and Convert Disk Wizard”. After taking a look at the opening screen, click Next.

[Second VHD 11]

The next screen asks which disks you want to convert. Here, you see Disk 1 is selected, which is correct (your C drive is disk 0, then each additional drive is 1, 2, etc.) Click Next.

[Second VHD 12]

Now it asks about converting disks to Dynamic disks. Check this on, and pick next. (Note in the pic below I haven’t checked it on yet, you will need to.)

[Second VHD 13]

Finally, you are presented with the Finish window. Click Finish to complete.

[Second VHD 14]

Now the window shows Disk 1 as initialized, but it’s still not quite ready to use yet.

[Second VHD 15]

Hang on, we’re almost done. Right click in the Disk 1 area, and select New Volume. This launches the New Volume wizard. On the opening screen just click Next.

[Second VHD 16]

Now you are presented with the Select Volume Type. Simple is the only option enabled, so let’s just select Next.

[Second VHD 17]

The next screen is prompting you to see how much disk space you want to allocate to this new volume. In our case we’ll use all the space, so we’ll just click Next.

[Second VHD 18]

In the next dialog we’re asked what drive letter to assign to our new volume. You can pick any available letter, but I think I’ll just take the default of E and click Next.

[Second VHD 19]

Now the wizard will prompt about formatting. We need to format this drive, so we definitely want to do this. I did change the default volume label from “New Volume Label” to “VSDriveE” since I’m using this with a vhd I use for Visual Studio. However, you should name it something appropriate to your use. Other than that, I’m leaving the other options alone and clicking Next.

[Second VHD 20]

Finally we’re nearing the end. The next screen is the “Completing the New Volume” wizard. Here we are simply confirming our choices. Take a quick look, if all looks well, click Finish.

[Second VHD 21]

While it formats, it will show you the progress in the status window, as you see below.

[Second VHD 22]

OK, that’s it, you’re done. Close the Computer Management window, then the Administrative Tools window. When you return you new computer, you will see your new drive, ready to go!

[Second VHD 23]

Well there you go. Seems like a lot of steps, but it took a lot longer for you to read this than it will take you to actually do it. If you do create new drives, drop a comment and let us know what creative uses you use your second drive for.

Customizing Visual Studio – Shortcuts to Commands

One of the great things about Microsoft is the way all of their stuff is extensible. For years folks have been writing macros, add-ins for the office tools. In case you hadn’t noticed, Visual Studio is just as extensible as the rest of the Microsoft tools.

In this first article, we’ll look at making a shortcut to a handy VS command. First, we’ll need to fire up SlickEdit Gadgets Command Spy tool. What? You haven’t installed it yet? OK, go read my blog posting from November 14th (https://arcanecode.wordpress.com/2006/11/14/visual-studio-add-ins-slickedit-gadgets/ ). The rest of us will wait.

Back now? Great. OK, as I was saying fire up Command Spy. You’ll see it’s window appear, just slide it to an out of the way space, or dock it. In this example, we’ll want to create a shortcut toolbar to collapse and expand all of our code regions with one click.

There’s already a menu option to do this, click on Edit, Outlining, Collapse To Definitions. (Note if you don’t see the Outlining option, make sure you’ve clicked in the code window.) Glancing down at the Command Spy window, you will see that the command issued was Edit.CollapseToDefinitions.

[CommandSpy First Command]

Great, jot that down, and let’s run another command. Click on Edit, Outlining, Toggle All Outlining. You’ll see a new command has shown up in Command Spy.

[CommandSpy with Second Command]

Edit.ToggleAllOutlining is what we are looking for here. Now that we have the commands we want, let’s create a toolbar and hook them in.

Right click in the toolbar, and select Customize. In the Customize dialog, click on New. Give your toolbar a good name, it’s also helpful if you use something like your name to distinguish it from the rest of the built in bars. I named it ArcaneOutlining. You’ll see your new toolbar pop up to the right of the Customize window. (The red arrow is pointing at it.)

[Create a new Toolbar window]

I’m now going to drag the new toolbar under the Customize window, just so it will look decent for the next screen capture.

Now we need to drag our commands onto the toolbar. Click on the Commands tab of the Customize window. Under Categories, scroll down to Edit. Now in the Commands list area, scroll down to Outline Toggle All, and drag it onto the toolbar. Then, pick Outline Collapse to Definitions, and drag it into the toolbar. In this shot, you’ll see what it looks like when you’re done.

[Customize the toolbar window]

OK, we now have our commands, but all that text looks pretty ugly. Right click on the Outline Toggle All command, and you’ll get a menu. Click in the Name area, and you can type over the name of the menu option. I’m going to replace Outline Toggle All with + (a plus sign).

[Rename menu]

Once done, close the Customize dialog, then you can drag your toolbar to an appropriate spot. Use the – button to collapse everything, and the + to toggle it back.

[Picture of our new toolbar]

While I’ve picked out some specific commands, you can use this technique for any command that Visual Studio can produce, and create your own customized toolbars.

Visual Studio Add-Ins: VSFileFinder

If you tend to organize everything in your projects using file names, then you will love this add-in. VSFileFinder, available at http://www.zero-one-zero.com/vs/, adds a simple window to your Visual Studio environment. I elected to dock this window in the bottom center, where my output sits. There’s a text box across the top and a list box under it.

[Picture of VSFileFinder]

 

The text area lets you key in a file name (or part of one) to filter off of. The list area shows all the files in your project that match the entered filter. Clicking on a file will let you open it, or if already open will bring it to the foreground.

As you can see, entering “fo” matched all my Form1 files. Interestingly enough it also matched AssemblyInfo since it also contains “fo”.

That’s about it, VSFileFinder is a simple, one task tool that adds one specific type of functionality. But it does it well, and for free!

 

Visual Studio Add-Ins: Cool Commands 3.0

Update Feb. 9, 2008: Version 4 is now out, but there’s no new blog post. Follow the link below and scroll down through the comments to find the link to version 4.

Another handy add-in that brings functionality to the Solution Explorer is CoolCommands. Version 3 is available from http://weblogs.asp.net/gmilano/archive/2006/05/10/446010.aspx, and adds a whole series of new menu commands to the right click menu in the Solution Explorer window. It also adds a few new menu command to the Code Editor window. Since the site doesn’t do a great job of documenting all the features in the current release, here is a brief list of all the commands that get added.

Commands for the Code Editing Window

DemoFont – In the edit window, right clicking has a new menu option called DemoFont. This will let you quickly toggle back and forth to a larger size of the font you’ve been running. Clicking again will return you to the font size you previously had.

Wheel Font Zooming – My guess is this lets you use the mouse wheel to adjust the font size, but it didn’t work on my system. However the other commands are so useful I’m willing to overlook one dud.

Open File – This is very cool. Within comments you will sometimes see something like “// See the class file Xyz.cs for more info”. With cool commands, you simply right click on Xyz.cs and pick Open File, and that file will open in VS.

Commands for the Solution Explorer

Collapse All Project – Simple menu option to collapse all the projects in your Solution Explorer’s tree.

Command Prompt Here – Opens a command window in the directory where the project sits. (Only appears when clicking on a project).

Open Container Folder – Opens a Windows Explorer where the current file happens to reside.

Reference Manager – Lets you manage the references for the solution.

Resolve Project References – Validates all of your project references.

Copy and Paste References – Lets you create a reference for one project and paste it into another project. Makes setting up references between projects nice and easy.

Add Projects From Folder – Allows you to easily import one or more projects that are stored in a folder.

Commands for the open files tabs

Locate in Solution Explorer – This is cool, in the little tab markers at the top of the editing window, right click and pick this option. The solution explorer will then highlight the file for you.

One thing to note, technically CoolCommands is not an Add-In. While it adds new menu options, it cannot be loaded or unloaded from the Tools, Add-In Manager.

This free tool adds some nice functionality to your VS environment, and is well worth the download.

Visual Studio Add-Ins: Explorer

My next find for a Visual Studio Add-In is called Explorer, and is another free one available from http://www.codeproject.com/csharp/Explorer.asp . Explorer is easy to install and use.

After you download, extract the two files to your My Documents/Visual Studio 2005/Addins directory (create the Addins directory if it doesn’t exist). Then launch Visual Studio, click on Tools, Add-in Manager, and make sure Explorer is loaded.

Using Explorer is quite simple, just right click on the Solution, Project, or a folder and you’ll see a new menu option, Explorer.

[Picture of Explorer Menu]

 Explorer has a submenu with two options, “Open folder” and “Execute this application”. Open folder opens up a windows explorer folder in the same directory where the item you clicked on resides. This is a very handy way to quickly navigate to the directory where your project resides.

Note the “Execute the application” option only appears when you are on a project, not the solution. However, this is handy when you have a test project that is not your main application. Using this menu option keeps you from having to go through the effort of changing your startup project to run a rest program that is part of your solution.

Be aware this does not build the project, it runs the last built exe you created. If you’ve made changes to the project you want to run be sure to do a build before using this menu option.

If you are interested in writing your own add-ins, you should also check out the available source code. It’s a nice example of how to hook into the menu structures for writing your own add-ins.

.Net University Comes To Birmingham Alabama

Next week Microsoft will be sponsoring a free event in Birmingham, Alabama called .Net University. This will be the evenings of December 11th and 12th doors open at 5:30 pm, event starts at 6:00 pm.

This is an opportunity to learn about version 3.0 of the .Net Framework and it’s new technologies, including Windows Presentation Foundation, Windows Workflow Foundation, Windows Communication Foundation, and CardSpace. All attendees will receive a certificate and spiffy T-Shirt. Best of all, the cost is free!

I can speak from personal experience, having attended the very first .Net University session in the country when it was held in Montgomery. This was a great event that quickly brought us up to speed on the new additions to the .Net Framework. Well worth a couple evenings of your time.

To learn more about .Net University, see it’s website at http://www.dotnet-u.com/

For more information on this event, see the Bug.Net user group site at http://www.bugdotnet.com/

To register follow this link: https://www.clicktoattend.com/invitation.aspx?code=113947

Arcane Searches

One of the things I really like about WordPress is that you can see the search engine terms that lead people to your site. In the lists I see some search terms that occur frequently. I thought it might be fun to take a guess at what the googlers were looking for, and take a stab at answering them.

exit full screen remote desktop

Move your mouse to the top, center of the display. A little yellow bar will scroll down, with the machine name. On the left is a push pin you can use to make it stick. On the right is the traditional Min / Max buttons you see on a window.

virtual pc exit full screen

Alt + Enter will exit full screen, but it has to be the Alt key on the right side of the keyboard. (This assumes you haven’t changed you hot key mappings).

command to close virtual pc

There’s several ways to close a virtual pc. The simplest, and best is to do a shutdown of what ever OS you are running. When the guest OS shuts down, the Virtual PC exits.

You can also select Action, Close on the menu, VPC will prompt you to see if you want to close and save state (sort of like Hibernate on a laptop) or exit and discard changes. If you are running a Windows OS, VPC will also give you the option to shut down. You can get the same prompt by clicking the X (cancel) button on the window your guest OS is running in.

eventtoaster

This is one that shows up a lot in my searches. Event toaster is part of the Visual Studio Enhancements Add-In from Microsoft. See my entry on November 15th (https://arcanecode.wordpress.com/2006/11/15/visual-studio-add-ins-ms-visual-studio-enhancements/ or http://shrinkster.com/kdt ) for more info.

virtual computer usb

Virtual PC does not support USB in either version 2004 or Server 2005. And, despite being the most asked for item in Virtual PC 2007, Microsoft still does not have any plans to include it in the next version.

VMWare, on the other hand does support USB. In the VMWare Server product, USB is not entered by default. You can add it, however by Editing the Virtual Machine Settings. In the dialog under Hardware click Add, and pick USB.

zone alarm remote desktop client

Another one that appears frequently, I’m guessing there’s a need to know how to get remote desktop to cooperate with Zone Alarm. Open the Zone Alarm settings panel, and click on Firewall. By default the Internet Zone Security is set to High. Drop this to Medium to get it to work with remote desktop. You will also need to go into Program Control and put checks for Remote Desktop Connection for all four columns.

defrag a single file

Use the SysInternals Contig tool. See https://arcanecode.wordpress.com/2006/11/06/sysinternals-contig/ for more info.

There’s a few of the top searches from my history, hopefully I’ve answered questions for a few of you out there!

Arcane Thoughts: The Zone

Over the Thanksgiving holidays I did a lot of traveling. Before I left I downloaded a lot of videos and podcasts from the internet to keep me busy during those slow times when everyone else had keeled over from too much turkey. One video that caught my eye was on the Channel 9 website. Channel 9 ( http://channel9.msdn.com/ ) , by the way, is the Microsoft sponsored site where the Channel 9 team goes out and videos other folks in Microsoft, talking about new technologies or interesting activities they are doing. This is the same place famous (or infamous) Rory Blyth ( http://www.neopoleon.com/home/default.aspx ), former co-host of DotNetRocks went to.

This particular video, http://channel9.msdn.com/Showpost.aspx?postid=226791 talked about the CodePlex team. CodePlex, by the way is the Microsoft site ( http://www.codeplex.com/Default.aspx ) for open source development projects. I rather like the way it’s laid out, easy to find and organize a project, however that’s beside the point of this post.

During the video they revealed the entire CodePlex team works in a single office. Not an office with nice cubicles, not a section of a building, no all 8 of them are crammed into a single small office. Each has a small workstation or laptop on a small table or desk. Apparently this is some take off on Agile Development. Their claim was that if one guy runs into an issue, it’s very easy to say “Help!” and get immediate help on a coding issue and not delay his work. My thought was, hey that’s really great. For that one guy.

For the rest of the team, it seems to me it would be incredibly disruptive to the creative process. As developers, we often get into what Tony Robbins ( http://www.anthonyrobbins.com/ ) refers to as “The Zone”, that creatvie point where the juices are flowing and we lose all track of time. You’re solving problems, creating code, really making your application flow well. You know you’re there when you reach over for that cup of coffee to find it’s ice cold.

Then boom, someone interrupts you. Doesn’t really matter if they were asking, all that matters is you are rudely jarred out of “The Zone” and back to reality. After dealing with the interruption, it can be difficult to get back into “The Zone”, I’ve seen some studies that suggest it can be as long as half an hour before your mental processes have returned to full focus on the issue.

There are some aspects to Agile that appeal to me, for example the short release schedules. But cramming a bunch of coders into a single room? No thanks. I prefer to hang out in “The Zone”.

But hey, that’s just my opinion. I could be wrong.

Visual Studio Add-Ins: SmartOutline

SmartOutline is a tool for creating regions in your code without having to use Region / EndRegion tags. Available at http://submain.com/default.aspx?nav=products.smartoutline, this tool took third place in the Microsoft Visual Studio Extensibility Contest packages category.

SmartOutline is a product that’s easier to show you how it works than describe, so let’s look at a few pictures. Let’s say I have a simple if statement. Highlighting it gives me a new pop up, as you can see below.

[SmartOutline 1]

Clicking on the Create new SmartOutline Region command brings up the following dialog, where you key in the name for your region.

[SmartOutline 2]

In this example I’ve keyed in “My If Statement” for the name. Assuming I then check the “Collapse region” box, my code will update as you see below.

[SmartOutine 3]

 

Clicking the + button will expand my region back to the original state, as you can see.

[SmartOutine 4]

SmartOutline is useful for hiding long lengths of code that add safety but not value. For example, you might have to do a lot of validation to input parameters, but they don’t add to the real purpose of the method. SmartOutline is a great way to hide that.

You might assume that SmartOutline is altering the source files using Region tags and intercepting them. Not so, as this command window dump of the source file proves:

[SmartOutine 5]

 

Some useful situations to use SmartOutine to hide code segments might include:

  • Lengthy error handlers
  • Long parameter checks
  • Long comments
  • Code that is commented out, perhaps something for a future version or older version that you’re not sure you want to delete
  • Using (or Imports) sections
  • Entire Methods

These are just a few ideas, feel free to post a comment with your own thoughts.


My one complaint / wish list item for enhancement is that SmartOutline left aligns the name you give to the smart region. This breaks up the visual flow of indents. You can add spaces yourself when you give the name, for example I could have keyed in six spaces then “
My If Statement”, but if I were to indent the code later SmartOutline doesn’t change to reflect this. You should also know this is a VS2005 tool only, sorry 2003 users.


Overall a useful tool for adding to the readability of your code, well worth the download, and like many of the other tools mentioned so far, it’s free.

Visual Studio Add-Ins: VSCmdShell

VSCmdShell is a handy add-in that places a Command window inside of Visual Studio. Available at http://www.codeplex.com/Wiki/View.aspx?ProjectName=VSCmdShell, after a simple install you can launch the command window from the View, Shell Window command. By default it launches as free floating, I chose to dock mine down at the bottom with the Command and Output windows.
[Picture of default VSCmdShell]

From here, you can issue your typical array of commands, such as getting a directory, but the cool thing I use it for is my deployment scripts. I have a cmd file (sort of the new version of a batch file) that compiles my web apps then deploys to the development server.

VSCmdShell has some nice customizations. It has the things you might expect, like being able to change the text and background colors, but you can also select the shell. For example, you could install the new Windows PowerShell, and use it as your default shell window.

To get to VSCmdShell’s options, click on Tools, Options. Scroll down to “Power Toys”. Note if you previously installed the Visual Studio Enhancements (which I blogged about at https://arcanecode.wordpress.com/2006/11/15/visual-studio-add-ins-ms-visual-studio-enhancements/) you’ll actually have two entries for power toys. The “PowerToys” (no space) is from the enhancements, the “Power Toys” (with a space) is from the VSCmdShell. Here’s a quick shot of the dialog:

[VSCmdShell Options Dialog]

As you can see, you can change the font and colors, the shell, and even set the initial directory for the command shell. Best of all, VSCmdWindow automatically sets up all the VS variables for you. If you ever have need of a command prompt, this free tool is well worth the download.

Visual Studio Add-Ins: Paste As…

If you are like most programmers, you tend to fiddle with your SQL in some tool where you can run, test, and optimize your SQL before you paste it into your app. Or perhaps you have some long static text info (such as instructions) that you need to display to the user. You type it all in, then you have to mess around with getting it onto a string. You break it into multiple lines, perhaps you are using a string builder to hold it. The whole time you’re thinking there’s got to be an easier way. Well, there is!

The great add on, Paste As… from

http://weblogs.asp.net/alex_papadimoulis/archive/2004/05/25/Smart-Paster-1.1-Add-In—StringBuilder-and-Better-C_2300_-Handling.aspx (or if you like shorter URLs, I’ve shrinksterized it, http://shrinkster.com/jut ).

This add-on takes whatever text you have in the buffer and pastes it into your code in one of four ways: as a comment, as a string, as a string builder, or as a region. Let’s take a fake SQL statement and render it the various ways. First, here is a SQL Statement that you’ve worked on inside your SQL tool (it’s fake, but you’ll get the idea.)

select FirstName, MiddleInit, LastName, Street, City, State, Zip, PayRate, HireDate from SomeEmployeeTable order by LastName, FirstName, MiddleInit

Here it is as a comment:

//select FirstName, MiddleInit, LastName, Street, City, State, Zip, PayRate,

//HireDate from SomeEmployeeTable order by LastName, FirstName, MiddleInit

Now here it is as a string:

@”select FirstName, MiddleInit, LastName, Street, City, State, Zip, PayRate, “ +

@”HireDate from SomeEmployeeTable order by LastName, FirstName, MiddleInit”

All you have to do is put “myString = “ on the front, and (if you are in C#) a ; at the end and you’re done. Now here it is as a StringBuilder. Note it will prompt you for the name of your StringBuilder variable, and how cool is it that it automatically calculates the size of the string for you (in this case 147).

StringBuilder myStringBuilder = new StringBuilder(147);

myStringBuilder.AppendFormat(@”select FirstName, MiddleInit, LastName, Street, City, State, Zip, PayRate, “);

myStringBuilder.AppendFormat(@”HireDate from SomeEmployeeTable order by LastName, FirstName, MiddleInit”);

 

The final option is Paste As Region. While you would not typically paste a single SQL statement as a region, let’s see how it looks anyway:

#region myRegion

select FirstName, MiddleInit, LastName, Street, City, State, Zip, PayRate, HireDate from SomeEmployeeTable order by LastName, FirstName, MiddleInit

#endregion

In the context we’ve presented above probably not something you’d do. Where this would come in handy is when you’ve copied a bunch of code to the clipboard, and want to paste it into a new region. Since it does no reformatting, this makes it an easy way to bring in new code to your application.

This tool works with both VS2003 and VS2005, and works in both C# and VB.Net. It has quickly reached the top of my “indespensible” list and is one of the first I install when setting up a new instance of VS. And it’s free! How cool is that.

Visual Studio Add-Ins: Copy Source as HTML

Our next tool is very handy for those of us who blog, or perhaps just want to share code snippets with friends using HTML enabled e-mail. Copy Source as HTML, available at http://www.jtleigh.com/people/colin/software/CopySourceAsHtml/ does just what it says. It takes the lines of source code you have highlighted in your Visual Studio editor and copies them to the clipboard as HTML.

For an example, I’ve pasted this simple HTML into my blog so you can see what it looks like. This is HTML text, not a picture:

 

    9 namespace WinTest1

   10 {

   11     public partial class Form1 : Form

   12     {

   13         public Form1()

   14         {

   15             InitializeComponent();

   16         }

   17     }

   18 }

 

 

There are several options, as you can see from the dialog below.

[Copy Source as HTML Options Dialog]

You can have line numbers (as I’ve done above), set the line number to start at, or omit them entirely. You can activate word wrap, over ride the default tab size, font and font size. If you’re a CSS guru there are even tabs for entering your own CSS for both the entire section (surrounded in DIV tags) or the individual line.

Another great free add-in, it has both 2005 and 2003 versions. If you ever need to convert your code to HTML this is a great, easy way to do it.