Archives

Archives / 2010
  • Favor Privileges over Role Checks

    A very common practice in web applications, especially those written using the ASP.NET built-in Role provider (circa ASP.NET 2.0 / 2005), is to perform role checks throughout the code to determine whether a user should have access to a particular page or control or command.  For instance, you might see something like this:

    if (CurrentUser.IsInRole(Roles.Administrators) ||

    CurrentUser.IsInRole(Roles.SalesAgents))

    {

    SomeSpecialControl.Visible = true;

    }

    The problems with the maintainability of this approach become apparent after a short while.  For one, any buttons or other controls on the SomeSpecialControl above that post back to the page should … more

  • How Can I View MSMQ Messages and Queues?

    I’m working with NServiceBus to send messages to and from different parts of my application.  NServiceBus is a mature tool that sits on top of MSMQ and provides a great developer experience for working with a number of different scenarios.  One thing that’s challenging when working with queues is figuring out where a message went when it doesn’t show up at the other end of the message bus.  Where did things go wrong?  How can I see the messages in the queue for MSMQ?  Is the queue set up and working?

    It turns out that there is built-in support for viewing details of MSMQ baked into the MMC snap-in, though it’s not immediately obvious where to … more

  • Get the Batch File’s Path in a Batch File

    I’m a huge fan of build automation, and all of my dev projects include scripts to build, test, deploy, run etc.  Sometimes these use PowerShell and quite often they use MSBuild (or occasionally NAnt) but batch files remain a very simple and powerful way to take care of automation business.  Today I’m trying to wrap up my use of NServiceBus on a project that’s going live with some CQRS goodness, and I want a simple way to kick off the host process while I’m doing development so I don’t have to go to the trouble of running the thing from Visual Studio.  Anyway, to make a long story short, I needed to refer to the current path of the batch file within the batch file itself.  … more

  • Singleton Pattern

    I recently published an article on Alternatives to the Singleton Design Pattern on AspAlliance.com.  If you’re a fan of the Singleton pattern, I would encourage you to have a read and feel free to comment (here or there) if you agree or disagree with my position.  You can also learn more about the Singleton in the Patterns Library at Pluralsight.  Finally, if you haven’t read it, I definitely recommend checking out Jon Skeet’s coverage of the Singleton, as it provides several alternative implementations and demonstrates several weaknesses of the naïve implementation of the pattern. more

  • 9 Ways Contract Lawyers are Like Software Developers

    Lawyers.  We love to hate them.  But they’ve been writing code since long before Ada Lovelace wrote the first computer program.  Here are 9 ways that Contract Lawyers are like Software Developers. Reason One: They Use a Language That Barely Resembles English Let’s face it, most attorneys writing contracts use language that one would be hard-pressed to find used anywhere on the planet in the last 100 years.  In part, this is because English (and most other natural languages) is not very good at being specific without being verbose (and even then, it’s often ambiguous).  This is the same reason why attempts to program computers using natural language … more

  • Software Craftsmanship 2011 Calendar

    The folks at NimblePros have put together a pretty sweet 2011 calendar showcasing principles of software craftsmanship and agile software development.  The calendars are arriving from the printer today and should start shipping out over the next week or so to those who have pre-ordered them (or won them in the twitter contest, which lasts until 8 December 2010).  Here’s my review of the calendar (before having an actual one in hand, mind you). On the Cover: It starts with The Manifesto for Software Craftsmanship: …and the Manifesto for Agile Software Development: Each month highlights a different principle, such as the Boy Scout Rule: The calendar grid itself … more

  • Zen and the Art of Software Craftsmanship

    Not long ago, I (finally) read Zen and the Art of Motorcycle Maintenance, which I’d had recommended to me since I was a teenager.  It’s a very interesting book and one I would certainly recommend to anyone, but especially to anyone with an interest in quality.  Quality is one of the recurring themes of the book, and there are a number of sections of the book that resonate with me as a software craftsman attempting to improve the quality of the work I produce and the work my team produces. One passage from the book really resonated with me in terms of the difference between workers who really care about what they’re doing, compared to those who do not.  In all honesty I’ve … more

  • Verify a List of URLs in C# Asynchronously

    Recently I wanted to test a bunch of URLs to see whether they were broken/valid.  In my scenario, I was checking on URLs for advertisements that are served by Lake Quincy Media’s ad server (LQM is the largest Microsoft developer focused advertising network/agency).  However, this kind of thing is an extremely common task that should be very easy for any web developer or even just website administrator to want to do.  It also gave me an opportunity to use the new asynch features in .NET 4 for a production use, since prior to this I’d only played with samples. Check if a URL is OK First, you’ll need a method that will tell you whether a given URL is OK.  What OK means … more

  • On Software Quality at Cleveland .NET SIG

    Last night I led a discussion on software quality at the Cleveland area .NET SIG.  Thanks to everyone who came and especially to those of you who shared your thoughts and opinions.  I enjoyed the discussion and I hope you did as well.  This was the first time I’ve done such a talk at this style of group, which typically just has a speaker lecturing for 90 minutes or so, and I thought it went well but of course I welcome any comments. I quickly looked through the evaluations after the discussion and on the whole they looked positive.  I saw a few positive comments, which I appreciate, and at least one comment that I recall where someone said they expected more discussion … more

  • Time Spent Green

    I’ve been a fan of continuous integration for what seems like forever.  It’s an amazing way to boost the quality of your code and ensure that what gets checked into your repository is working code.  It also does a great job of eliminating the “it works on my machine” syndrome that is so common without such a tool.  If nothing else, having a separate machine run your build directly from what’s in source control, even without any testing involved, will tell you if what you’ve checked in actually sufficient. Of course, once you have a build, the goal is to keep it green.  You should follow the check-in dance to minimize the chance of build breakage.  When the build … more

  • The Message Is The Message Received

    I recall early on in my military career, in an ROTC class, learning about communication.  Communication is very important in the military, and at least as important in civilian life.  Especially today, when there are so many ways to communicate, and so many ways to communicate poorly. In a recent twitter conversation, I was reminded of one of the lessons from this class, which was summed up as “The Message Is The Message Received.”  The twitter conversation went like this:   I did a quick search to see if I could find a reference that uses the nugget of knowledge that I recall from the course, and was unsuccessful.  Here’s a super-brief communications 101 … more

  • Use Interfaces for Metadata and Comments

    If you’re using XML Comments for intellisense purposes, or are making heavy use of attribute-based metadata in your classes, you’ve likely found that these have a tendency to bloat your code and make it more difficult to follow.  For example, consider this simple configuration section handler: 1: public class DemoSettings : ConfigurationSection, IDemoSettings 2: { 3: private static readonly DemoSettings settings = 4: ConfigurationManager.GetSection("DemoSettings") as DemoSettings; 5:  6: public static DemoSettings Settings 7: { 8: get { return settings; } 9: } … more

  • When To Comment Your Code

    My opinions on comments in software code have evolved with my experience.  When I was a teenager first learning to program for real, I rarely used comments unless the code was for an assignment, in which case it was a forced exercise every bit as much as teachers’ requests to “show your work” added verbosity to my math and science problems’ solutions.  Of course, the programs themselves were quite simple, and the languages used (BASIC, Pascal) didn’t really support OOP (not that I knew what that was).  And it was important, then, to be able to express the intent of the code in English, if only so the instructor knew what was being attempted.  … more

  • DevReach 2010

    This past week I had the good fortune of traveling to Sofia, Bulgaria to speak at DevReach for the second time (the first was 2 years ago in 2008).  This is a great conference and was held for the second year in a row at a movie theater, which worked very well (similar to StirTrek in Ohio each year).  The event included a great list of speakers, including Scott Stanfield, Beth Massie, Andrew Brust, Donald Belcham, Stephen Forte, Lino Tadros, Miguel Castro, and Sahil Malik.  Michelle was able to join me again this year, which worked out well since Telerik is one of her/NimblePros’ clients. The Venue The conference was held at the Arena Kino (cinema), which you can see here … more

  • SQL Table Cleanup Job

    It’s pretty straightforward to create a job in SQL Server that will clean up a table.  For instance, for AspAlliance.com I use ELMAH to record errors, and it’s set up to go to a database table (called ELMAH_Error – see image at right).  While doing some maintenance, I noticed that this table had several months’ worth of data in it and over 400k records (many of which were simply 404s).  This was needlessly bloating the size of the database, so I did a quick delete to take care of it.  Personally, I’m interested mainly in 500 errors, but I don’t mind seeing the odd 404 error in the log as sort of a sanity check to make sure I haven’t done something stupid.  So the … more

  • The CHECK_POLICY and CHECK_EXPIRATION options cannot be turned OFF when MUST_CHANGE is ON

    In addition to the dreaded SQL Server Error: User Group or Role Already Exists in the Current Database error, you may also get this error when creating new logins after a database move: Alter failed for login ‘somelogin’. An exception occurred while executing a Transact-SQL statement or batch. The CHECK_POLICY and CHECK_EXPIRATION options cannot be turned OFF when MUST_CHANGE is ON. (Microsoft SQL Server, Error: 15128) The fix for this is to change the password.  You can do this via script like so: USE Master GO ALTER LOGIN [somelogin] WITH PASSWORD = ‘samepassword’ GO ALTER LOGIN [somelogin] WITH       CHECK_POLICY = OFF, … more

  • LINQ Range Variable Problem

    Ran into this issue last night and just figured it out.  I have this code for a demo: using System;using System.Data.Objects;using System.Transactions;using ExtractTransformLoad.Domain;using Northwind.Entities;//using System.Linq;namespace ExtractTransformLoad{ public class SqlFreightByShipperRepository : IFreightByShipperRepository { public void DeleteAndInsert(DateTime runDate, FreightByShipper freightByShipper) { using (var context = new NorthwindEntities()) using (var scope = new TransactionScope()) { var summaryToDelete = (from freightSummary in context.FreightSummaries … more

  • The Check In Dance

    When developing software and working with a build or integration server, there are certain conventions that one should follow when making updates to the shared codebase.  Somewhere I picked up the term “the check in dance” (not to be confused with “the chicken dance”) for this process, which is very straightforward and, if followed, can ensure that build failures on the continuous integration (CI) server are a rarity. Automating the Build Before we get into the process of properly checking in code for a build server to work with, let’s briefly talk about how one automates a build, and why this is a good thing.  If you’re using Visual Studio, automating a build with MSBuild (or if … more

  • Build Automation for your Application using MSBuild

    Over the past few years, I’ve established something of a standard for how I like to organize my projects, and this includes having a one-click build-and-test script for each project.  This is a quick description of my current thoughts on this, along with some details of how to get the MSBuild scripts working for your project as well.  The ultimate goal is that you, a new developer who just pulled down the source from the version control system, and the build server can all run a build in exactly the same way, and expect the same results. Solution Organization Of late I’m using a structure like this one for most non-trivial projects: This is designed to use the Onion … more

  • How Do I Save Performance Counters in Windows Server 2008 or Windows 7

    If you’re writing multi-user applications like just about any ASP.NET application, it’s probably worth your time to get familiar with performance counters.  Performance Monitor, or perfmon for short, is the tool you use to view these counters on your computer or server.  You can add it to an MMC instance (run MMC and add the performance snap-in) or you can just run perfmon.  (Sidenote – I once got dinged by a manager for mis-spelling perfmon in a proposal for a client.  I forget what he thought I was trying to spell but it made no sense.  In any event, trust me, perfmon is really how it’s spelt).  There are about 3 counters that you can work with in … more

  • Real World Monitoring and Tuning ASP.NET Caching Part 2

    In Real World Monitoring and Tuning ASP.NET Caching Part 1, I showed the behavior of a certain ASP.NET application under load.  We resolved the issue today, which turned out to be a result of two related issues that, thankfully in our case, were limited to a single class in our application that was responsible for interacting with our cache.  Here’s the old behavior: The new version of the same application, under pretty much the same load, looks like this: Note the lack of ever-growing memory followed by high-CPU utilization as the memory is reclaimed.  In my last post, I suggested that there were several approaches we could take to correct the issue, one of them being … more

  • ASP.NET Custom Errors Security Flaw

    Updated 5 October 2010: There is now a patch available via Windows Update.  Read more about it here, and ensure all ASP.NET web servers have been patched ASAP. Microsoft just released some details on a security flaw that was publicized a few hours ago.  On this post, you can learn more about the ASP.NET vulnerability and how to detect whether your web sites might be affected by them.  This is a serious flaw that you should take steps to address as soon as possible, since the attack can be performed by anybody with the available tools, in less than a minute, and can provide them with access to any file the site has access to (including web.config), as well as potentially root … more

  • An IIS Crash Analysis Story

    Last week I attempted to update a high-traffic production ASP.NET application to ASP.NET 4.  In the course of doing so, I was surprised, despite having tested everything thoroughly in a staging environment, to find that under production loads, the system was erratic and slow to respond to requests.  Further inspection revealed that IIS was actually crashing under load, leaving a cryptic message in the event log but no other clues.  This is basically an account of what I did, and how I ultimately resolved the issue, for my own future reference and to assist others who may face similar situations. In The Beginning The application in question is a fairly high traffic site, with … more

  • Using Dynamic Parameters in a WebTest or LoadTest

    Using Visual Studio 2010 (and some earlier versions), it’s very easy to create a WebTest by recording one or more web requets to the system under test (SUT).  To get started, open Visual Studio 2010 and create a New Project.  Then select Test Project like so: Next, add a Web Test to the project, and hit the URL you want to test (the one that accepts multiple different parameters that you want to make dynamic).  Run the test and verify it passes with a single set of hardcoded parameters.  You should see something like this: Now it’s time to change the hardcoded parameters you’re using into dynamic parameters.  The first thing you need to do is generate the code … more

  • Principles of Software Design

    Recently I did a webcast on Principles of Software Design in which I very quickly covered several important principles, as well as a few patterns and practices, that lead to better software quality.  If you’re interested, you can view a recording of the webcast (click the wmv link beside the 16 Sep 2010 webcast), or download the slides and demos. more

  • DevReach Online 2010 - Software Fundamentals

      I just finished my DevReach Online presentation, A Whirlwind Tour of Software Development Fundamentals.  In this 45-minute talk, I covered what I consider to be fundamental principles, patterns, and practices of software development, with a little bit of time for a demo at the end.  The session was recorded and will be available on the DevReach Online web site soon.  You can get my slides and demos from the talk here, though.  I’ve also included some of the links from the talk to save you the trouble of hunting through the PowerPoint file.

    18-19 October 2010, Sofia, Bulgaria

    References

    A Whirlwind Tour of Software Development Fundamentals - Slides and … more

  • Real World Monitoring and Tuning ASP.NET Caching

    First off, let me direct you to a great article on monitoring your ASP.NET cache API behavior.  Go read that first, then come back here. Done?  Good, so let’s make the advice from Simon’s blog a bit more concrete with some real-world examples. Consider this fairly high-traffic web server’s behavior (avg. 55 ASP.NET requests/sec, 110 max, at the moment): Notice how the RAM sort of falls off a cliff, and at that same moment, CPU is much higher than usual?  That’s the behavior we want to diagnose (I’ll save the answer for a moment).  As it happens, this same pattern recurs constantly, and is exhibited on multiple machines within the web farm … more

  • Perform Rolling Upgrade of Web Farm using Windows Network Load Balancer

    Once you’ve set up a web farm / cluster using Windows Network Load Balancing, one of the benefits you have is the ability to perform a rolling upgrade.  A rolling upgrade is a process by which you perform updates to individual servers within the cluster while they are not actively serving requests.  This process is repeated so that eventually all servers have been updated, but users have not experienced any downtime. Assume for a moment that you already have 3 servers set up identically to serve web requests, and that you have configured them into a cluster using Windows Network Load Balancing.  You can open Network Load Balancing Manager from Administrative Tools on one of … more

  • Applying Interface Segregation to Configuration Files

    In .NET, it’s very easy to set up custom configuration section handlers to handle your application or component’s configuration needs.  As my previous post shows, it’s also very easy to configure these with attributes that enforce required fields and other validation.  However, over time it’s very easy to create fairly large configuration sections that violate the Interface Segregation Principle, which states that classes shouldn’t be forced to depend on things they don’t need. Consider this relatively simple configuration section: <configSections> <section name="ConfigurationSettings" type="InterfaceSegregation.Configuration1.ConfigurationSettings, … more

  • System.Core in VS2010 Projects

    I just ran into an odd issue with a VS2010 project.  In my case it was an MVC 2 application I was upgrading from VS2008.  One of the built-in controllers (ProfileController) was failing to compile because it could not resolve the Linq extension method symbols Single() and Matches().  These are located in the System.Core assembly.  I checked my project references in Solution Explorer, and System.Core was not listed.  So I tried Add Reference, and System.Core was listed as included and gave me the option of to Remove it. After some searching, I found this blog post, aptly named Do NOT remove the reference to System.Core from your VS2010 Project.  It pointed out … more

  • Using CCTray with JetBrains TeamCity

    TeamCity is a great build server tool from JetBrains (makers of the awesome Visual Studio add-in, ReSharper).  The user-interface and features of the TeamCity web front-end are wonderful and are leaps and bounds easier to use for new users than my previous favorite, CruiseControl.Net, which required much XMLness to configure.  However, one of my favorite tools from CruiseControl, CCTray, still has no equal among competitors like TeamCity and even the Visual Studio tray watcher for Team Build. Why CCTray Is Awesome CCTray has one job and it does it extremely well.  That job is to let anybody interested in any software projects (that support CCTray) know whenever something … more

  • Startup Business Checklist 2010

    Below is my current checklist for startup businesses in 2010.  This is meant to be relatively industry-agnostic and focuses primarily on online components of the business (meaning, it may not apply to businesses which avoid the Internet for whatever reason).  I’ve included numerous links to more information and references.  Checklists are a great way to ensure you don’t forget important things – check out the Checklist Manifesto for how one doctor is attempting to apply this logic to medicine. If you’re not reading this on my blog, you’re likely missing out on the latest updates to this post – click here to view the source article: Startup Business Checklist 2010 … more

  • Code Analysis Techniques

    There are a number of code analysis tools available for .NET developers, including some stats that are built into the pricier SKUs of Visual Studio.  Recently, I’ve been playing with a relatively new product (released earlier this year by Microsoft agile consulting shop NimblePros.com) called Nitriq.  Nitriq is a bit like LINQPad for your code.  If you’re not familiar with it, go download LINQPad now – it’s a great tool worth paying for.  I’ll wait until you’re back… Back?  Great!  I think we were discussing using Nitriq for code analysis, which by the way you can run for free on a single assembly.  Before going any further, it’s worth mentioning something … more

  • Getting Started with Code Contracts in VS2010

    The idea of Design By Contract has been around for quite a while, and Microsoft Research has had a project focused on this topic for several years now, called Spec#.  With Visual Studio 2010, there is now support for Code Contracts which are a DevLabs project based on the Spec# project.  You can read more about and download Code Contracts for VS2010 here. Once you’ve downloaded and installed Code Contracts, you’ll have a new tab in your VS2010 projects: With the Code Contracts installed, you can start to use them in your code in place of things like guard clauses to ensure that a parameter is not null.  The benefit of this approach is that you get a richer experience at … more

  • Screencast and Podcast Recording Gear

    I’m working on some screencasts and have had some gear recommended to me that I’m ordering now.  I’ll post back later with an update on how I like these, but if anybody else is interested in what I’ve been told is the best stuff to get, here you go. Microphone The microphone of choice is the Rode Podcaster, pictured at right.  It has a built-in pop filter, so no need to pick up one of those.  This is a USB microphone and doesn’t require any additional boxes or cables.  From the product description: Seamless integration was the idea, and it was obtained by creating a studio dynamic microphone with unparalleled A/D converters, so that the microphone can be plugged … more

  • Books

    Sadukie tagged me with her books post a couple of weeks ago and I’ve been meaning to respond with a post of my own.  I have a post I update periodically that includes some of my most recommended developer books (where I’ve been meaning to add Agile Principles, Patterns, and Practices in C# by Robert and Micah Martin) – if you’re looking for ways to improve yourself as a software developer I would start there. Currently Reading Right now I’m reading Disclosure, by Michael Crichton.  I’m a fan of his stuff, and in the last year I also read Next, State of Fear, and A Case of Need.  I’ve also been reading a lot of James Rollins novels (which Michelle got me started on), which … more

  • Working with Application Pool Identities

    There a new feature of IIS called Application Pool Identities that was apparently introduced with SP2 of Windows Server 2008.  There’s a nice overview of Application Pool Identities here, which is the basis for this post, which is just my notes on the feature. If you’re setting up new web sites and application pools in IIS on Windows Server 2008, it’s likely they’ll default to ApplicationPoolIdentity, like this: This is all well and good, and for the most part you don’t need to care about how this works behind the scenes or why it’s different than the other bazillion different esoteric accounts you’ve had to know about over the last 10 years when setting up IIS for ASP.NET … more

  • Software Engineering 101 in Cleveland

    Next week I’ll be one of several speakers at a free one-day event being held at the Microsoft office in Independence, Ohio.  The event is designed for Microsoft developers who are seeking to improve their skills in software engineering, including object-oriented design, design patterns, and automated testing.  The event is being hosted by Microsoft and organized by the Hudson Software Craftsmanship group and NimblePros consulting services. Initially there were 50 slots available – I think there are about 15-20 left as of today.  The event is scheduled for 16 July 2010 from 830am to 4pm, so if you can get approval to come for some free hands-on training, sign up fast before … more

  • Set Up Build Agents By Project in TeamCity

    We’re using TeamCity to manage our continous integration builds for CodeProject.com and LakeQuincy.com.  Before TeamCity, I was using CruiseControl.net, and TeamCity is much easier to get working (and requires far less XML manipulation).  I do miss CCTray, which I found to be much nicer than the TeamCity tray notifier (which if you click on it never shows anything immediately – it has to go and get it which imposes a delay – it also doesn’t do sounds like CCTray does – but I digress). Let’s say you have several large projects and you want them to run on the same instance of TeamCity.  Let’s further assume that some of these build configurations do a lot of stuff, and thus … more

  • How Can I Determine The Current Controller or Action in an Html Helper

    If you’re writing an HTML Helper for ASP.NET MVC you may want to do something different based on whether the page that is to be rendered was arrived at via a particular controller or controller action.  I found the following code which does just this in one of the ASP.NET MVC Themes available from the www.asp.net web site (the Dark theme, I believe it’s called). Note that I’ve already modified this code to work with the new ASP.NET 4 string encoding and the MvcHtmlString type, as I wrote about previously. public static MvcHtmlString LoginLink(this HtmlHelper helper) { string currentControllerName = … more

  • Budding Versus Festering Code

    This is in response to Michael Feathers’ recent post on Festering Code Bases and Budding Code Bases. Certainly the default tooling in the Visual Studio space has, until recently, made it dramatically easier to add code to an existing class than to create a new class.  However, tools like ReSharper have a large impact on this, and can make it extremely easy to create new classes, put them in their own files, and move those files where they are supposed to go with just a few keystrokes (and VS2010 is coming along in some of these areas as well).  So, I think there is a trend in the tooling to make the cost of budding less - it would be interesting to add something to the IDE that … more

  • Disable Hibernation on Servers

    Here’s a quick tip if you should find several GB of your system drive taken up with hiberfil.sys on a production server machine (as I recently did with a virtual server with a very small C partition) – Disable Hibernation. Disable Hibernation 1. Open a command prompt as administrator 2. Run this command: powercfg –h off 3. Done! The hiberfil.sys file should immediately disappear.  This also works on desktop computers that never use hibernate, of course.  Thanks to SpearMan for the tip.  I’ve only tested this on Windows Server 2008, but I’m pretty sure it will work on most modern versions of Windows (7, Vista, 2008 R2, etc.). more

  • Default Encoding of Strings in ASP.NET MVC 2

    If you have ASP.NET MVC 1 code you are moving to ASP.NET MVC 2 (and ASP.NET 4) you are likely to encounter a problem in which your application starts displaying encoded HTML on the page rather than the actual results of that HTML (e.g. you see <a href … /> instead of a hyperlink). One of the greatest features added to ASP.NET 4 is a new way to render content that is encoded by default in your .aspx/.ascx pages/views.  This new syntax uses <%: Model.SomeString %> instead of the ever-popular <%= Model.SomeString %> way of doing it.  Note the third character is now a : not an =.  It actually takes up a tiny bit less horizontal space – isn’t that nice of the … more

  • Tagging Releases in Source Control

    A best practice when you’re using source control is to tag your releases.  What does this mean, exactly?  If you’re following the relatively standard non-distributed source control repository folder structure of having root folders for: branches tags trunk then it means simply making a copy of the current state of the system when you did your release.  Here’s how to do it using Subversion (SVN) and the TortoiseSVN client, both popular free tools for source control management. Step 1: Test and Deploy Your Application Do whatever it is you do to deploy your application.  Maybe you create an EXE package.  Maybe you FTP a web site to production.  Whatever … more

  • Moving a Certificate Between Web Servers

    I’m in the process of moving Lake Quincy Media’s web site from one server to another, and since it uses SSL to secure users’ data, I had to move the certificate to the new server as part of the server move.  Fortunately, this process is quite painless.  First, you need to export the certificate to a .pfx file and give it a password, using these steps: 1. Start, Run, MMC (I did it as administrator) 2. Go to File –> Add/Remove Snap-in 3. Click on Certificates and Add 4. You want Local Computer.  Click Finish 5. Click OK to close the Add/Remove Snap-in wizard 6. Expand the Certificates (Local Computer) tree. 7. Open the Personal – Certificates section. 8. You should … more

  • SQL Server Error User Group or Role Already Exists in the Current Database

    If you restore a database and then try to login to it, you’re likely to run into this wonderful SQL Error: User, group, or role ‘whatever’ already exists in the current database (Microsoft SQL Server, Error: 15023). Unfortunately, using Sql Management Studio alone doesn’t seem up to the task of correcting this problem.  You have to drop down to calling esoteric stored procedures (who needs a GUI to actually manage users and logins, right?). Searching for this error at least yields many results like these.  I especially like the second one whose title ends with ‘Aarrgghh!!’ which led to me clicking it since it represented my current thoughts on the matter quite succinctly. In … more

  • Great Uses of Using Statement in C#

    In my last post about testing emails in .NET, I noted the use of the using statement to ensure safe usage of the IDisposable SmtpClient and MailMessage objects.  This is the typical usage of the using statement, but you can take advantage of this statement’s behavior for other scenarios as well, resulting in cleaner code. Consider the scenario where you want to perform some kind of pre- and post- processing around an arbitrary block of code.  The simplest scenario I know of is when you want to time some code, using the stopwatch class.  If you want to perform basic stopwatch usage, you can write some code like this (borrowed from the stopwatch MSDN docs): public … more

  • Testing Email Sending

    Recently I learned a couple of interesting things related to sending emails.  One doesn’t relate to .NET at all, so if you’re a developer and you want to easily be able to test whether or not emails are working correctly in your application without actually sending them and/or installing a real SMTP server on your machine, pay attention.  You can grab the smtp4dev application from codeplex, which will listen for SMTP emails and log them for you (and will even pop-up from the system tray to notify you when it receives them) – but it will never send them.  Here’s what the notification looks like: The other interesting tidbit about emails that is specific to .NET is that the … more

  • DevConnections Spring 2010 Speaker Evals and Tips

    As a conference speaker, I always look forward to hearing from attendees whether they felt my sessions were valuable and worth their time.  It’s always gratifying  get a high score, but of course it’s the (preferably constructive) criticism that’s key to continued improvement.  I’m by no means the best technical presenter around, and I’m always looking for ways to improve. I’ve recently spoken at a few events, including TechEd and an Ohio event called Stir Trek.  DevConnections was actually back in April, but they’re just getting their final evals out to speakers.  TechEd, of course, does online evals so immediately after your talks you can see what people … more

  • TechEd 2010 Important Events

    If you’ll be attending TechEd in New Orleans in a couple of weeks, make sure the following are all on your calendar:   Party with Palermo – TechEd 2010 Edition Sunday 6 June 2010 7:30-930pm Central Time RSVP and see who else is coming here.  The party takes place from 730pm to 930pm Central (Local) Time,  and includes a full meal, free swag, and prizes.  The event is being held at Jimmy Buffett’s Margaritaville located at 1104 Decatur Street.   Developer Practices Session: DPR304 FAIL: Anti-Patterns and Worst Practices Monday 7 June 2010 4:30pm-545pm Central Time Room 276 Come to my session and hear about what NOT to do on your software … more

  • Don&rsquo;t Throw Duplicate Exceptions

    In your code, you’ll sometimes have write code that validates input using a variety of checks.  Assuming you haven’t embraced AOP and done everything with attributes, it’s likely that your defensive coding is going to look something like this: public void Foo(SomeClass someArgument) { if(someArgument == null) { throw new InvalidArgumentException("someArgument"); } if(!someArgument.IsValid()) { throw new InvalidArgumentException("someArgument"); }   // Do Real Work } Do you see a problem here?  Here’s the deal – Exceptions should be meaningful.  … more

  • REST to Objects in C#

    RESTful interfaces for web services are all the rage for many Web 2.0 sites.  If you want to consume these in a very simple fashion, LINQ to XML can do the job pretty easily in C#.  If you go searching for help on this, you’ll find a lot of incomplete solutions and fairly large toolkits and frameworks (guess how I know this) – this quick article is meant to be a no fluff just stuff approach to making this work. POCO Objects Let’s assume you have a Model that you want to suck data into from a RESTful web service.  Ideally this is a Plain Old CLR Object, meaning it isn’t infected with any persistence or serialization goop.  It might look something like this: … more

  • Could not load type System.Configuration.NameValueSectionHandler

    If you upgrade older .NET sites from 1.x to 2.x or greater, you may encounter this error when you have configuration settings that look like this: <section name="CacheSettings" type="System.Configuration.NameValueFileSectionHandler, System"/> Once you try to run this on an upgraded appdomain, you may encounter this error: An error occurred creating the configuration section handler for CacheSettings: Could not load type 'System.Configuration.NameValueSectionHandler' from assembly 'System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Microsoft moved a bunch of the Configuration related classes into a … more

  • Custom Configuration Section Handlers

    Most .NET developers who need to store something in configuration tend to use appSettings for this purpose, in my experience.  More recently, the framework itself has helped things by adding the <connectionStrings /> section so at least these are in their own section and not adding to the appSettings clutter that pollutes most apps.  I recommend avoiding appSettings for several reasons.  In addition to those listed there, I would add that strong typing and validation are additional reasons to go the custom configuration section route. For my ASP.NET Tips and Tricks talk, I use the following example, which is a simple DemoSettings class that includes two fields.  … more

  • Shared Folders in VirtualBox on Windows 7

    In my adventures with VirtualBox, my latest victory was in figuring out how to share folders between my host OS (Windows 7) and my virtual OS (Windows Server 2008).  I’m familiar with VirtualPC and other such products, which allow you to share local folders with the VM.  When you do, they just show up in Windows Explorer and all is good.  However, after configuring shared folders in VirtualBox like so:   I couldn’t see them anywhere within the machine. Where are Shared Folders in a VirtualBox VM? Fortunately a bit of searching yielded this article, which describes the problem nicely.  It turns out that there is a magic word you have to know, and that is … more

  • Government Mandates and Programming Languages

    A recent SEC proposal (which, at over 600 pages, I haven’t read in any detail) includes the following: “We are proposing to require the filing of a computer program (the “waterfall computer program,” as defined in the proposed rule) of the contractual cash flow provisions of the securities in the form of downloadable source code in Python, a commonly used computer programming language that is open source and interpretive. The computer program would be tagged in XML and required to be filed with the Commission as an exhibit. Under our proposal, the filed source code for the computer program, when downloaded and run (by loading it into an open “Python” session on the investor’s computer), … more

  • Detect Unicode Usage in SQL Column

    One optimization you can make to a SQL table that is overly large is to change from nvarchar (or nchar) to varchar (or char).  Doing so will cut the size used by the data in half, from 2 bytes per character (+ 2 bytes of overhead for varchar) to only 1 byte per character.  However, you will lose the ability to store Unicode characters, such as those used by many non-English alphabets.  If the tables are storing user-input, and your application is or might one day be used internationally, it’s likely that using Unicode for your characters is a good thing.  However, if instead the data is being generated by your application itself or your development team (such as lookup … more

  • Sql Table Refactoring Challenge

    I’ve been working a bit on cleaning up a large table to make it more efficient.  I pretty much know what I need to do at this point, but I figured I’d offer up a challenge for my readers, to see if they can catch everything I have as well as to see if I’ve missed anything.  So to that end, I give you my table: CREATE TABLE [dbo].[lq_ActivityLog]( [ID] [bigint] IDENTITY(1,1) NOT NULL, [PlacementID] [int] NOT NULL, [CreativeID] [int] NOT NULL, [PublisherID] [int] NOT NULL, [CountryCode] [nvarchar](10) NOT NULL, [RequestedZoneID] [int] NOT NULL, [AboveFold] [int] NOT NULL, [Period] [datetime] NOT NULL, [Clicks] [int] NOT NULL, [Impressions] [int] NOT … more

  • Determine All SQL Server Table Sizes

    I’m doing some work to migrate and optimize a large-ish (40GB) SQL Server database at the moment.  Moving such a database between data centers over the Internet is not without its challenges.  In my case, virtually all of the size of the database is the result of one table, which has over 200M rows of data.  To determine the size of this table on disk, you can run the sp_TableSize stored procedure, like so: EXEC sp_spaceused lq_ActivityLog This results in the following: Of course this is only showing one table – if you have a lot of tables and need to know which ones are taking up the most space, it would be nice if you could run a query to list all of the … more

  • Sql Server Prevent Saving Changes That Require Table to be Re-created

    When working with SQL Server Management studio, if you use the Design view of a table and attempt to make a change that will require the table to be dropped and re-added, you may receive an error message like this one: Saving changes is not permitted.  The changes you have made require the following tables to be dropped and re-created.  You have either made changes to a table that can’t be re-created or enabled the option Prevent saving changes that require the table to be re-created. In truth, it’s quite likely that you didn’t enable such an option, despite the error dialog’s accusations, as it is enabled by default when you install SQL Management Studio.  You can … more

  • PowerShell Control over Nikon D3000 Camera

    My wife got me a Nikon D3000 camera for Christmas last year, and I’m loving it but still trying to wrap my head around some of its features.  For instance, when you plug it into a computer via USB, it doesn’t show up as a drive like most cameras I’ve used to, but rather it shows up as Computer\D3000.  After a bit of research, I’ve learned that this is because it implements the MTP/PTP protocol, and thus doesn’t actually let Windows mount the camera’s storage as a drive letter.  Nikon describes the use of the MTP and PTP protocols in their cameras here. What I’m really trying to do is gain access to the camera’s file system via PowerShell.  I’ve been using a very handy … more

  • Clone a VirtualBox Machine

    I just installed VirtualBox, which I want to try out based on recommendations from peers for running a server from within my Windows 7 x64 OS.  I’ve never used VirtualBox, so I’m certainly no expert at it, but I did want to share my experience with it thus far.  Specifically, my intention is to create a couple of virtual machines.  One I intend to use as a build server, for which a virtual machine makes sense because I can easily move it around as needed if there are hardware issues (it’s worth noting my need for setting up a build server at the moment is a result of a disk failure on the old build server).  The other VM I want to set up will act as a proxy server for the … more

  • Stir Trek 2: Iron Man Edition

    Next month (7 May 2010) I’ll be presenting at the second annual Stir Trek event in Columbus, Ohio. Stir Trek (so named because last year its themes mixed MIX and the opening of the Star Trek movie) is a very cool local event.  It’s a lot of fun to present at and to attend, because of its unique venue: a movie theater.  And what’s more, the cost of admission includes a private showing of a new movie (this year: Iron Man 2).  The sessions cover a variety of topics (not just Microsoft), similar to CodeMash.  The event recently sold out, so I’m not telling you all of this so that you can go and sign up (though I believe you can get on the waitlist still).  Rather, this … more

  • Run MSTest Without Breaking on Exceptions in VS2010

    Quick tip I just figured out (no R# installed yet) when using VS2010’s test runner.  If you want to just use the keyboard, then you can use ctrl-R T to Run Tests in Current Context.  But if like me you tend to just leave ctrl held down when you hit the T, your test run will stop at any/every exception.  Why?  Because ctrl-R T is not the same as ctrl-R ctrl-T which is the shortcut for Debug Tests in Current Context. Note to self, don’t be lazy and pick up your finger from the ctrl key when running tests… more

  • VS2010 Launch Presentations

    Last week I was in Vegas to present at the DevConnections / VS2010 Launch event.  The show was well-attended and everybody I spoke to agreed it was educational and enjoyable.  My three talks were all on Wednesday, 14 April 2010, including one at 8am for which I was impressed to see a large turnout in attendance.     Pragmatic ASP.NET Tips, Tricks, and Tools My first session was on tips, tricks, and tools for ASP.NET developers.  This is a talk I’ve given in past years, but which I refine every time.  I usually like to have a full session to devote to tools, and a separate talk just for Tips and Tricks, but for this show I was only given the one 75-minute … more

  • Adding Attributes to Generated Classes

    ASP.NET MVC 2 adds support for data annotations, implemented via attributes on your model classes.  Depending on your design, you may be using an OR/M tool like Entity Framework or LINQ-to-SQL to generate your entity classes, and you may further be using these entities directly as your Model.  This is fairly common, and alleviates the need to do mapping between POCO domain objects and such entities (though there are certainly pros and cons to using such entities directly). As an example, the current version of the NerdDinner application (available on CodePlex at nerddinner.codeplex.com) uses Entity Framework for its model.  Thus, there is a NerdDinner.edmx file in the … more

  • How To Move or Rename a File using MSBuild

    MSBuild is a very powerful tool, and it’s relatively easy to get started using it.  You can run a “hello world” example of MSBuild in no time, and it’s easy to build up the files incrementally as your needs (and knowledge of the tool) increase.  Here’s a handy list of the tasks that are built into MSBuild. Move File Task or Rename File Task One thing that is missing from the built-in list of tasks is a file rename (or move) task.  Fortunately, this is pretty easy to accomplish using a combination of the Copy and Delete tasks.  Here’s a real-world example that renames a file from _web.config to web.config as part of a deployment script written in msbuild: … more

  • How To: Automatically Remove www from a Domain in IIS7

    I recently moved the DevMavens.com site from one server to another and needed to ensure that the www.devmavens.com domain correctly redirected to simply devmavens.com.  This is important for SEO reasons (you don’t want multiple domains to refer to the same content) and it’s generally better to use the shorter URL (www is so 20th century) rather than wasting 4 characters for zero gain. My friend and IIS guru Scott Forsyth pointed me to his blog post on how to set up IIS URL Rewriting.  To get started, you simply install IIS Rewrite from this link using the super awesome Web Platform Installer.  You should get something like this when you’re done with the install: If you … more

  • ASP.NET MVC 2 and Windows Azure

    If you upgrade an Azure web instance to use ASP.NET MVC 2, make sure you mark the System.Web.Mvc reference as Copy Local = true.  Otherwise, your deployment will fail.  And you won’t get any good feedback from Windows Azure as to the cause of the problem.  So you’ll start searching the web for help, and perhaps you’ll stumble on this post, and you’ll realize that you didn’t set Copy Local = true on your System.Web.Mvc assembly reference in your ASP.NET MVC 2 web instance.  And you’ll  leave happy (or at least slightly happier) than when you came. That is all. more

  • Simple Branching and Merging with SVN

    It’s a good idea not to do too much work without checking something into source control.  By “too much work” I mean typically on the order of a couple of hours at most, and certainly it’s a good practice to check in anything you have before you leave the office for the day.  But what if your changes break the build (on the build server – you do have a build server don’t you?) or would cause problems for others on your team if they get the latest code?  The solution with Subversion is branching and merging (incidentally, if you’re using Microsoft Visual Studio Team System, you can shelve your changes and share shelvesets with others, which accomplishes many of the same things … more

  • Fix: SqlDeploy Task Fails with NullReferenceException at ExtractPassword

    Still working on getting a TeamCity build working (see my last post).  Latest exception is: C:\Program Files\MSBuild\Microsoft\VisualStudio\v9.0\TeamData\Microsoft.Data.Schema.SqlTasks.targets(120, 5): error MSB4018: The "SqlDeployTask" task failed unexpectedly. System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Data.Schema.Common.ConnectionStringPersistence.ExtractPassword(String partialConnection, String dbProvider) at Microsoft.Data.Schema.Common.ConnectionStringPersistence.RetrieveFullConnection(String partialConnection, String provider, Boolean presentUI, String password) at … more

  • Could Not Load Type Microsoft.Build.Framework.BuildEventContext

    Setting up a TeamCity build and got this error: C:\Program Files\MSBuild\Microsoft\VisualStudio\v9.0\TeamData\Microsoft.Data.Schema.SqlTasks.targets(80, 5): error MSB4018: The "SqlSetupDeployTask" task failed unexpectedly. System.TypeLoadException: Could not load type 'Microsoft.Build.Framework.BuildEventContext' from assembly 'Microsoft.Build.Framework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. at Microsoft.Build.BuildEngine.TaskExecutionModule.SetBatchRequestSize() at Microsoft.Build.BuildEngine.TaskExecutionModule..ctor(EngineCallback engineCallback, TaskExecutionModuleMode moduleMode, Boolean profileExecution) at … more

  • Fix: Can&rsquo;t Change or Remove Visual Studio 2008 from DVD

    If you installed Visual Studio 2008 on a 64-bit operating system, you may have trouble when you try ad add or remove functionality by inserting the disk (or remounting the ISO image).  I believe this is because of the path used to install the 32-bit Visual Studio program.  When you run the setup.exe off of the disk, you get this: Clicking on Change or Remove Visual Studio 2008 brings up this dialog: But not long after it appears, it disappears to be replaced with: Microsoft Visual Studio 2008 Setup A problem has been encountered while loading the setup components.  Canceling setup. FIX: Use Add or Remove Programs Launch the Add or Remove Programs dialog in … more

  • Open Visual Studio Files As Administrator

    Working with IIS as your web server, or working with Azure projects, are two examples of situations in which Visual Studio (2008+) needs to be running as Administrator (on Windows Vista or Windows 7).  If you don’t run it as such, you may be faced with a dialog like this one (for Azure): Now of course if you have Visual Studio pinned to your taskbar or start menu, you can launch it as admin by right-clicking and selecting Run As Administrator, as Jeff Blankenburg shows here.  That’s great for one-off things, but in my scenario I really want to be able to double-click on a .sln file and have it open with Visual Studio as an administrator: The solution as suggested by … more

  • Eliminate Repetition with Action&lt;T&gt;

    Yesterday I was looking at some old code and refactoring it to clean it up (in this case I wasn’t the original author, but I’ve written code just like this).  The application in question was a simple process that had to run once per month, on demand, and so was coded up as an EXE application.  As it ran, it provided updates on its progress, so it looked something like this: static void Main(string[] args) { Console.WriteLine("Starting Application @ " + DateTime.Now); var parser = new ParameterParser(); Parameters parameters = parser.Parse(args); Console.WriteLine("Finalizing Revenue for " + … more

  • SQLite Error IDbCommand and IDbConnection implementation in the assembly System.Data.SQLite could not be found.

    I just ran into a problem with SQLite and NHibernate, which was giving me this error message: The IDbCommand and IDbConnection implementation in the assembly System.Data.SQLite could not be found. The strange thing was, it worked fine from within Visual Studio, but it died when I used my ClickToBuild.bat file, which calls msbuild and runs my tests from the command line.  A bit of searching led me to a similar problem on StackOverflow, which produced the answer: Use the x64 binaries. I downloaded the latest version of SQLite (SQLite-1.0.65.0-binaries.zip) and made sure to use the .dll in the x64 folder, and the problem disappeared.  It’s worth noting that I’m running on … more

  • Untrusted Projects and Blocked Files in Visual Studio

    I was just trying to open a project I was emailed as a zip file from a colleague.  VS2010 opens up saying: You should only open projects from a trustworthy source. The project file 'project' may have come from a location that isn’t fully trusted. It could represent a security risk by executing customer build steps when opened in Microsoft Visual Studio that could cause damage to your computer or compromise your private information. Which is fine… but in this case I know the project is OK so I click the box and tell it to get on with it.  Next, I try to run the project, but I am faced with this: Error    1    The "ValidateXaml" task … more

  • SELECT from a Stored Procedure

    Occasionally I find myself wanting to SELECT from a SPROC in SQL Server.  Usually this is because I want to ORDER the results or filter them further with a WHERE clause.  Unfortunately, you can’t just do this: SELECT *FROM(EXEC mySproc foo, bar) There are several workarounds here, and the appropriate one depends mostly on whether you have any control over the use of the stored procedure, or how it works.  For example, you could choose to use a VIEW instead of a stored procedure.  Unfortunately, a VIEW usually won’t work if you need to pass parameters to your stored procedure (which I’m guessing you are).  If your sproc is literally just a wrapper for a query … more

  • Avoid Regions for Interfaces in Visual Studio

    Another quick tip related to the use of regions in your C# code – you can turn off the default behavior of wrapping interfaced implementations in regions via the options dialog.  Simply go to Tools –> Options –> Text Editor –> C# –> Advanced as shown in the screenshot below, and uncheck the “Surround generated code with #region” checkbox. more

  • Moving SVN Repositories to new Server

    Recently I had to move some SVN repositories from one server to another.  Here are the steps that worked for me, courtesy of Pete Freitag: Step 1: Back up SVN Repository Back up your existing repository with the following command.  Note that if you are using VisualSVN Server as I blogged about previously, you should be able to right-click within the VisualSVN server manager and get a command prompt that will have the correct paths and such to do this: svnadmin dump /path/repositoryfolder > repositoryname.svn_dump Notice the ‘>’ and its direction.  It’s important. Step 2: Create New SVN Repository (on new server) Next create a new repository.  You can … more

  • Silverlight Tools

    As we approach the launch of Silverlight 4 and today the 2010 Winter Olympics begin (which are streaming via Silverlight!) I thought I’d post about some Silverlight Tools you may find useful as you build Silverlight applications.  Some of these are also good WPF or general XAML tools.  I haven’t used all of these personally – some are on the list because people I respect have vouched for them.  If you have favorites of your own, please let me and other readers know via the comments. The Silverlight Basics You can Get Started with Silverlight by following the steps on the Silverlight site.  The Web Platform Installer makes it easy to get the SDK, developer runtimes, and … more

  • Tight Coupling, Legos, and Super Glue

    Building software applications is sometimes compared with building structures out of smaller components.  The children’s toys, Legos (and their generic brethren), come to mind and in fact make for a good analogy.  Given a set of components with varying characteristics (shape, color, etc, or in the case of software, objects with different behavior and state), it is possible to connect the components in order to create a larger structure, with (hopefully) more advanced capabilities. The reason Legos can connect to other Legos is because of the raised cylinders that correspond with similarly shaped cavities in the bottoms of the pieces.  These comprise the interface that allows … more

  • Hiring Inbound Marketing Score CARD

    In their book, Inbound Marketing (review), authors Shah and Halligan use a couple of acronyms that, maybe due to my military background, I thought could be improved.  The first one was VEPA, which I thought made a lot more sense as PAVE.  PAVE relates to qualities of a call to action, and it is easy to remember that if your call to action has these qualities it will PAVE the way to better results. In chapter 12, the authors describe a  “framework…for hiring and developing inbound marketing savvy employees.”  Like VEPA, this four-letter acronym is a nonsense word, DARC.  Again, it’s easy to see how this can be improved by converting it into an actual word, CARD, and … more

  • PAVE the Way to Effective Calls to Action

    In their book, Inbound Marketing (review), authors Shah and Halligan describe some key traits of effective calls to action.  The four important qualities of killer calls-to-action are that they be Valuable, Easy-to-Use, Prominent, and Action-Oriented (chapter 8).  The authors go on to suggest that this be referred to as “VEPA”, but I think we can do better than that.  By simply shifting the letters by 2 positions, this becomes the much more memorable mnemonic, PAVE: Prominent.  Your offer must stand out.  It should be difficult to miss.  Don’t make potential customers have to think about how to interact with you. Action-Oriented.  You want the visitor to … more

  • Inbound Marketing and Small Business Trends

    I recently read Dharmesh’s and Brian Halligan’s Inbound Marketing book, which has a lot of good tips for startup companies to follow in order to maximize their online reach and popularity.  Many of the tips are pretty obvious: start a blog, get people linking to you, build a following on twitter.  But there are some that are pretty easy to overlook, and at the end of the book is a very good appendix that is a checklist for any startup or small business to follow. One of the key points that describes the importance of Inbound Marketing, is that it is difficult for your competitors to one-up.  First, let me explain that inbound marketing differs from outbound in that you are … more

  • Prevent Resharper From Adding Regions

    A couple of days ago I was annoyed that Resharper was insisting on turning my abstract base NUnit test class with nothing in it but a shared [SetUp] method into a one line class with a collapsed Setup / Teardown region in it.  While I didn’t always feel this way, my experience has taught me that regions are a smell in your code.  They are a way to hide things you don’t want to deal with or look at.  It’s kind of like putting makeup over a melanoma instead of having a doctor remove it.  Here’s a pretty good analysis of why regions are a code smell if you’re interested. So anyway, I’m using Resharper and am in general a huge fan, and I know I can configure this thing every … more

  • How to set up TRIM with Win7 and SSD Drive

    I have an Intel X-25M SSD in my developer workstation machine (and it’s quite fast).  However, I’ve heard from others that over time SSD performance can degrade due to sub-block level fragmentation that occurs as a result of write combining.  Fortunately, newer SSD drives (like mine) support the TRIM command, but of course this only works if your system is sending the command to the drive. How Do I Know if Windows is Using TRIM for my SSD? Fortunately (and thanks to Ken), there is a simple command you can execute to determine if windows is sending TRIM commands to your SSD drive. Run the following command: fsutil behavior query disabledeletenotify If the result is 0, then … more

  • Azure Tip: How To Deploy a ZIP File to Windows Azure

    Last month, The Code Project ran an Azure contest and gave away several Amazon Kindles.  As part of the contest, which we hosted on Azure, we deployed a sample project with all of the necessary install files for getting started with Windows Azure.  It turned out to be slightly more difficult than expected to actually get the zip file deployed to the cloud, so I thought I’d post here in case others ran into the same issue. The issue isn’t related to ZIP files, of course, but to any content file that is added to a web project that isn’t a typical ASP.NET or web file type (e.g. .aspx, .gif, etc.).  For instance, if you simply add a .zip file to an ASP.NET web … more

  • Party with Palermo: MVP Summit Edition

    The Code Project is sponsoring the next Party with Palermo in a few weeks at the MVP Summit.  If you haven't already, sign up.  The cost is a nominal $5, just to try and keep the RSVPs accurate.  You can see who else is coming on the sign-up page (via EventBrite), so check it out.  Hope to see you there! more

  • Product Idea: Polarizing Plate Covers

    I’m one of those people that is always coming up with crazy business or product ideas.  The problem is always that there just aren’t enough resources to go after every idea, and I at least know that An Idea is Not a Business so at least I don’t pretend that maybe some day I’m going to capitalize on these things.  So on the way to CodeMash last week talking to Brendan about Mythbusters, apparently the show did an episode about trying to defeat traffic cams that take a picture of your license plate if you’re speeding.  I haven’t seen the show, but the end result was that most of the things people have tried (or businesses sell) to avoid these cameras simply don’t work.  … more

  • Windows Azure Pricing and Shared Hosting

    Windows Azure, Microsoft’s cloud computing platform, has recently gone into production and will begin charging customers next month.  You can keep up on Azure news and blogs at AzureFeeds.com, a community moderated resource.  One of the promises of Azure is to treat application hosting like a utility service, through which one pays for what one uses, just as with electricity or telephone usage.  In fact, you’ll find that, like your phone plan, there are many options to consider when trying to estimate what an application will cost while running on Azure, but there are also many ways to test out an application for free (such as via MSDN Premium).  You can learn more about … more

  • Axosoft OnTime and Queues

    At CodeProject we’ve recently adopted Axosoft OnTime for our task, feature, and bug tracking needs.  We had tried a number of different solutions, and there was even some discussion of building our own (naturally), but in the end we’ve settled on OnTime, at least for the time being. OnTime breaks up items into Defects, Tasks, and Features by default, and you can establish fairly rich workflow rules for each of these that tie into actions (for example, there is a status for ‘Complete’ but also a workflow of ‘Complete’.  If you choose to use the workflow feature, you can make it so that when the item moves into the Complete state, various other things occur, like re-assigning it … more

  • Coding Katas

    Last week at CodeMash I helped host a Software Craftsmanship PreCompiler onWednesday afternoon.  I also helped organize a coding dojo for the event, but it was very last minute and didn’t have a lot of instructions for developers new to performing katas.  Having a room where people could get together and work through a problem together, perhaps in a new language, was still very worthwhile and totally in the spirit of CodeMash, so I’m not terribly disappointed.  But next year, based on Sara’s experience, I think we definitely can do a better job of explaining some of the terms used and ways that one can improve one’s skills in such an environment. Sara asked about what … more

  • Goals for 2010

    I recently wrote about how I did with my 2009 goals, now it’s time to set a few for this year.  Let’s start with two that didn’t go so well for me last year: 1. Get In Shape.  By the end of 2010 I will be under 200 pounds.  I will have achieved my Brown Belt in karate.  I will have biked 100 miles.  (I have a Wii Fit Plus now, so I’m sure I’ll also get better at many of the games on the system). 2. Blogging.  This year my goal won’t be for post quantity.  Rather, I want to increase my readership.  By the end of 2010, I will double my readership (RSS) from about 1250 now to 2500.  I will double December 2009’s 14,499 pageviews in December 2010 … more

  • Is Extreme Programming Dying? Is Agile Growing in Popularity?

    It’s interesting to compare the interest over time in various software development methodologies and practices.  Google Trends is a great tool for this, although it’s not without limitations, especially since so many programming terms have other meanings.  For instance, you can use it to visually show how interest in eXtreme programming has (sadly) been waning for many years now: Meanwhile, Scrum has been growing in popularity, but it’s difficult to do a fair comparison because scrum appears frequently in searches that have nothing to do with software development. Three inter-related development methodologies of interest to me are Test Driven Development, Agile Software … more

  • Personal Goals and Transparency 2009

    I find that if I commit to things in writing, they have a much higher chance of getting done.  And if I commit to them in writing on the Internet where everybody in the world can see it, even though I realize that nobody in the world cares, it gives me even more motivation to follow through.  So with that in mind, I’ve been posting my annual resolutions to my blog, and in 2009 I resolved to do the following: Get In Shape (190 pounds, Biking, Hiking).  Result: Fail (same weight as a year ago, went biking twice, no hiking).  Could be much worse, I suppose, but I’m not as fit as I’d like to be, as usual. Speak Locally (6 for year).  Result: Success.  In … more

  • Most Popular 2009 Posts

    If you’re one of my subscribers, you’re probably a software developer, or perhaps someone I know personally.  You might be surprised to find that many of the most popular posts on my blog in 2009 were not particularly developer-oriented.  According to Google Analytics, my blog had the following stats for 2009: 1. Codebehind Files in ASP.NET MVC Are Evil (8,320 pageviews) – Yes, I know it’s a cheap trick to call something evil to get people’s attention, but it also happens to work.  And thankfully when ASP.NET MVC shipped, it did so without codebehind files included with the views, at least in part as a result of this discussion. 2. Render ASP.NET … more

  • Whew! Made It Through 2009

    So, 2009 is over.  It was an interesting year, wasn’t it?  Talking to many of my friends and peers, especially entrepreneurs like other Regional Directors, I share a sense of relief that the year is behind us.  We made it.  For many, 2009 was a year with a lot of financial dread,  and often loss.  For me, the whole year was “ninjas on fire” – there never seemed time to take a breath, and it felt like I was having to run twice as fast just to stay in place. In fact, the global economic dip is certainly not over, but I know many who are looking to 2010 with hope, whereas a year ago nobody was sure where the bottom would be in the financial crisis.  Have a … more

  • Software Craftsmanship at CodeMash

    This week at CodeMash I will be co-hosting a Precompiler session on Software Craftsmanship with Brendan Enrick on behalf of the Hudson Software Craftsmanship group (@HudsonSC on twitter).  The Software Craftsmanship session will take place Wednesday afternoon on 13 January 2010.  This will be a chance to improve your skills as a software developer, regardless of your language preference or level of expertise, by working with your peers on a variety of exercises and katas.  We will be pairing attendees up, and each pair should have a laptop with a dev environment of your choice, so please bring along your laptops to the session.  From the abstract: Join your peers and … more

  • Unlock All Doors When Parking Honda Ridgeline

    I’ve had a Honda Ridgeline for a little over a year now and one of the absolute most annoying things about this vehicle is that when you drive, it locks all the doors, but when you stop, it only unlocks the driver’s door.  Now, this is independent of the child safety locks that are switch-activated for the back doors.  This is just a pure annoyance that makes me want to strangle some engineer somewhere about three times a week. So, it finally bugged me enough for me to figure out if there is a way to change this behavior, and it turns out there is (apparently it’s in the owner’s manual, but who reads those things when you have the Internet?).  The answer is pretty simple: … more