[Dev Tip] Cannot activate wcf service

The type ‘Chimera.Tools.Services.AgencyServices.DocumentService.DocumentService’, provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.

=> first thing: verify xxx.svc to make sure service and CodeBehind value are correct: namespace, file name

<%@ ServiceHost Language=”C#” Debug=”true” Service=”Chimera.Tools.Services.AgencyServices.DocumentServices.DocumentService” CodeBehind=”DocumentService.svc.cs” %>

[Dev Tip] DataContract in WCF

[KnownType(typeof(UserAttribute))]
[KnownType(typeof(RepeatingUserAttribute))]
[XmlInclude(typeof(UserAttribute))]
[XmlInclude(typeof(RepeatingUserAttribute))]
public class UserAttributes : KeyedCollection<string, AbstractUserAttribute>

[DataContact]
AbstractUserAttribute

Ref service
=> Array of AbstractUserAttribute

[KnownType(typeof(UserAttribute))]
[KnownType(typeof(RepeatingUserAttribute))]
[XmlInclude(typeof(UserAttribute))]
[XmlInclude(typeof(RepeatingUserAttribute))]
[CollectionDataContract]
public class UserAttributes : KeyedCollection<string, AbstractUserAttribute>
=> UserAttributes

[Dev Tip] Deserialize a List with newtonsoft.json

void Main()
{
    var test = new List<Business>();
    test.Add(new Hotel { Name = "Hilton", Stars = 5 });
    test.Add(new Pool { Name = "Big Splash", Capacity = 500 });

    test.Dump();

    string json = JsonConvert.SerializeObject(test, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings
    {
        TypeNameHandling = TypeNameHandling.All
    });

    json.Dump();

    var businesses = JsonConvert.DeserializeObject<List<Business>>(json, new JsonSerializerSettings
    {
        TypeNameHandling = TypeNameHandling.All
    });

    businesses.Dump();
}

// Define other methods and classes here
public abstract class Business
{
    public string Name { get;set; }
}
public class Hotel : Business
{
    public int Stars { get;set; }
}
public class Pool : Business
{
    public int Capacity { get;set;}
}

It worked perfectly. Abstract collection serialized to:

{
  "$type": "System.Collections.Generic.List`1[[UserQuery+Business, query_jvrdcu]], mscorlib",
  "$values": [
    {
      "$type": "UserQuery+Hotel, query_jvrdcu",
      "Stars": 5,
      "Name": "Hilton"
    },
    {
      "$type": "UserQuery+Pool, query_jvrdcu",
      "Capacity": 500,
      "Name": "Big Splash"
    }
  ]
}

The original and the deserialized collections matched.