Monday, 12 December 2011

MSBuild and XmlTransform

Using .NET 4.0 you can use the Config Transformation features by which we can maintain multiple configuration files for different environments. To have one of these files built as part of your continuous integration you can use the MSBuild task TransformXml:

An example of the code usage is below:

<UsingTask TaskName="TransformXml" 

<Target Name="GenerateConfigs">
  <TransformXml Source="Source\Web.config"

MSBuild - Non-string data for Inetstp@MajorVersion

When using the the Microsoft.Web.Publishing.Tasks.dll library to do the XML Transforms in a Continuous Integration set-up, like TeamCity. You receive an error like below:

[GetProjectWebProperties] error MSB4138: Non-string data was specified at the registry location "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Inetstp@MajorVersion".

If this is the case, ensure that your build scripts are using .NET 4.0. The scripts I had were defaulting to use .NET 3.5 which threw the error.

Thursday, 24 November 2011

YAF Polls - You already voted.

A user can't vote as it says "You already voted." when you know you haven't voted with this user account. Have you voted though with a different user account from the same machine or the same network?
By default, YAF only lets a user vote if no one using the same IP Address has already voted.
You can turn this feature off in Host Settings -> Features -> Poll Options -> Poll Votes Dependant on IP

Monday, 7 November 2011

Could not load type 'System.ServiceModel.Activation.HttpModule'

Have you started working on a .NET 4.0 project and received the following error?
Could not load type ‘System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.TypeLoadException: Could not load type ‘System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

If you have, you probably have installed .Net framework 4.0 on IIS and then enable either a .Net 3.0 or 3.5 WCF feature.  To fix you need to reconfigure ASP.NET by using the following command depending on the version of ASP.NET you have installed.

IIS 32 bit

%SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis /iru

IIS 64 bit

%SYSTEMROOT%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis /iru

Tuesday, 1 November 2011

SQL Server Management Studio Intellisence not refreshing on schema change

When I have been adding tables, columns etc, I've noticed that the intellisense is not updated with in the query window. The intellisense is updated however if I shutdown the management studio and re-open it. This is quite an agressive and time consuming measure.

The problem it that objects are cached in the solution so to you have to refresh the local cache.

Edit  -> Intellisense -> Refresh Local Cache (CTRL+Shift+R)

Monday, 10 October 2011

txt2re: Regular Expression Generator

txt2re is a great tool that can help you a lot when creating regular expressions. Just type in an example string you want to match, then use the selectors to create a snippet of code with the regex and validation process pre-populated, allowing you to drop the code straight into your application. This supports many languages including some of the following

  • perl
  • php
  • python
  • java
  • javascript
  • ruby
  • c#

I must give some credit to my colleague for his blog post and also the full credit to Zoe Nolan.

Wednesday, 21 September 2011

IIS PowerShell Module on Windows 7

I've just got round to installing the PowerShell Module for IIS 7. This was not a straightforward task.

I got some of the following errors:

Import-Module : File C:\Windows\system32\WindowsPowerShell\v1.0\Modules\WebAdministration\WebAdministrationAliases.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details.

Import-Module : The following error occurred while loading the extended type data file: Microsoft.PowerShell, C:\Windows\system32\WindowsPowerShell\v1.0\Modules\WebAdministration\iisprovider.types.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".

The following blog post was very helpful in getting this installed and working:
IIS Workstation: Troubleshooting: IIS Powershell Module on Windows 7 RC

Speeding up Visual Studio

Do you find that Visual Studio is not fast enough for you? There are several guides and options you can tweak to improve performance.

Improve your hardware
  • 4Gb of RAM
  • Dual or Quad core processor
  • Solid State Drive(SSD) hard drive and install Visual studio and project files to this disk.

If this is not possible, try to tweak you visual experience.  One of the more comprehensive guides I found on this is here:
Ultimate Guide to speed up Visual Studio

Thursday, 8 September 2011

Rogue VSMacro80 folder

I've just rebuilt my machine after a hard disk crash, so lost most of my Visual Studio settings. Since the rebuild I've noticed that a VSMacro80 folder is appearing in my projects folder.  Every time I deleted it, it always seemed to return.

The solution is to update your projects location path:
Visual Studio -> Tools -> Options -> Projects and Solutions

Ensure that the path ends in a trailing slash. e.g. c:\Projects\

Tuesday, 26 July 2011

HTML Agility Pack breaks XHTML

We have some HTML that contains the tag <br /> but when we parse this through the HTML Agility Pack to process the HTML, it converts it to <br>.

The solution to this the following:

var doc = new HtmlDocument();
HtmlNode.ElementsFlags["br"] = HtmlElementFlag.Empty;
doc.OptionWriteEmptyNodes = true;

//process data
return doc.DocumentNode.OuterHtml;

More can be found on this StackOverflow post

Thursday, 14 July 2011

Compression support not configured

A colleague and I were having to debug an issue with the Lucene search engine. When trying to index data we kept receiving the following error.

Compression support not configured

Further details and the solution is avaliable on my colleagues blog.

Wednesday, 23 March 2011

MCPD ASP.NET Developer 3.5

Yesterday I successfully passed the upgrade MCPD exam 70-567. Not a great pass mark, but still managed the pass. The result pays off for all that studying that had to been done.

Monday, 21 February 2011

Cannot resolve the collation conflict

I've been working recently on databases that contain different collations. Mainly the following two:
  • SQL_Latin1_General_CP1_CI_AS
  • Latin1_General_CI_AS
When trying to write simple queries I kept getting the following error:

Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the equal to operation.

To solve this you just need to cast the field to the correct collatiion using COLLATE Latin1_General_CI_AS


ON Table1.ID = Table2.ID
WHERE Table1.ID = 1

This would become


ON Table1.ID COLLATE Latin1_General_CI_AS = Table2.ID
WHERE Table1.ID = 1

Friday, 4 February 2011

Blank or Empty lists for Windows Features

I've seen this issue a few times where the "Turn Windows features on or off" window is empty, stopping you from installing or uninstalling a feature.

Microsoft's solution is to perform a "System Restore" which is quite a drastic action.

There is a more viable fix for this issue available here:
FIX Blank or Empty List in Vista Turn Windows Features On or Off (OptionalFeatures.exe)