.Net

.Net Tips – Xml Serialize or Deserialize Dictionary in C#

If you try to serialize/deserialize a type which uses the generic Dictionary<TKey, TValue> type with the XmlSerializer then you’ll get an InvalidOperationException, for instance: Here’s my class: I’ll get an InvalidOperationException with an inner exception of type NotSupportedException when I do this: And the error message of the NotSupportedException is: “Cannot serialize member MyClass.MyDictionary of …

.Net Tips – Xml Serialize or Deserialize Dictionary in C# Read More »

Understanding arithmetic overflow checking in C#

Default context = unchecked By default, arithmetic operations and conversions in C# are executed in an unchecked context. This means that for a signed integer it overflows from int.MaxValue to int.MinValue and underflows from int.MinValue to int.MaxValue, hence both statements below evaluates to true: Similarly, for an unsigned integer it will underflow from 0 to …

Understanding arithmetic overflow checking in C# Read More »

.Net Tips – Using custom ServiceThrottlingAttribute to specify WCF service throttling behaviour

If you have created a WCF service in the past then I assume you’re aware that WCF is very heavily configuration-driven and that you can specify the service behaviour including the throttling parameters (MaxConcurrentCalls, MaxConcurrentInstances, MaxConcurrentSessions) in the config file. But to specify the type of service (PerCall, PerSession or Singleton) you need to apply …

.Net Tips – Using custom ServiceThrottlingAttribute to specify WCF service throttling behaviour Read More »

Extension methods for compressing/decompressing string

Serialization Overhead When it comes to serializing/deserializing objects for transport through the wire, you will most likely incur some overhead in the serialized message though the amount of overhead varies depends on the data interchange format used – XML is overly verbose where as JSON is much more light-weight: XML representation: JSON representation: {“MyProperty”:10} As …

Extension methods for compressing/decompressing string Read More »

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close