The Blog

Adding background to a DrawingView in Android

Yesterday, I was attempting to add a background to my DrawingView - something which IMHO should be ridiculously simple. Yet, after trying to various combinations of Bitmap, Drawable even ImageView types, nothing worked. Although you can do it directly in the XML, I had my DrawingView defined in Java file rather than XML. In the

Continue Reading

Setting default value for property in EF Code First

There few ways in which one can do it. The simplest way is via data annotations:

Continue Reading

The Output window in VS 2013

I accidentally closed the output 'window' in my VS 2013. I cannot believe it took me that long to find this, but hopefully it will save you some time:

Continue Reading

Bootstrap Tabs with Google Charts - how to make it work?

Today, I've encountered an interesting problem. It seems that when an object is hidden, it breaks the properties of width and height for Google Charts. Using Bootstrap 3.3, I had a set of tabs. Each tab contained a graph of some sort. In the initial tab, the chart was being displayed correctly. However, the charts

Continue Reading

"using", the safe keyword

Frequently, we don't really care what the exception is, but if it is thrown we want to finalise operations e.g. close the database connection or files. This is where using comes in. using keyword allows to make code a little bit more readable by omitting try-catch-finally clause. Instead, your object should implement IDisposable interface and

Continue Reading

Neat way of getting rid of nullable type in Linq

Nullable types can sometimes be a handful to work with. This 'billion dollar mistake' (as described by Tony Hoare who claims to have invented null) can, however, be convereted to r There is a need way of converting nullable type: ??. The example below selects some value from an object using Select method. YourVariable is

Continue Reading

foreach image in a resource file

Resource files are a very useful addition to the .NET framework as they allow easy storage and retrival of data e.g.

In order to iterate through the all the resources in the resource file, we have to use ResourceSet. To get it we need run a resource manager on our resource file. The complete

Continue Reading

How to display an image on the website from a binary source (e.g. a database)

There are various ways in which one could display an image on the website form a binary source. One solution would invole simply converting the binary source into a base64 and put it as the src of the image:

However, this is not acceptable if you load images 'on demand' i.e. when the user

Continue Reading

"The target application has been unloaded" - the annoying error

"The target application has been unloaded" is highlighted by Visual Studio, but doesn't actually do anything. Interestingly enough the error wasn't doing anything. It was just highlighted by Visual Studio and prevented the syntax highlighter as well as the code builder from working. After finding nothing on the internet I gave up and went home.

Continue Reading

Tracing of WCF services - code example

Tracing can be very beneficial especially when the application has already been deployed and we need to figure out why things do work. Useless errors of type HTTP 500 don't give any meaningful results, so I decided to use System.Diagnostics to help me track down the errors. Logging There are two important (and very simplifed

Continue Reading