How to set Json.Net as the default serializer for WCF REST service

The usage of Extending Encoders and Serializers (see http://msdn.microsoft.com/en-us/library/ms733092.aspx) or other methods of Extending WCF like usage of DataContractSerializerOperationBehavior is very interesting, but for your special problem there are easier solution ways. If you already use Message type to return the results an use WCF4 you can do something like following: public Message UpdateCity(string code, … Read more

No generic implementation of OrderedDictionary?

Implementing a generic OrderedDictionary isn’t terribly difficult, but it’s unnecessarily time consuming and frankly this class is a huge oversight on Microsoft’s part. There are multiple ways of implementing this, but I chose to use a KeyedCollection for my internal storage. I also chose to implement various methods for sorting the way that List<T> does … Read more

.NET console application as Windows service

I usually use the following techinque to run the same app as a console application or as a service: using System.ServiceProcess public static class Program { #region Nested classes to support running as service public const string ServiceName = “MyService”; public class Service : ServiceBase { public Service() { ServiceName = Program.ServiceName; } protected override … Read more

Fixing slow initial load for IIS

Options A, B and D seem to be in the same category since they only influence the initial start time, they do warmup of the website like compilation and loading of libraries in memory. Using C, setting the idle timeout, should be enough so that subsequent requests to the server are served fast (restarting the … Read more

.NET 4.0 has a new GAC, why?

Yes since there are 2 distinct Global Assembly Cache (GAC), you will have to manage each of them individually. In .NET Framework 4.0, the GAC went through a few changes. The GAC was split into two, one for each CLR. The CLR version used for both .NET Framework 2.0 and .NET Framework 3.5 is CLR … Read more

Microsoft.WebApplication.targets was not found, on the build server. What’s your solution?

To answer the title of the question (but not the question about the output you’re getting): Copying the following folder from your dev machine to your build server fixes this if it’s just web applications C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications Remove x86 according to how your build breaks. If you have other project types you will probably … Read more

Conditional compilation and framework targets

One of the best ways to accomplish this is to create different build configurations in your project: <PropertyGroup Condition=” ‘$(Framework)’ == ‘NET20’ “> <DefineConstants>NET20</DefineConstants> <OutputPath>bin\$(Configuration)\$(Framework)</OutputPath> </PropertyGroup> <PropertyGroup Condition=” ‘$(Framework)’ == ‘NET35’ “> <DefineConstants>NET35</DefineConstants> <OutputPath>bin\$(Configuration)\$(Framework)</OutputPath> </PropertyGroup> And in one of your default configurations: <Framework Condition=” ‘$(Framework)’ == ” “>NET35</Framework> Which would set the default if it … Read more