Initializing ThreadStatic fields

Saturday, May 17th, 2008

Yesterday a friend of mine came across a problem concerning the initialization of ThreadStatic fields. He always encountered a NullReferenceException while accessing those fields.
Here's a sketch of what he tried to do:
PLAIN TEXT
C#:

class Program

{

    [ThreadStatic]

    static StringBuilder aValue = new StringBuilder();

 

    static void Main(string[] args)

    {

        Program p [...]

Double-Checked Locking in C#

Thursday, January 10th, 2008

Heute hatte ich eher zufällig das Buch Head First Design Patterns in der Hand. Auch eher zufällig bin ich dabei im Kapitel über das Singleton-Pattern beim Double-Checked Locking hängen geblieben. Dort wird darauf aufmerksam gemacht, dass dieses Pattern unter Java 1.4 und früheren Versionen nicht funktioniert.
Da ich dieses Pattern bereits einige male in C# verwendet [...]

Using xs:choice in WCF-Services

Tuesday, August 7th, 2007

At the very beginning of the ongoing work of my "Projektgruppe" we had to convert an existing XSD into a DataContract compliant schema. The XSD was part of the WSDL of one of our services which we developed using a contract-first approach. One complex type contained a xs:choice element which is not supported by DataContracts [...]

FatalExecutionEngineError on calling HttpQueryServiceConfiguration

Sunday, May 27th, 2007

The last few days I struggled a lot with WCF endpoints while configuring them running with least privileges. As already mentioned in my post WCF: Namespace Reservierung there are several tools simplifying this procedure. Nevertheless I wanted to write my own little tool with a GUI. The tool works fine so far (go and grep [...]

Warum muss eine abstrakte Klasse in C# alle Methoden einer Schnittstelle implementieren?

Wednesday, May 16th, 2007

Ein Kommilitone von mir, der sonst hauptsächlich im Java-Umfeld programmiert, stellte mir heute die Frage, warum er folgendes in C# nicht machen kann:
PLAIN TEXT
C#:

interface IInterface

    {

        void Method();

    }

 

    abstract class Base : IInterface

    {

    }

Folgendes funktioniert nämlich in Java problemlos: