Winforms controls not painting correctly, messed up.

While writing a custom paint routine you may come across a strange phenomenon where some of the controls on the Winforms are not painting correctly or even appearing at times. This is usually due to Control.Invalidate() being called recursively, and the API tries to keep on painting what is important and defers the painting of […]

WCF Tutorial: WCF Service with Windows Service (Part 3 of 3)

Just a stub Creating Service Contract Creating DataContract Creating FaultContract Creating Windows Service Host Creating Proxy Creating Client Creating app.config with WCF config Editor in Microsoft Visual Studio 2010 Installing/Uninstalling/Starting/Stopping Windows Service Host with sc.exe Use client to connect proxy to host, and consuming services. Programatically configure service and proxy using and without using app.config […]

WCF Tutorial: WCF Overview (part 1 of 3)

Just a stub first: WCF is Windows Communications Foundation By default, it sends message using SOAP protocol by serializing data structures into XML. For serialization, it specifies the DataContract and DataMember attributes. For Interface programming, it specifies the ServiceContract and OperationContract attributes. For Error and Exception handling, it specifies the FaultContract attribute. Language agnostic (the […]

One-to-many mappings

A lot of times I had to look for a data structure to store one to many relationships such as a list of products keyed by their categories. I remember the last time I coded in C++ I used a whole lot of std::multimap to do just this. With C#, there isn’t such a container. […]

C# static initialization sequence

Object orientated code could break down dangerously when using static class members in an unorthodox manner. Static initialization sequence goes like this: 1. Program starts, mark all classes that has static members as statically uninitialized. 2. Enters a scope where static calls are made. 3. Check, in order of execution sequence, get the first class […]

IEumerable cannot be used as a single object datasource

In the case of binding a an object and its property to, say, a control using the feature will always work except when myObject is of the IEnumerable type. Once that happens, the data binding architecture will attempt to use the list of objects returned by the Enumerator for updating of UI and data source, […]

ObjectGridView – An easier way to use DataGridView

With a project that I am currently working on, I frequently need to display object information in a DataGridView. However, the values that needs to be displayed does not always directly belong to the bounded objects, instead, it is often a value related to the objects. Furthermore the DataGridView only accepts an IList of objects […]