Thursday, 19 January 2012

WCF Error - This collection already contains an address with scheme http.

This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.

I've found two solutions to this error depending on which version of the .NET framework you are using. You need to update the web.config with the following:

.NET 4.0

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

.NET 2.0 - 3.5

<serviceHostingEnvironment>
  <baseAddressPrefixFilters>
    <add prefix="http://www.yourdomain.com"/>
  </baseAddressPrefixFilters>
</serviceHostingEnvironment>

Unknown server tag 'asp:ScriptManager'

Currently build a new portal using Ajax for asynchronous calls.  Had the following error:
Unknown server tag 'asp:ScriptManager'

This error has caused me a headache over the last few days.  I finally narrowed it down to a missing line in the web.config.

<pages>
  <controls>
    <add tagPrefix="asp" namespace="System.Web.UI" 
            assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </controls>
</pages>

Tuesday, 17 January 2012

SetSite failed for package [Visual Studio Class Designer Package]

When starting Visual Studio you get a pop up which contains the following error:
The package 'Visual Studio Class Designer package' has failed to load properly. GUID {DD1683A7-5A4C-4234-81B3-A4CC91DBEAC9}
Close Visual Studio.

Now start Visual Studio with devenv /log

Navigate to the log location, normally:
C:\Users\username\AppData\Roaming\Microsoft\VisualStudio\10.0\ActivityLog.xml
If this log contains the following entries:

<entry>
 <record>208</record>
 <time>2012/01/17 15:06:00.310</time>
 <type>Information</type>
 <source>VisualStudio</source>
 <description>Begin package load [Visual Studio Class Designer Package]</description>
 <guid>{DD1683A7-5A4C-4234-81B3-A4CC91DBEAC9}</guid>
</entry>
<entry>
 <record>209</record>
 <time>2012/01/17 15:06:00.412</time>
 <type>Error</type>
 <source>VisualStudio</source>
 <description>SetSite failed for package [Visual Studio Class Designer Package]</description>
 <guid>{DD1683A7-5A4C-4234-81B3-A4CC91DBEAC9}</guid>
 <hr>8000ffff - E_UNEXPECTED</hr>
 <errorinfo>Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))</errorinfo>
</entry>
<entry>
 <record>210</record>
 <time>2012/01/17 15:06:00.415</time>
 <type>Error</type>
 <source>VisualStudio</source>
 <description>End package load [Visual Studio Class Designer Package]</description>
 <guid>{DD1683A7-5A4C-4234-81B3-A4CC91DBEAC9}</guid>
 <hr>8000ffff - E_UNEXPECTED</hr>
 <errorinfo>Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))</errorinfo>
</entry>
Now start Visual Studio with devenv /ResetSettings

If this doesn't work, then repair or re-install Visual Studio.

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" 
           AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"/>

<Target Name="GenerateConfigs">
  <TransformXml Source="Source\Web.config"
                Transform="Source\Web.$(Configuration).config"
                Destination="Output\Web.config"/>
</Target>

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=3.0.0.0, 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=3.0.0.0, 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