WebLog

Server-side, client-side, code snippets, scripts, automation, best practices, proven approaches, tips & tricks...

Migrate stored procedures across databases

Copy stored procedure from one database to another with T-SQL
0
When working on an app you create all your stored procedures, functions, tables, view and other objects in a development database (or t least it should be like that). A small but annoying problem occurs when you have to migrate your stored procedures to test or production database. Imagine during development you had let's say 20 stored procedures...read more

Managed Extensibility Framework (MEF) quick start

Introducing MEF with simple code example application
 
0
Managed Extensibility Framework or MEF is a library introduced in .NET Framework 4 which allows developers to easily create plugin based applications. It lives in System.ComponentModel.Composition namespace and before start working with MEF reference to this assembly needs to be added in a project.It is basically an implementation of IoC (Inversion of Control) pattern with few core functionalities such as assembly loading...read more

ConcurrentDictionary vs Hashtable.Synchronized

Comparison of collections in multithread environment
 
0
Basically all Dictionary collections in .NET internally implement Hashtable wrapped, so in terms of mechanism they are pretty much the same. The difference is that Dictionary exposes strong types while Hashtable uses object-object keyvalue pair which is much harder to work with because you need to know what is the actual type of the object stored in a key or value. Often casting will probably be required...read more

Convert string to any type that implements TryParse method

String extension method for converting to other value types
0
In many cases serialized data is returned in a form of string although the actual type of data is different. The problem begings when you want to use data in it's original type becaus direct cast is not allowed in C# as it is in VB.net. This is why you have to use TryParse and safely parse the value to it's original type...read more

Creating Visual Studio ProjectTemplate VSIX package

How to create VSIX package for ProjectTemplate
 
0
If you often have projects which setup is pretty much the same you might consider creating ProjectTemplate for Visual Studio.It speeds up development for the project setup, adding references, default configuration .config, content files... Before you start make sure that you have installed Microsoft Visual Studio 2013 SDK (http://www.microsoft.com/en-us/download/details.aspx?id=40758) and Nuget Package Explorer (http://npe.codeplex.com/)I also attached a small dummy project just to help understanding what is written in this article.Skipping to hands on code is always more helpful and faster for me to, so if you are bored by reading, download the attached .7zfile and explore it...read more

Avoiding high processor load in long running loops

Keep processor not overloaded with long running loops
0
When having a long running loop which you are not sure when it is going to end you will probably have to create a loop in a separate loop and on every iterration you will check whether some condition is true and exit the loop. Let's say you want to execute some piece of code after some specific time, let's say after one minute or everyday at specific time (common scenario in windows services). You can do it really simple with Timer class and just few lines of code as the code below. ...read more

Deserializing JSON to anonymus type in C#

Binding JSON string to anonyms type
0
JSON is really easy to use and it really boosts performances since it is a lot lighter than XML and SOAP. Sometime it can be really annoying having to create POCO class every time you need to deserialize JSON value passed from client side in ASP.NET web applications. During extending project functionality this number of POCO classes can significantly grow to that matter that you have a bunch of classes for even the simplest task you have to do with JSON value. ...read more

Application plugin host with assembly caching and auto reloading

Caching and loading plugins dynamically when plugin library updates
 
0
Few moths ago I wrote and article about simple way to implement plugin architecture in C# simple plugin host application approach. This approach is great for desktop applications because when you for example need to update (which means replace the plugin dll) you can easily close the app and start it again and it will pickup new code...read more

One way, fire and forget action in WCF

Long running process invoke from ASP.NET web application
0
In case you are building a web app that needs to perform some complex or long running task, for sure you would't want that task to slow down your website or web application. For example you have a database of growing number of members on your website and you want to send a notification after you published some page on the website. Imagine you have 10,000+ members and that you are composing different message for each of them based on their account information and then sending an email with notification message. ...read more

JavaScript

read more

Umbraco CMS

read more

.NET

read more

SQL/T-SQL

read more