HOWTO remove diacritics in a string

20. October 2009 13:31 by arnoldbo in General  //  Tags:   //   Comments

When comparing strings you sometimes need to ignore diacritics (accents) like é, ö etc.
The following method removes the diacritics:

With the following extension method you can compare two strings for equality: 

static string RemoveDiacritics(string stIn)
    string stFormD = stIn.Normalize(NormalizationForm.FormD);
    StringBuilder sb = new StringBuilder();
    for (int ich = 0; ich < stFormD.Length; ich++)
        UnicodeCategory uc = CharUnicodeInfo.GetUnicodeCategory(stFormD[ich]);
        if (uc != UnicodeCategory.NonSpacingMark)

    return (sb.ToString().Normalize(NormalizationForm.FormC));

public static bool Equals2(this string source, string toCheck)
    return RemoveDiacritics(source).ToLower().Trim() == 
The following code gives as result 'True'. 
string x = "Azië";
bool equal = x.Equals2("azie");


Padding is invalid and cannot be removed

10. October 2009 13:14 by arnoldbo in General  //  Tags: , ,   //   Comments

After deploying my site to a webhosting company I suddenly was faced with error's when requesting WebResource.axd.

The following error occured:
Padding is invalid and cannot be removed.

Stacktrace:    at System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast)
   at System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount)
   at System.Security.Cryptography.CryptoStream.FlushFinalBlock()
   at System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, IVType ivType, Boolean useValidationSymAlgo)
   at System.Web.UI.Page.DecryptStringWithIV(String s, IVType ivType)
   at System.Web.UI.Page.DecryptString(String s)
   at System.Web.Handlers.ScriptResourceHandler.DecryptParameter(NameValueCollection queryString)

The solution for this problem for me was to set a fixed machine key in the web.config file.
For this you can use a machineKey generator or generate your own if you know how to do it (random chars will not work).

    <machineKey    validationKey='A06BDCF2F6CF.A.VERY.LONG.44F13E76184945A7C477601'

For more detailed information you can read the blog post from José Antonio

Microsoft Techday's

6. March 2009 10:07 by arnoldbo in General  //  Tags: ,   //   Comments
Next week André and I attend the Microsoft TechDays in Antwerp. We are especially interested in the pre-conference day. This is a hole day of SharePoint sessions! LINQ and SharePoint WCF webservices and SharePoint Workflow and SharePoint

At the conference I will blog about the sessions. 480x325ani