Friday, March 26, 2010

Bart @ Techdays 2010

Next week I’ll speak at the Techdays 2010.

If you want to attend one of my sessions:

See you all there!

Generalists vs Specialists

I’m just wondering…

I see a lot of people who call them self specialists in a specific technology. But these self called experts seem to believe that specializing in something simply means you don’t have to know about other things.

“Yeah, I know everything about technology X (replace by the latest shiny toy) so why should I need to learn good OO design or do testing and so on…?”

Compare it with following situation (from one of the Pragmatic Programmer books):

Imagine you visit your family doctor, complaining about a strange lump under the skin of your right arm. Your doctor refers you to a specialist to have a biopsy performed. What if that specialist was a person whose only credentials as a specialist were that they didn’t attend any classes in medical school or have any experience in residencies that weren’t directly relevant to the act of performing the specific procedure that they were going to perform on you today? What if they didn’t know anything else?

The software industry has churned out a whole lot of these shallow specialists, who use the term specialist as an excuse for knowing only one thing. In the medical industry, a specialist is someone with a deep understanding of some specific area of the field. But never forget that a specialist is also a doctor. It’s just that for a specific issue the specialist can give them better care than a general practitioner.

Thankfully, most software experts aren’t responsible for life-or-death situations...

Command-Query Separation for dummies

The more I read about CQRS, the more I start to like it.

Some really good references:

Failed to load Profile data in an ASP.NET website

As I had the same problem before, always be careful if you install an ASP.NET website on a server where Sharepoint is already running. 

Sharepoint removes some modules from the request pipeline. So if you need these modules, explicitly re-add them in the web.config of your ASP.NET application.

One to remember!

NHibernate Access Strategies

As I keep forgetting the different options I have to specify how NHibernate should map database columns to properties, this quick reminder to myself:

  • property
  • field
  • field.camelcase
  • field.camelcase-underscore
  • field.pascalcase-m-underscore"
  • field.lowercase-underscore
  • nosetter.camelcase
  • nosetter.camelcase-underscore
  • nosetter.pascalcase-m-underscore
  • nosetter.lowercase-underscore

Team Foundation Server Administration Tool goes 2010

The TFS Administration Tool allows Team Foundation Server administrators to manage user permissions on all three platforms utilized by Team Foundation Server: Team Foundation Server, SharePoint, and SQL Server Reporting Services. The tool also allows administrators to easily copy user permissions among team projects and to easily identify any missing permissions on any of the three platforms. This makes my life as a TFS administrator a lot easier.

The TFS Administration Tool 2.0 Beta has been released and it brings support for Team Foundation Server 2010 RC.

This release also contains a new feature - User Import. This allows administrators to copy user permissions between two team projects on the same server.

Run Tests in Current Context fails in Visual Studio 2010 RC

One very annoying issue I had after upgrading from Visual Studio 2010 Beta 2 to the RC, that the ‘Run Tests in Current Context’ options runs all tests in my solution. As I’m having a lot of tests, I needed a solution.

It turns out that this is caused by a change that was made in Visual Studio 2010 RC to the way Test Settings files are stored. In this blog post, they describe that you can fix the issue by opening each Test Settings file (*.testsettings) contained in your solution, making a trivial change, and saving it.

Team System 2005 Service Pack 1 Forward Compatibility Pack

Important for the people among us who are still developing in Visual Studio 2005. There is an update for the 2005 SP1 version of Visual Studio Team System Team Explorer that allows the 2005 SP1 version to work with the Team Foundation Server 2010.
The update will allow teams to move forward and use the Team Foundation Server 2010 server even if part of the team continues to use the Team Explorer 2005 SP1 client.

Download it here.

IMPORTANT

  • The Visual Studio 2005 SP1 is a required prerequisite to install this update.
  • If you plan on using TFS Office Integration with in a side by side configuration with Visual Studio 2010, you will need to install the side-by-side Hotfix KB946075.
  • VS 2010: Interop type cannot be embedded. Use the applicable interface instead.

    For a recent project we had to use the Excel Interop Assembly. But after referencing the Interop Assembly in Visual Studio 2010, we get an error when we try to compile.  Setting the "Embed Interop Types" to FALSE  solves the problem but of course than we loose a nice new feature in Visual Studio 2010.

    So where does this error comes from? One of the limitations for 'Embed Interop Types' feature has been that classes cannot be used when embedding an assembly. This limitation has to do with servicing - it is safe to embed metadata but not anything that can potentially contain executable code (class types contain metadata AND code while interfaces only contain metadata). When you try to references a class type from an Interop Assembly for which the "Embed Interop Types" is set to TRUE compiler do issue a warning.

    In most cases this error is the result of code which tries to instantiate a COM object e.g. here piece of code starting up Excel:

       1:  Excel.ApplicationClass xlapp = new Excel.ApplicationClass();


    Here it is enough to say that Excel.ApplicationClass derives from Excel.Application interface and one can even instantiate Excel using Excel.Application interface. Rewriting this code as below produces exact same results:

       1:  Excel.Application xlapp = new Excel.Application();

    Typically, to change your code to use an interface type instead of a class type you just need to remove the 'Class' suffix and compile the code! Another way to find what the applicable interface is - look at the definition of the class type. The class usually derives from one or more interfaces. Look at the definition of each interface - one of them will have CoClass attribute and this is the interface that you are looking for.

    Error installing WebSetup on Windows Server 2008 R2

    If you are having troubles installing a websetup on a Windows Server 2008(R2) environment, double check that you have the IIS 6 Metabase Compatibility Components installed.

    To install the IIS 6.0 Management Compatibility Components by using the Windows Server 2008 Server Manager

    • Click Start, click Administrative Tools and then Server Manager.
    • In the left navigation pane, expand Roles, and then right-click Web Server (IIS) and select Add Role Services.
    • On the Select Role Services pane, scroll down to IIS 6 Management Compatibility.
    • Select the check boxes for IIS 6 Metabase Compatibility and IIS 6 Management Console.
    • Click Next from the Select Role Services pane, and then click Install at the Confirm Installations Selections pane.
    • Click Close to leave the Add Role Services wizard.

    To install the IIS 6.0 Management Compatibility Components by using the Windows Vista Control Panel

    • Click Start, click Control Panel, click Programs and Features, and then click Turn Windows features on or off.
    • Open Internet Information Services.
    • Open Web Management Tools.
    • Open IIS 6.0 Management Compatibility.
    • Select the check boxes for IIS 6 Metabase and IIS 6 configuration compatibility and IIS 6 Management Console.
    • Click OK.

    Thursday, March 18, 2010

    Nice Quote

    “I’m not a great programmer, just a good programmer with great habits”

    - Kent Beck

    Running BizTalk ESB Toolkit and Enterprise Library

    If you are using Enterprise Library in your application and you also have installed the BizTalk ESB Toolkit, expect some strange behavior.

    Your own configuration is hijacked by the ESB configuration. More information and a solution can be found here.

    Test Data Reporting in TFS 2010

    One of the new components in the Visual Studio 2010 offering is the Test and Lab Manager. This tool is great for creating and running your test suites. But creating reports on top of this data is not available in the tool itself. Luckily all information is stored in Team Foundation Server. So thanks to the build in reporting and the new excel reports feature, you’ll get the necessary data out the system.

    For an introduction in reporting  on your test management data, have a look at this blogpost:

    Disappearing tab in Microsoft Test and Lab Manager

    After using Test and Lab Manager for a while, suddenly the Test Results View disappeared after some resizing. We tried everything to get the tab back, but repairing, re-installing, cleaning the registry, nothing did the trick.

    Today a colleague finally found a solution. You have to clean the settings stored in the Local App Data section of your user profile. These settings are simple XML files that have your settings from MTLM – window size/location, whether the Test Runner is docked or floating, the queries you’ve configured in Test Case Manager, etc…

    To easily navigate to them on Windows Vista, 2008, 7, or 2008 R2, open this folder in Windows Explorer:

    %localappdata%\Microsoft\TeamTest\v10.0\

    Or, on XP, 2003, and 2003 R2:

    %userprofile%\Local Settings\Application Data\Microsoft\TeamTest\v10.0\

    In this directory you will see a number of *.config files. They will be prefixed with ‘mtlm’. The main configuration file is ‘mtlm.config’ – the other files you see are isolated files for each of the activities within MTLM.  Just delete all the *.config files in the folder mentioned above. You should do this while MTLM is not open, since we save your settings on exit. Once you’ve done this, you’ll start MTLM in the clean state you had it when you first installed it.

    Connecting with TFS 2010 from Team Explorer 2008 fails

    In theory, connecting with a TFS 2010 server from Team Explorer 2008 should not be a problem. You only have to specify the full url (eg. http://servername:8080/tfs) instead of only the servername.

    For most of our developers this worked fine, but for some of them this kept failing even after installing the Forward Compatibility Pack. Today I finally found the root cause of this issue. It was caused by the order in which components were installed on the developer’s machine.

    They first installed Visual Studio 2008, then upgraded to SP1 and then installed Team Explorer 2008. The effect is that the service pack isn’t applied on the Team Explorer. After a rerun of the SP1 installation everything worked fine.

    Wednesday, March 17, 2010

    Rewriting and how to survive it

    Sooner or later, we are all confronted with this type of project: rewriting an existing application, a one-on-one migration between 2 technologies, and so on… Most of the time this is far to like experience caused by a lot of reasons.

    Tim Ross did an interesting (and unfortunately very recognizable) blog post about this kind of rewrite projects.

    Never forget this general rule, you should never rewrite your software, ever.

    Tuesday, March 16, 2010

    Find the private key associated with a specific X.509 certificate

    It can be difficult to find the location and name of the private key file associated with a specific X.509 certificate in the certificate store. The FindPrivateKey.exe tool facilitates this process.

    X.509 certificates are installed by an Administrator or any user in the machine. However the certificate may be accessed by a service running under a different account (for example, the ASPNET on Windows XP or the NETWORK SERVICE accounts on Windows Server 2003).

    This account may not have access to the private key file because the certificate was not installed by it originally. The FindPrivateKey tool gives you the location of a given X.509 Certificate's private key file. You can add permissions or remove permissions to this file once you know the location of the particular X.509 certificates' private key file.

    Read more.

    Using the TFS 2010 object model

    In Team Foundation Server 2010 a lot has changed. One of the impacted areas are the available API’s to extend and integrate TFS into your own applications.

    Ewald Hofman did a great job creating a list of posts about using the new API’s available in TFS 2010.

    Configure WCF Security to use the ASP.NET Membership provider

    Today I found this great link explaining step by step how you can integrate the ASP.NET Membership provider with your WCF service security.

    Enterprise Library 5.0: Beta 2

    One month after the Beta 1 release, the Beta 2 release is there. It mostly contains a list of bug fixes.

    For the full Change log, go here.

    Friday, March 12, 2010

    Securing an ASP.NET MVC application

    If you want to integrate ASP.NET MVC with Microsoft Authorization Manager, check out this post:

    http://franklaub.blogspot.com/2008/06/securing-aspnet-mvc-application.html

    Specify the testrunconfig in your TFS 2008 build file

    After creating a TFS 2008 build file, I noticed that the build didn’t take into account the specified test run configuration data from the testrunconfig file.  You can easily add this reference in your build. Open the “TFSBuild.proj” file in your XML editor and locate the “PropertyGroup” node. Inside this node, add the following node “<RunConfigFile> </RunConfigFile>”. Inside this node you need to point to the location in your source control where the “.testrunconfig” file can be found. Use the $(SolutionRoot) tag and then add your folder like this:

    $(SolutionRoot)\YourFolder\YourTestConfigFileName.testrunconfig

    Test Scribe: A tool for Test Plan Document Generation

    Microsoft released it’s first Team Test PowerTool for Visual Studio 2010: Test Scribe.  This tool allows users of Visual Studio 2010 Ultimate to generate a Word 2007 Test Plan Document from their plan, suites, test cases, and other artifacts. 

    The resulting document contains a list suites with test cases and steps detail and pie charts detailing the overall progress of your Test Plan. 

    Download the tool at http://visualstudiogallery.msdn.microsoft.com/en-us/d18873c7-909d-4788-a56e-0c496a1d8bb9.

    Note:It’s still a little rough around the edges, on some systems I failed to get it up & running. So look out if there is a newer version available.

    DataSets to the Rescue

    As I spend most of my time in ORM land, sometimes datasets and datatables are still very useful. Thanks to the integration with LINQ you can easily leave the untyped dataset world and enter the typed IEnumerable<T> world thanks to the easy projection syntax in LINQ.

    Some old but still valuable posts about this (almost) forgotten technology:

    ASP.NET MVC 2 released!

    Great news just before the weekend. Phil Haack announces the RTM release of ASP.NET MVC 2.  Scott Guthrie also gives his own insides about this release with his post ‘ASP.NET MVC 2 Released‘ talking about some of the key features of the V2 release, and Scott Hanselman highlights a number of resources to help you learn more in his ASP.NET MVC 2 Released post.

    Busy guys, those Microsoft folks!

    Friday, March 5, 2010

    MSDeploy

    In Visual Studio 2010 a new deployment option is available to easily deploy your web applications: MSDeploy.

    On your webserver itself you can deploy the created package using the Web Deployment tool. But I found out it is also possible to do this immediately in IIS 7.

    1. Open the IIS Manager by clicking Start > Run and typing inetmgr.
    2. In IIS Manager, expand the Server node and the Sites node, then select the Default Web Site.
    3. In the right-hand Actions pane, click the Import Application... link to launch the packaging wizard.
    4. Select the package that you created in the previous quick guide, MyApplication.zip, or any other package.
    5. In the Install an Application Package dialog, you will see the application and the database.
    6. On the Parameters page, enter a new application name if desired and enter a SQL connection string.
    7. Click Next to install the package.
    8. The Summary page will provide a high-level overview of some items that were installed from the package. The Details tab will give a lot of detail of exactly what was added.

    Saving changes not permitted

    Last week I had following error when I tried to save some changes in the SQL Server Management Studio 2008.

    “Saving changes is not permitted. The changes that 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.”

    This error happens because by default the  Prevent Saving Changes That Require Table Re-creation option is enabled by default in SQL Server 2008 Management Studio.

    To disable this option:

    • Open SQL Server 2008 Management Studio
    • Click Tools and then Options
    • Expand the Designers node and select Table and Database Designers option
    • Uncheck “Prevent saving changes that require the table re-creation”
    • Click OK to save changes

    NHibernate 3.0 becomes lazier

    Today I was browsing through the NHibernate trunk. I discovered a nice new feature. Before lazy loading was only supported on associations, from now on it also becomes available on properties!

    Imagine, you have a customer object where one of it’s properties is an image. By specifying this as a lazy property it will only be loaded when you explicitly call it.

       1:  <property name="Image" lazy="true"/>

    Ok, this looks nice, but of course sometimes you want to do eager loading. What do you need to do then? Just add some extra info to your HQL and you are done.

       1:  var customers = session.CreateQuery("from Customer fetch all properties");