public static void SetSerializationSurrogateProvider(this DataContractSerializer serializer, ISerializationSurrogateProvider provider) { // allocate every time, expectation is that this won't happen enough to warrant maintaining a CondtionalWeakTable. IDataContractSurrogate adapter = new SurrogateProviderAdapter(provider); serializer.SetDataContractSurrogate(adapter); }