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

Creating MSDN like documentation of your C# project

10. February 2009 06:28 by arnoldbo in Tools  //  Tags: , ,   //   Comments
[caption id="attachment_31" align="alignleft" width="100" caption="Sandcastle Logo"]Sandcastle Logo[/caption] Today I needed to document my C# project for a customer, for creating the documentation automatacly I used the Sandcastle tool. I used a Blog post from Jan Schreuder where he describes how to build your own documentation. The description didn't work for my directly I needed to install Microsoft HTML Help