Monday, October 12, 2009

New Gigabit NIC

A couple of weeks ago I installed a new NIC in my aging emachines box. The computer has an integrated 100 mbit NIC on the mobo which has been working just fine, but I have recently been upgrading my equipment to gigabit. My new D-Link DIR-855 Wireless N/gigabit router is the new core of our home network. Our 1 TB Buffalo TeraStation supports 1 gbit links, and now my main computer also does. I really wanted this to speed up my Ghost backups to the TeraStation.

It took a long time for me to decide which NIC to get for my PCI Express mobo. After a bunch of research, I finally decided on the D-Link DGE-560T. There are conflicting reviews out there on its worth, but I decided its cost was low enough that I could afford to take a chance.

Happily, the card has been working well, and after disabling the integrated NIC in the BIOS, it really was plug-n-play, even on this Vista 64 box. I did have one problem after the install, which was that the security rights got screwed up on a Windows system folder. I figured out how to solve that, though, and blogged about it here.

Here's a picture of the NIC. It is very small, smaller than I expected. The card edge occupies just a small portion of the PCI Express slot on the mobo.


Wednesday, September 30, 2009

Finally Figured Out My Vista Problem

Wow I have found the solution to a problem that I have had intermittently since installing Vista 64. Sometimes after upgrading my computer, my VPN connection would become inaccessible and my Ghost service would quit working (see A Painful Lesson and Fragile Vista). Tonight, I got bit by this again after installing a gigabit network card in my computer.

A natural thing to do when you get errors is to go look in the Windows event log to see if there are any messages. But when I tried to open the Event Viewer, I got this message:

Event log service is unavailable. Verify that the service is running.



Well, in fact, the Windows Event Log service was not running, and attempts to start it gave the error:

Error 4201: The instance name passed was not recognized as valid by a WMI data provider

So, I did some Binging and found a tip to check the permissions on the C:\Windows\System32\LogFiles\WMI\RtBackup folder. It didn't look good. They didn't at all match the permissions on its WMI parent folder. What it had was just my user name, and what the parent had were several system accounts.



I removed my account and added the system accounts to match the parent folder.



After rebooting, everything was back to normal again. I have no idea why certain installs mess up the permissions. Hopefully, this will be useful info for someone experiencing this problem.

Tuesday, September 29, 2009

Automating Excel from C# Pt. 1

Recently, I have wanted to convert Excel spreadsheets to CSV files for further processing. Excel provides a COM Automation model for using its functionality from 3rd party applications.

One of the things about COM Automation is that if you don't close all of the handles you are using in the application being automated, orphaned instances can be left running and they will never quit unless you use Task Manager to kill them or reboot the computer.

So, the automating application needs to be very careful to get rid of everything it is referencing in the automated process to allow it to shut down. The problem is, .NET is a garbage-collected environment, and this means that objects are destroyed, or released, whenever the framework decides that memory should be freed up. Unlike C++ destructors, which are always called immediately when a variable goes out of scope or is delete'd, .NET finalizers are called only when the framework wants to free memory. Exactly when that happens cannot be known with certainty. Oh, objects will be released eventually, but not necessarily when the application might like.

Therefore, the .NET framework provides the IDisposable interface, which allows the non-.NET allocated portions of an object to be immediately freed without the .NET portion being freed. This is what we need to use when automating COM so that COM handles are released in a controlled, dependable, and timely fashion.

In the next part to this series, I will talk about the IDisposable interface.

Tuesday, September 22, 2009

Multiple vs. Single Exit Points

Recently in one of the newsgroups a side discussion came up about the benefits of a single exit point from a function. There was a time when I followed that notion very closely. However, I found that the functions ended up having more nesting and other logic to "jump over" code paths once the return value was determined. In recent years I have found myself pretty much ignoring that idea completely.

Here is an example of some actual code I have somewhere. I have removed the null-checks, comments, and other exception throws to get down to the core of the logic.

In this snippet you can see that once the return value is determined, it immediately returns it.

    1 private int CompareTokens(CommandLineParser commandLineParser)
    2 {
    3     var n = System.Math.Min(this.tokens.Length, commandLineParser.tokens.Length);
    4 
    5     for (var i = 0; i < n; i++)
    6     {
    7         var result = this.tokens[i].CompareTo(commandLineParser.tokens[i]);
    8         if (result != 0)
    9         {
   10             return result;
   11         }
   12     }
   13 
   14     if (this.tokens.Length < commandLineParser.tokens.Length)
   15     {
   16         return -1;
   17     }
   18 
   19     if (this.tokens.Length > commandLineParser.tokens.Length)
   20     {
   21         return +1;
   22     }
   23 
   24     return 0;
   25 }

In the next snippet I have refactored the original routine into a single exit point. Note the required variable for the return value in line 3, the break at line 12 and the extra logic at lines 16 and 22 required to jump over the other code paths. Somewhere I know I have a more severe example. I will look for it. In fact, I remember it is an old one that used to have one exit point that I have since converted to multiple.

    1 private int CompareTokens(CommandLineParser commandLineParser)
    2 {
    3     var result = 0;
    4 
    5     var n = System.Math.Min(this.tokens.Length, commandLineParser.tokens.Length);
    6 
    7     for (var i = 0; i < n; i++)
    8     {
    9         result = this.tokens[i].CompareTo(commandLineParser.tokens[i]);
   10         if (result != 0)
   11         {
   12             break;
   13         }
   14     }
   15 
   16     if (result == 0)
   17     {
   18         if (this.tokens.Length < commandLineParser.tokens.Length)
   19         {
   20             result = -1;
   21         }
   22         else if (this.tokens.Length > commandLineParser.tokens.Length)
   23         {
   24             result = +1;
   25         }
   26     }
   27 
   28     return result;
   29 }

So, what's your opinion? I suppose some of you have seen coding horrors where multiple exit points have been abused.

Saturday, September 19, 2009

Consolas Font in Code Snippet Windows

I have the Consolas font issue fixed for my code snippet windows. If you have the Consolas font installed, the snippet windows should now show in that font. I haven't figured out the line ending problem yet, though.

    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Windows.Forms;
    5 
    6 namespace Test1
    7 {
    8     static class Program
    9     {
   10         /// <summary>
   11         /// The main entry point for the application.
   12         /// </summary>
   13         [STAThread]
   14         static void Main()
   15         {
   16             Application.EnableVisualStyles();
   17             Application.SetCompatibleTextRenderingDefault(false);
   18             Application.Run(new Form1());
   19         }
   20     }
   21 }

The issue with the font was that the  <pre>  tags for the coloring on the fragments weren't inheriting the  font-family:consolas  that was specified in the style for the  <div>. Modifying the Copy Source As HTML utility settings remedied that.

So now my settings for CopyAsHTML are:




Friday, September 18, 2009

Posting Code Snippets to Blogger

I want to be able to post code snippets and I found a little utility that integrates with Visual Studio 2008 called CopySourceAsHtml. This utility lets you select source code in a code window and copy it verbatim to the clipboard, which can then be pasted into the blog.

In this shot, I selected some source code, and right-clicked. I then chose Copy As HTML...



When you do this, the utility's dialog box appears allowing you to choose options. I have set options on two of the tabs.




On the File Style tab, I have added some more style settings for the  <div>  that it creates for the snippet.  The  overflow:auto  setting will add scroll bars as needed, the  white-space:nowrap  setting will turn off word-wrapping, the  height:500px  setting sets the box height to 500 pixels, and the  border:inset silver  sets the box's border style to inset with silver color.

When you press OK the HTML is placed on the clipboard and is ready to paste into the blog post.



For this to work, I also had to make a change to my Blogger template, otherwise the word-wrapping setting was ignored and was always on.



This is the final result:

  296                 else if (path.EndsWith(":"))
  297                 {
  298                     path += @".\";
  299                 }
  300                 else if (!path.EndsWith(@"\"))
  301                 {
  302                     path += @"\";
  303                 }
  304 
  305                 path = System.IO.Path.GetFullPath(path);
  306                 if (path == null)
  307                 {
  308                     throw new System.ApplicationException("GetFullPath() returned NULL unexpectedly.");
  309                 }
  310 
  311                 if (fileType == FileTypes.File)
  312                 {
  313                     // Special cases for when x.txt is truly a FileInfo, this code
  314                     // must come after the GetFullPath() call above:
  315                     //      c:\x.txt\
  316                     //          Path: c:\x.txt\
  317                     //          File: 
  318                     //      c:\x.txt\.
  319                     //          Path: c:\x.txt\
  320                     //          File: .
  321                     //      c:\x.txt\.\.\.\\\.\.\..\x.txt\\\\\.\.\.\..\x.txt\.\
  322                     //          Path: c:\x.txt\
  323                     //          File: 
  324                     //      c:\x.txt\.\.\.\\\.\.\..\x.txt\\\\\.\.\.\..\x.txt\.\.
  325                     //          Path: c:\x.txt\
  326                     //          File: .
  327                     //      c:\x.txt\.\.\.\\\.\.\..\x.txt\\\\\.\.\.\..\x.txt\.\.\\\
  328                     //          Path: c:\x.txt\
  329                     //          File: .
  330                     if (((fileName == string.Empty) || (fileName == ".")) &&
  331                         path.EndsWith(@"\"))
  332                     {
  333                         fileSpec = path.Substring(0, path.Length - 1);  // Make the new filespec be the earlier resolved Path minus the trailing \
  334                         path = System.IO.Path.GetDirectoryName(fileSpec);
  335 
  336                         if (path == null)
  337                         {

One thing I note is that you cannot easily copy text out of this window, because it doesn't have normal line ends. I am looking into how to remedy that. I do plan to post downloadable code when I post snippets. The other thing is that this is displaying with a Courier font, rather than Consolas as in Visual Studio.

Wednesday, September 16, 2009

I Have Perforce Source Control Now

I had been wanting to get source control for my home hobby projects for the last couple of months. I am most familiar with Visual SourceSafe since I first used it 14 years ago (We use Team System now at work). I've been following eBay auctions to try to get VSS cheap, like say $50, but I hadn't had any takers for this price. Thankfully, I gave up on the stupid VSS idea, and after some research decided to give Perforce a try. It is free for up to two users, which is exactly the price I wanted to pay. It also integrates with Visual Studio 2008. Of all of the components on their download page, I only downloaded and installed these three 64-bit ones:
  • P4D: Server
  • P4V: Visual Client
  • P4SCC: SCC Plug-in

The installs went smoothly. It wanted me to reboot, which I did. After rebooting, I went into the Perforce Visual Client P4V utility, then on the Tools / Administration menu I set myself up as a superuser. I accepted all of the defaults for everything, including the Workspace, which ended up being a problem later. I fired up Visual Studio and opened a solution that I wanted to add to source control. After opening the solution, I enabled the Source Control toolbar and selected Change Source Control.



This is where I ran into the only problem I had. When I tried to bind the solution to source control I got this error:

Path 'd:\Source\XLStoCSV/*' is not under client's root 'C:/Users/Alan/Perforce/EMACHINEST6520_1666/Alan_eMachinesT6520'.



I have a root folder where all of my programming projects are and figured that the problem was that I needed to make this be the root in source control. It was a little unclear how to do that though, but after some snooping around in P4V I found that I could edit the Workspace.



Earlier, I had accepted all of the defaults when setting Perforce up. I should have specified d:\source for my root.



After making this change, I went back to Visual Studio and retried binding the solution to source control. This time it worked just fine.



One more dialog came up to ask what to do if the files were already in source control. They weren't, of course, and I just took the default.



At this point, the icons on the project items were marked with the familiar yellow plus signs and could be checked in. Here's a screenshot of everything checked in. Elapsed time from download: 20 min. Very cool!

Saturday, September 12, 2009

StyleCop 4.3.2.1

Just noticed tonight that StyleCop 4.3.2.1 was released a month ago. Bug fixes are always welcome. Plus they've added the ability to suppress warnings on a per-unit basis, like FxCop.

Wednesday, September 9, 2009

Error Updating Norton Ghost

Since I hadn't ever updated Norton Ghost since I originally installed it, I thought it would be a good idea to see if there were any updates for it. Norton Ghost comes with the Norton Live Update utility, which I ran. It told me that there were indeed updates for it, so I told it to go ahead and update it. After the updater ran for awhile, I eventually got this error:



Fatal error during installation.

Nice. How informative. At this point, Ghost is UNINSTALLED, and needs to be reinstalled from the media. You would think that with all the ridicule vendors get from The Daily WTF and similar sites, the developers would know better than to give a message like this. I tried installing several times without any luck.

One day, by accident, I had forgotten and left the original install CD in the drive and ran Live Update again. I noticed that the updater was spinning up the CD drive and reading from it. This time, the updater completed successfully.

Lesson learned: The Norton Ghost updater wants the original media in the drive during the upgrade.

Saturday, August 22, 2009

New Cable Modem

A couple of weeks ago, I got a new cable modem. I mentioned how the old one, a Linksys BEFCMU10, had been somewhat flakey, needing to be unplugged every once in a while because it would lock up. The other problem it had was that it was only DOCSIS 1.0, which is not supported by my cable company. I had been hitting eBay and CNET to try to figure out what new cable modem to get, but my cable company had a $35 special on new Ambit U10C018.80 (also known as Ubee) DOCSIS 2.0 cable modems, so I just did that. This new modem is 1/3 the size, 1/2 the cost, and 6x faster than my older one. I'm very happy with it. Haven't had one problem since installing it. Right now with our basic internet package, my download speed is 14 Mb/s and upload is 1.0. My numbers used to be 2.2 and 1.0. (Test yours)

Wednesday, July 22, 2009

Micosoft Newsfeeds for Visual Studio

After I installed Visual Studio Standard Edition, I noticed that the installer left the newsfeed set to the Visual C# Express newsfeed. I looked around for the proper feed for the regular Visual Studio C# and found this:

MSDN: Visual C#

Other good feeds

MSDN: Visual Studio
MSDN: Visual C# Headlines

Visual C# Express feed

MSDN: Visual C# Express Edition

You can set the feed on the Start Page in Visual Studio by going to Options / Environment / Startup

Tuesday, July 21, 2009

Installed Visual Studio

Now that my computer is somewhat stable, I went ahead and installed the Visual Studio 2008 SP1 Standard Edition that I got on eBay a couple of weeks ago. It runs great so far. I have StyleCop installed and have been using it on a project. I have saved out the default settings that you can get if you ever need them, and have installed my own custom settings. I have used this color scheme for over a decade and it is similar to colors I used in VB 4.0 and Visual C++ 1.0 way way long ago. (Somewhere, I've still got the legendary Visual C++ 1.52c CD).



This setup uses the Consolas font, which is designed for programming environments. You can get it by following the link. It is also included in the ClearType Font Collection. You already have all of these if you have Vista or Office 2007.

Monday, July 20, 2009

Fragile Vista

I don't know what is up with this computer, drivers, or Vista 64 itself, but it has been showing itself to be very fragile and resistant to change. In my other post, I talked about how Vista would get screwed up, such as the Event Log service not working and unable to start, internet access not working, my office VPN not working, unable to connect to the Ghost service running on this computer, and maybe other problems I'm not aware of. Back then, I thought it was due to driver issues, Windows Update, or System Restore, but now I know that is not true. Well, maybe it is true, but there are other scenarios that will screw up this computer in the same way. The last two weeks have been a nightmare of backing up and restoring my system drive over and over trying to make simple changes. First of all, I originally had the system files and our family and personal files all on the same C: drive. To reduce the time to make Ghost images of the C: drive, I decided to partition the Drive 0 into two drives, one 100 GB partition for Windows and applications, and 150 GB for personal files. There is also a 250 GB 2nd drive D: in this computer as well, though I want to keep it empty and only hold temporary files there. So the first task was to copy all of the personal files from the C: to the 2nd D: drive, and retain only system files on the C:. To be able to shrink the drive using Disk Manager, you need to have free space at the end of the drive. So I defragged the C: drive, but unfortunately, Windows has unmovable files, such as the swap file, the hibernate file, and shadow copy files (Restore Points) for System Restore. One can shrink a drive up to the point of one of these unmovable files, but no further. You can get rid of the hibernate files by turning off the hibernating feature using this command:
powercfg -h off
You can get rid of all of the Restore Points by turning off System Restore, and you can get rid of the swap file by disabling virtual memory from the Control Panel. I did all of this, then Windows wants to reboot. Guess what? After rebooting, the system is screwed up. Why? Oh I have a Ghost image I can restore, but only from a week ago. Didn't think to back up before moving all of the personal files and disabling those features. Didn't think I would need to. So I got to start all over. In fact, I got to start over several times. I finally realized that any time I remove the swap file, the system gets screwed up. It is probably something to do with a low-memory condition. But as I say, that is not the only thing that will screw it up. I finally got a stable configuration for the C: drive, including good Ghost backups of the drive on my TeraStation network storage. So, the next thing I wanted to do was to install a new 1 GBit network card to speed up backups even further. I looked at a bunch of vendors and decided on the D-Link DGE-530T because I just love my new D-Link DIR-855 router. This was a huge mistake. I think. After several attempts, I have not been able to get Vista to even SEE that it is installed in the computer. My motherboard does have an onboard LAN connection, so I was sure to disable this in the BIOS before installing the new NIC. The directions say that Vista should see it and then offer to install a driver for it. But nothing I have tried will cause this NIC to be seen, and worse, it screws up my Vista, like all the other changes I make, and I have to restore from a backup... which is on the network... which requires a working network card... which requires the new NIC to be removed... which requires the PC to be powered down... then requires the BIOS to be adjusted again... and the network cable to be reinserted into the original jack... and then rebooting from the Ghost CD... then restoring the backup which takes 1.5 hrs... etc. It is very taxing. When Vista is working, it runs great. But I hate how it can get screwed up. This has been a very long two weeks. Oh, and the D: drive... I am not using Ghost to back up our personal files. I am using XXCopy to make a duplicate image of the file structure on my 1 TB TeraStation, using the command

xxcopy d:\*.* \\ts1\data\Backups\ComputerName /D /M /E /C /F /H /I
/R /K /Y /ZY /YY /EX:c:\Misc\D_Excludes.txt


I have this in a batch file, and the D_Excludes.txt file is empty at the moment. This command will compare the source and destinations for new or deleted files, and will also copy files up that have the Archive file attribute set (the a bit), and will clear the a bit after copying the file. I like this because I have an exact duplicate of the files up on the network storage, whereas Ghost file backups are stored in a proprietary format. Right now, I have 50,122 personal files in 3,530 directories, and with Vista file indexing, it only takes 1:40 for the command to run if there are no files to back up.

Sunday, July 5, 2009

A Painful Lesson

Well, I had an interesting last couple of days with Vista. I learned about how screwed up Vista can get with borked ACL's. It all started Friday morning, when a Windows update alerted me that there was an update for Windows Defender. These are usually lightweight updates that never seem to have any adverse effects. But... I also have an old flaky cable modem, a Linksys BEFCMU10, which is no longer on our ISP's list of supported modems. I have been researching getting this replaced, but haven't made a decision about which modem to go with yet. Anyhoo, I was working at the computer on Fri. morning, when WU asked to install the Defender update, and I told it to go ahead. After it installed, I noticed that my internet quit working and my Norton Ghost icon changed, indicating that it could no longer communicate with the Ghost service. I fiddled with it awhile and concluded that the WU had damaged something that used to work, though I didn't know what. So I decided to just undo the WU by using Windows' ability to Restore from a Restore Point, which the WU created as it was installing. Reboot, and no problem, right? Wrong. After the computer rebooted, the internet still didn't work, Ghost was still unhappy, and not only that, I found that my VPN network icon no longer worked, giving Access Denied when I clicked on it. I had just been using the VPN prior to the WU. Not good. Digging deeper, I learned that the Event Log service was not running, and would fail immediately when I would try to start it. That is very bad, as the Event Log is where error information is supposed to go. What to do? I googled the error message I was getting from trying to start the Event Log service, which was
Error 4201: The instance name passed was not recognized as valid by a WMI data provider
Forum threads such as this Microsoft Technet one indicated that it was a permissions problem on certain folders or files, or else it was an ACL problem. I tried a few things with permissions, but nothing was helping. The suggested ACL fixes are complicated and may not have worked anyway. So, I decided to just restore that whole computer from a backup. I just happened to have a 2-day old Ghost backup image of the drive, so that was good to restore from. Trouble is, it is on my Buffalo Terastation NAS drive, and I only have a 100 mbit NIC in this computer. When I booted up from the Ghost CD, it started to do a verify of the image before the restore. It estimated 15 hours... yowzer. Well, we were leaving for the 4th of July weekend anyway, so I just turned off the monitor and left for vacation. There is a checkbox in Ghost to tell it to reboot when it is done restoring, and I told it to go ahead, expecting that when I returned, I would see the usual login screen and everything would be fixed. But guess what? When I got back late last not, the problem was STILL THERE. WHAT?!!! This problem was NOT there when I made the backup on Wednesday. What's going on? Oh... did I mention that I also have a RAMDisk, and I have all of our temp directories pointed there, along with all of the browser cache files going there? When I upgraded to Vista 64, Superspeed required that I get a new license for Vista. It is not a license that you can get immediately. You have to send them an email, then they respond back with the key. In the meantime, you can run the software in trial mode for 30 days, at which time it expires and quits working. Here is the genesis of my trouble: I neglected to update the license key for the RAMDisk and it quit working right at the end of June. Therefore, the temp file locations were no longer valid because the drive was no longer there. Now here is the 1st lesson that I learned about Vista: If you boot up your computer with the temp file location unavailable, the Event Log service will not start up, and all sorts of other nasty inexplicable problems crop up. I noticed that this was a problem, but unfortunately, the Ghost image was not created with the RAMDisk license info installed. What I decided to try, and really hoped would work, was to predate the computer to mid-June, before restoring the backup. That way, when the computer booted up, it will think it was June and the RAMDisk would be active, thus having a valid temp file location. I also disconnected the computer from the internet, in case Vista would try to fix the time using a time server. To speed things up, I copied the network Ghost image to the D: drive on the computer, and restored from there. Then crossed my fingers. I was happy to find that this worked perfectly, and I now have a fully functioning Vista again. Oh... and the original internet problem... It was not WU at all, it was the stupid cable modem, and only needed to reset it to make it work again. The 2nd thing I learned was: Don't procrastinate on entering license keys. The 3rd thing: Norton Ghost is worth its price in times like this.

Wednesday, July 1, 2009

New Router

Yesterday, a new router was delivered to our home. I bought this D-Link DIR-855 Wireless-N gigabit router on eBay a couple of weeks ago. I was a little hesitant to get Wireless-N because the standard still hasn't been finalized. However, I have been wanting a gigabit router and we've been having weak signal problems with our wireless laptops upstairs. So, after some research, I decided on this dualband D-Link.



It replaces our old trusty Linksys WRT54GS Wireless-G router. It has worked great for years, but now it is time to retire it, partly because it is only 100 mbit.



Another nice feature of the new router is the ability to schedule the wireless access. When school starts, I want to block wireless access after bedtime.

Tuesday, June 30, 2009

Ghostnet Botnet in Action

One of the reasons we upgraded to Vista from XP is for increased security from malware. Here is a video showing one example of what the bad guys can do with your computer once it has been compromised. If you have never seen anything like this before, prepare to be shocked. It is an example of the Ghostnet botnet.

Sunday, June 28, 2009

Got VS.NET on eBay

I just won an auction on eBay for Visual Studio 2008 Standard Edition, got it for $61, and I also redeemed an eBay 8% off promo coupon, so the final price was $56.12, with free shipping. Very cool.

I Want to Buy Visual Studio

Well, I have been using Visual Studio Express at home for a couple of years now, but I think it is time to buy it. The reason is because the Express versions do not support tools. The three main tools I am interested in right now are Resharper, StyleCop, and NUnit. I went to Microsoft's comparison page to compare pricing. Cheap that I am, I will go with the Standard edition, which is listed at $299. But I see that I qualify for the Renew option, at $199. From the page,
To qualify for upgrade pricing, you must be a licensed user of an earlier version of Microsoft Visual Studio or any other developer tool (including free developer tools, such as Visual Studio Express Editions or Eclipse).
Well, I'm using Visual Studio Express, so I guess I qualify.

Thursday, June 25, 2009

StyleCop Is Usable

With the discovery of the context menu invocation of StyleCop, I am able to do what I have wanted all along, which is to run the tool on only one of our 60 projects and not have any affect on the other 4 developers in my group.

Wednesday, June 24, 2009

StyleCop with a Single File

A few minutes (!) after posting my previous post, I learned that there is indeed a StyleCop option added to the right-click context menu for running StyleCop on a file, project, or the solution.



Running StyleCop from the Tools menu, however, always runs it on the solution. Maybe this will be usable after all... I'll play with it tomorrow.

StyleCop and Legacy Code

Like so many Microsoft tools, they always seem to provide you with about 90% of what you need, and the 10% they don't is very frustrating. When you run the StyleCop install, it will insert a tool in the Visual Studio Tools menu, which you can run at any time.



I installed it today and note these problems:
  • In Visual Studio, the tool ignores what you currently have selected and processes the WHOLE solution. That's ridiculous. Microsoft knew that the first attempt at using this tool would produce thousands of warnings. You would think they would realize that the average person would want to run this on a single file only. Not a solution with 60 projects and hundreds of source files. Sheesh. What I would like is this: If I have a file selected, run the tool on that file. If I have a project selected, run the tool on that project. If I have the solution selected, run the tool on the whole solution. This isn't rocket science.
  • They provide a way to bypass certain projects or files by letting you modify the .csproj file. They even provide a utility to do this for you. But guess what, when you run the tool in Visual Studio it IGNORES these settings. GOOD GRIEF.
  • There is no standalone tool. The tool must be integrated into Visual Studio and/or MSBuild.
  • The only way to selectively run StyleCop and have it honor the project exclusion settings is to do a build. But to do that, you have to integrate the tool into MSBuild. When you do that in a shared environment, everyone has to install and configure StyleCop, even if they don't use it, otherwise they will not be able to build on their machines. Yes, they do provide a hack for team development, but this requires that StyleCop files be checked-in to source countrol along with your source. Ick.

Someone at work suggested that I create a new solution with just the project of interest. The problem is that the project has dependencies on other projects in the solution, using project dependencies, not file dependencies. If I start adding in all the dependent projects, I'm back to my original problem of thousands of warnings for source files that I am not interested in right now.

I did all this at work today. I am not sure that I want to or can continue with it. I may just do an Undo-checkout and throw it all away. In short, it is a good 90% solution, but the last 10% could be a show-stopper. And that's too bad.

Website for File Hosting

This blog will be my primary website. But I need a place to park files for downloading, so I just created a new personal Google site for free. I'll be putting programming projects over there and linking to them from here.

FeedJIT Trouble

I've been having trouble with the FeedJIT Live Traffic Feed on IE 8. If the page crashes, try reloading it.

Tuesday, June 23, 2009

StyleCop

Grrrr... I want to play with StyleCop but it is not supported with Visual Studio Express and there is no standalone version.

Thursday, June 18, 2009

Programming Haiku

From a tshirt given away to attendees of an MSDN event...



I solve some of my toughest programming problems in the shower...

Tuesday, June 16, 2009

Made the Move to Vista 64

I recently upgraded our home computer from Windows XP to Vista 64 Home Premium. I had been waiting for about 2 years, I suppose, to make the switch. A few years ago when I bought our computer, I chose an Athlon, hoping that someday I would actually get a 64-bit OS. Recently, I decided with all the buzz about Windows 7 it was time to get going on it. So I went out on eBay and got an OEM copy of Vista for $100. The OEM version will not do an upgrade of an existing Windows installation. I thought that the install would perhaps format the drive, but actually it just layed the bits down on what was already there. I had a spare drive that I used for the OS, and I removed the original XP drive for safe-keeping, just in case something went terribly wrong. Before the switch I exported all of our Live Mail and contacts to a NAS drive, then imported them later. I had no problems whatsoever, except that I forgot about all of my Message Rules. I have to say that I am very happy with the OS so far. We have had Vista 32 on a laptop for a couple of years now and it is awful - just too darned slow. But for all of the negative press Vista has gotten about being slow, the 64-bit OS is noticeably faster than 32-bit XP on this same hardware. I did not even consider installing the Win7 RC because there is no official upgrade path from the RC to the RTM. Microsoft really scr*wed people with the .NET 1.0 Framework RC when it went RTM back in 2002. The only officially supported upgrade to the RTM was to reformat the harddrive. Didn't want that with Win7! There were two problems that I have been dealing with, one of which I've resolved, the other not yet. After I upgraded, I had used the DVD drive to install MS Office. That was about a week ago. The night before last I went to rip a CD and I noticed that Vista wasn't showing my LiteOn DVD or CDROM drives. I hadn't used them since then, so I don't know when the problem first happened. I went into Device Mgr. and there were yellow warning triangles for these devices. I uninstalled the two drives and reinstalled them, but they did not repair. After googling the problem, I found that iTunes and some DVD burning software may install some drivers that break Vista. I was happy to find that upgraded GEAR Drivers fixed my problem. The install works for both 32 and 64-bit versions of XP and Vista. My second problem is that our Brother MFC-6800 printer has no Vista printer driver. It absolutely will not print from Vista, and if I try, not only will it not print, but no other print jobs from our other computers will print either until we turn the printer off and back on again. Other than this last glitch the upgrade has been great. Last night I installed Vista SP2. The upgrade went without problem, though it took about 45 min. to run.