Recently in Visual Studio Category

The review of CryptoLicensing for .NET that Roy Osherove posted recently was very well written and covered a topic that I've long held a mild level of curiosity around. That topic being protecting code/software that's written using a .net language from a licensing perspective.

There's a whole black-market industry surrounding the cracking of software and irrespective of the legality or ethics of it, I'm pretty sure a lot of people have used cracked software at some point (bonus points and the moral high-ground to those who claim they haven't and are actually telling the truth!). Be it cracked/patched software, a serial number generator, a serial number that everyone's using, there are ways and means. By far the simplest is probably with something like WinRAR that pops up a "Please purchase WinRAR license" dialog box and relies on honesty, with more complex and convoluted solutions like Microsoft's OS licensing that can go horribly wrong if their activation servers have a bad day. Not to mention the "what will happen when" scenario for when Microsoft finally get bored of providing activation servers/services for Windows XP.

The thing that particularly sparked my interest was a comment from Frans Bouma, which could be summed up pretty much as saying "whats the point?", which seems to be a very good question. My opinion is that some form of licensing/activation solution at least raises the bar and reminds people using the software isn't actually free for them to use and do with it what they will. Plus, software that has an "n-day trial" that's expired is likely to get paid for if it's expired and then its use is required. I frequently install software for a single/ocassional task that has a "30 day trial" attached, or similar, and then promptly forget about it. When I then come to perform that task again 6 months later, if the price is right I end up buying it. If not, off comes the software and something else is found.

A fantastic example of this is a project I worked on about 2 years ago, I'd played around with a trial version of some .net data access layer generating software (I can't for the life of me remember what it was, one laptop later and it's not installed - but I have the license key somewhere!) a few months before that for a one-time-use tool I needed to write and then had this project thrown at me with a very tight deadline and no other development resource. I remembered the software, loaded it up, "out of trial", bugger! One credit card transaction later the license key was in my inbox and in the product. So, licensing control software worked for the publisher concerned!

Now, I wonder if there's a trial version of CryptoLicensing available that I can have a play with,....?
One of the really annoying things with PDB files is when you don't have them for something. Be it 3rd party component, module you just plain don't care about. John Robbins seems to be the PDB guru and has written "Keeping specific PDB files from loading in the debugger".

The guy's a genius.

PDB Files ... The Complete Works

| | Comments (0)
Just because these two articles really can't get enough link-love! The definitive guide to PDB files, what they are, how to use them and why you (as a developer) should have a really deep understanding of just how much easier they can make your life.

John Robbins - PDB Files: What every developer must know
John Robbins - Visual Studio remote debugging and PDB files

Miscellanea 15

| | Comments (0)
Yet another link dump of things that I'm probably going to find useful:
Creating a folder inside the ZIP file with System.IO.Packaging
Fire and Forget class for ASP.NET
ASP.NET 4.0 and Visual Studio 2010 Web Development Overview

And a link that's as amusing as it is interesting, "Teach me to smoke", which reminds me of being at University where the example of how to boil a kettle was used as an exercise in exactly the same way.

Custom Visual Studio Item Templates

| | Comments (0)
More of a note to self than anything else, as the software I'm working on uses a dervived System.Web.UI.Page and always uses a set master page, so time is saved by having a custom webform template:


Really rather useful!

Miscellanea 7

| | Comments (0)
A New Look for Visual Studio 2010

Now, I don't particularly care what VS2k10 looks like as long as it does the job, but some of the new functionality like multi-monitor support and a better extensibility model do interest me quite a lot. There have been numerous times I've thought "It'd make my life easier if I could just add to VS so it did XYZ" and then I've been put-off by the heinous monster that is its current extensibility model. I'm sure it's very strong, but, yeuck!

"Fix it" - The Next Evolution of KB Articles and WER

I'm sure AOL had something similar, about 10 years ago, within their client software for resolving connectivity and other AOL related issues (oh yes, there were many, many issues!). It's nice to see Microsoft finally implementing something similar as this will take the pain out of solving some computer related problems for a lot of people.
Could not load file or assembly 'NameOfAssemblyGoesHere' or one of its dependencies. An attempt was made to load a program with an incorrect format.

This message being spewed-forth by an asp.net application means that the DLL concerned has been compiled as a specific "bitness", but one that doesn't match that which IIS is running at. The most usual reason for this is an assembly marked as "x86" deployed to an "x64" server. If the assembly doesn't P/Invoke out to any 32-bit DLLs, change the platform target to "AnyCpu".

As far as the .net framework is concerned, the x86/x64 categorisation is only used as an indicator of requirements, thus if no P/Invoke is going on it's not needed, as the JIT compiler takes the assembly and JIT compiles it to the relevant instruction set at runtime anyway.
The structure of a Web Setup Project (.vdproj) file is just plain strange as it's "kinda" like XML but with curly braces ( { and } ) and quotes instead of < and > symbols.Go figure.

If you have a large website that you build an MSI for using this technology, it's worth excluding "SCC" and "VSSSCC" files from the installer that's produced as you don't need them on the web server target and it'll reduce the install time and MSI size by a teeny tiny fraction. Anyhow, to do this, look for "ProjectOutput" in the .vdproj file in notepad and you'll find something similar to:

        "ProjectOutput"
        {
            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_BD879AEA2DAF432A83AD511860E15E8C"
            {
            "SourcePath" = "8:"
            "TargetName" = "8:"
            "Tag" = "8:"
            "Folder" = "8:_9C12D7A6BA9C4F5EB16D2E73FBD55EB3"
            "Condition" = "8:"
            "Transitive" = "11:FALSE"
            "Vital" = "11:TRUE"
            "ReadOnly" = "11:FALSE"
            "Hidden" = "11:FALSE"
            "System" = "11:FALSE"
            "Permanent" = "11:FALSE"
            "SharedLegacy" = "11:FALSE"
            "PackageAs" = "3:1"
            "Register" = "3:1"
            "Exclude" = "11:FALSE"
            "IsDependency" = "11:FALSE"
            "IsolateTo" = "8:"
            "ProjectOutputGroupRegister" = "3:1"
            "OutputConfiguration" = "8:"
            "OutputGroupCanonicalName" = "8:ContentFiles"
            "OutputProjectGuid" = "8:{A986933C-EB0C-4375-8B80-6E948D13A0BD}"
            "ShowKeyOutput" = "11:TRUE"
                "ExcludeFilters"
                {
                "ExcludeFilter" = "8:*.refresh"
                "ExcludeFilter" = "8:*.vssscc"
                "ExcludeFilter" = "8:*.scc"

                }
            }

I've already put in the bits you need to add (in bold). Simple as that!

Licensing a Build Server

| | Comments (0)
Take a trip to the Microsoft Software License Terms page on microsoft.com. Once you've suffered through all the postbacks just to get to the Visual Studio 2008 English Retail license terms, take a read of parts 1 and 2.

1.  OVERVIEW.
b.  License Model.  The software is licensed on a per user basis.
2.  INSTALLATION AND USE RIGHTS.
a.  General.  One user may install and use copies of the software to design, develop, test and demonstrate your programs.  Testing does not include staging on a server in a production environment, such as loading content prior to production use.
Does, based on the bits highlighted in bold, this mean that a buildserver doesn't require its own licensed copy of Visual Studio, as long as each and every developer is using a licensed copy of the same edition of Visual Studio as installed on the buildserver? I'd love to know the definitive answer to that!

I suspect the answer is "the buildserver needs its own copy", in which case "boo hiss boo", but that's what we've paid for, to be on the safe side.

Miscellanea 4

| | Comments (0)
Visual Studio add-in: CopySourceAsHTML

How very, very, very useful! Certainly looks better than the one I've been using. Time will tell!

TestDriven.Net 2.19: Release Notes

Nothing more to say really, there's a new version to upgrade to. Time to upgrade.

And finally, someone complaining (albeit mildly and constructively!) that the IE8 installer progress bar doesn't render in a useful fashion when youn use a non-Microsoft provided theme on Windows XP. Given that using a non-MS theme involves patching DLLs and generally putting your O/S into an unsupported state, a non-useful render of a progress bar is pretty good going. Given that "fixing" this would involve Microsoft putting in a code path in their installer, along with UI components, to cater for their O/S being in an unsupported configuration - I don't see it happening any time soon..
A couple of things to remember:

  1. Most, if not all, of your installed tools that the build scripts use will need any references to C:\Program Files\ changed to C:\Program Files (x86)
  2. Force ncover and nunit-console to 32-bit. Seriously, if you get the message "Profiled process terminated. Profiler connection not established" when chaining nunit-console through ncover, follow those instructions.
Those are my saving graces!
If you have an ASP.net web site (Visual Studio 2005 heritage from when project files disappeared), you might be using Visual Studio to build it into an MSI Installer in your CruiseControl.NET build server. If you're not, lucky you! :)

If you are, it's useful to be able to see Visual Studio's build output in the build log CC shows you, so try this:

  <target name="build.devenv90.website">
    <exec program="${DevEnvExe.90}">
      <arg value='/Rebuild release "C:\BuildServer\VSS\WebSite\Website.sln" /Out "c:\buildserver\vss\website\vs_errors.txt"' />
    </exec>
    <trycatch>
      <try>
        <loadfile 
          file='C:\buildserver\vss\WebSite\vs_errors.txt'          
          property='VisualStudio.Output'
        />
        <echo message='${VisualStudio.Output}' />
      </try>
      <catch>
        <echo message='*** Visual Studio Output Failed ***' />
      </catch>
    </trycatch>
  </target>
The trick there is using the loadfile task to pull Visual Studio's output into a property and then echo-ing it. Nothing more exciting than that really!