Simple WCF Service Host

app.config The configuration for a simple http WCF host is: <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> </appSettings> <system.serviceModel> <services> <service name="AssemblyNamespace.ServiceImplementation" behaviorConfiguration="ServiceBehavior"> <endpoint address="ServiceName" binding="basicHttpBinding" contract="AssemblyNamespace.ServiceContractInterface" /> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> <host> <baseAddresses> <add baseAddress="http://HostName:Port/"/> </baseAddresses> </host> </service> </services> <behaviors> <serviceBehaviors> <behavior name="ServiceBehavior"> <serviceMetadata httpGetEnabled="true"/> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> </configuration> An example: <?xml version="1.0" […]

Simple Thread Safe Singleton

This is simple but should work: public sealed class Singleton{   private static Singleton _instance = new Singleton();    private Singleton() { }    public static Singleton Instance   {      get      {         return _instance;      }   }} As the CLR synchronises static constructors it is thread safe. Also static constructors are not called until the types is accessed to you have lazy instantiation (use nesting if there are […]