Thursday, June 14, 2007


Grasshopper: code in Visual Studio, build Java and deploy on Linux

This sounds too good to be true: Code in .NET 2.0, Build for Java, Run on Linux with Grashopper 2.0

After more than 100 person years and $12 million of direct R&D investment, and the cross-compilation of 4.7 million lines of code from .NET to Java™, we’re celebrating the release of Grasshopper 2.0. This freely-available plug-in to the Visual Studio® 2005 IDE enables you to produce .NET Web and server applications that run on Tomcat under Linux® and other Java-enabled platforms, without having to rewrite your C# or Visual Basic code. Version 2.0 introduces support for Microsoft's® Visual Studio 2005 IDE, the .NET Framework 2.0, ASP.NET 2.0 controls, role-based security, and C# generics.

Here you'll find articles, code samples, and forums that you can use to jump into Grasshopper 2.0. For deployments on enterprise-class Java EE servers and portal servers, as well as multiple-CPU deployments, check out Mainsoft's Enterprise and Portal editions.

To be honest, I need tools that work the other way around at the moment, letting me run Java code in a managed environment. The Microsoft Java Language Conversion Assistant 3.0 tries to convert Java to .NET but it is way behind as it only supports JDK 1.3.

For now I am forced to integrate Java in .NET using JNI or SOAP. Let me know if you find any other valid alternatives.

Wednesday, June 13, 2007


"Value cannot be null. Parameter name: value" error in .TEXT

I know, I know. .TEXT is old ancient but it is working. I have made a couple of changes to the code and it has served me faithfully for almost 3 years, which is why I got very surprised when I suddenly started getting this error on a daily basis: "Value cannot be null. Parameter name: value"

K. Scott Allen found the solution a long time ago; It is a bug in .TEXT which you can work around by setting queueStats=”false” in the Tracking section of web.config.

I just updated my blogs. Please give me a shout if you see this error again.


How to remove accents from strings in .NET

A friend asked how to remove accents from strings in .NET 2.0. I found the code below on Michael Kaplan's blog.

The code uses String.Normalize() to get a normalized Unicode representation of the string where the base character and the accents are stored separately. It then loops on each character and ignores the accent mark characters so "àáåæéèøÜü" becomes "aaaæeeøUu".

public static String RemoveDiacritics(String s)       


    String normalizedString = s.Normalize(NormalizationForm.FormD);

    StringBuilder stringBuilder = new StringBuilder();


    for (int i = 0; i < normalizedString.Length; i++)


        Char c = normalizedString[i];

        if (CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark)



    return stringBuilder.ToString();