Thursday, June 25, 2009

Use Beyond Compare with Team Foundation Server in VS 2008/VS2005

VS2008 → Tools → Source Control → Visual Studio Foundation Service → Configure User Tools:
  • Compare → C:\Program Files\Beyond Compare 3\BComp.exe → %1 %2

  • Merge → C:\Program Files\Beyond Compare 3\BComp.exe → %1 %2 /savetarget=%4 /title1=%6 /title2=%7

Sunday, June 21, 2009

Addin favicon to your blog

Here is how to add Favicon to your blog:

ThreadPool.QueueUserWorkItem() could be very slow

ThreadPool.QueueUserWorkItem() could be very slow if callback being executed as a work item calls Thread.Sleep(). Consider the following example:

  1. using System;
  2. using System.Threading;
  4. namespace Test
  5. {
  6.   class Program
  7.   {
  8.     const int waitTime = 10000;
  9.     static void Main(string[] args)
  10.     {
  11.       for (int i = 0; i < 10; i++ )
  12.         ThreadPool.QueueUserWorkItem( TestProc, i);
  13.       Console.ReadKey();
  14.     }
  16.     static void TestProc(object stateInfo)
  17.     {
  18.       Console.WriteLine("Item number #{0} at {1}", (int)stateInfo, DateTime.Now);
  19.       Thread.Sleep(waitTime);
  20.     }
  21.   }
  22. }

The problem is that thread pool waits around 500 ms before allocating a new thread.
You may solve it by pre-specifying a minimal amount of threads in your application:
ThreadPool.SetMinThreads(20, 200);

Sand Requiem - devoted to soviet soldiers and people fallen in war that started 69 years ago...

Wednesday, June 17, 2009

Howto: publish metadata for net.tcp endpoint and add reference to WCF service hosted in process/service/console

  1. app.config => Edit WCF configuration

  2. Open "Services" section, then "Endpoints" section.

  3. Select an endpoint for which you want to add metadata/MEX endpoint hosted with TCP binding

  4. Endpoints => New service endpoint
    • Set Address to something like net.tcp://localhost:5060/MyEndpointMex

    • Set Name to be something like MyEndpointMex

    • Set Binding to mexTcpBinding

    • Set Contract to IMetadataExchange

    • Set ListenUriMode to Explicit

  5. Advanced => Service Behaviours => Add "New Service Behaviour Configuration"
    Add serviceMedatadata section and set both HttpGetEnabled and HttpsGetEnabled to False

  6. Now start your service process, open VS 2008, select References and then Add Service Reference.
    Put net.tcp://localhost:5060/MyEndpointMex in Address field.

  7. Enjoy

Metadata contains a reference that cannot be resolved net.tcp

Error "Metadata contains a reference that cannot be resolved: 'service reference'.
If the service is defined in the current solution, try building the solution and adding the service reference again." could be caused by specifying specific contract rather than IMetadataExchange in Contract section of service endpoint configuration.

Barrier multithreading primitive in C#

public class Barrier
public Barrier(int count)
Count = count;

public int Count{get; set;}

public void Wait()
if (--Count > 0)

Tuesday, June 16, 2009

Productivity tools suite

This post would be periodically updated and contain list of best tools for personal use.
(Updated: 23/12/2009)


w.bloggar - free blog editor; integrates with most of blogging platforms.
Windows Live Writer – same… slim UI.


  • Office:
    Copernic Search Desktop - Index and search your e-mails (in non-commercial version indexes mails only). Interface is outlook-oriented and it's easier to use then Google Desktop.
    Google Calendar Sync - automatically synchronize Outlook and Google Calendar.
  • Health:
    Workrave - assist healthy work organization by reminding to make exercises and mini-breaks
    Aire Freshener - Nature sounds player - good for relaxation (see why).


  • Antivirus:
    Avira Antivir - Free Edition - great for home use
  • Firewalls:
    PC Tools Firewall Plus - easy to use personal firewall - the only one which is free for personal use and works with Windows 2003
    Agnitum Outpost Free Edition - great for home use
  • File system:
    Eraser - secure data removal tool.
    True Crypt - open-source virtual encrypted disk
  • Security Scanners:
    Secunia PSI - check whether any installed software requires upgrades. Download and install update patches automatically.
    Microsoft Baseline Security Analyzer - check missing security updates and detect some security breaches. May scan range of PC's in a network.
  • Passwords Management:
    KeePass - Manage all your password in encrypted container. Freeware; support search, groups, expiration control, language packs.

Sound, Music, Video, Images

  • MP3:
    MP3 Split - Open-source & freeware application to split MP3 & OGG files by size, duration etc (without decoding). I using it really heavily to split audiobooks into chunks of 15-20 minutes and listen them while driving to work. It has command line and UI version (GTK). If you use it to split audiobook - select "auto-adjust mode" in Preferences to automatically split around silence zones.
  • Video:
    Media Player Classic - looks like old-style Windows Media Player but provides major features and supports many video formats.
    VLC Media Player - open-source media player, support virtually every format...
    XP Codec Pack - codecs for majority of video formats.

  • Image editors & viewers:
    Paint.NET - opensource image editor.
    FastStone Image Viewer - free image browser, converter and editor.


  • Sniffers:
    Ethereal - comprehensive network sniffer - Windows + #nux. Free.
  • Web Sniffers:
    Fiddler - free web (HTTP/HTTPS) sniffer & debugger.
    HttpWatch - web sniffer & debugger with programmatic (C#, Javascript & Ruby) automation interface. Free in basic edition.
    TracePlus & Web Detective - bundle of regular & web sniffer - no free edition.

System Tools

  • Download Managers:
    Free Download Manager - free, GNU license
    Flashget - Free, built-in ads
  • Miscellaneous:
    Process Tamer - monitor and dynamically adjust CPU usage of running processes.
    Shadow Copy - Copy files (including locked files!) or entire drives.
    Unlocker - check which process locks your file and unlock it.
    VirtuaWin - virtual desktop manager.
    Windows Installer CleanUp Utility - Uninstall any component installed on your system. Usefull to resolve installation problems.
    WinUpdatesList - list all windows updates on the system and provide extensive information on each (install date, install user, list of files) + show uninstall command for the update (properties window).

Thursday, June 11, 2009

Rally toward the multiprocessors and cloud computing

The rally to multiprocessor/grid/cloud computing begins. I think technology starting gradually to approach maturity point, when it's possible to crop money from the technological break. It is especially important, since mentioned areas are essential for the next economy boom/bubble cycle, which seems to ride on energy consumption:

Interesting development in this field is NVIDIA's CUDA technology which evolved from their developments done for the high-performance gaming video cards.Basically CUDA is a set of processors embedded in a GPU card, that are clustered in a blocks. Amount ranges from few hundreds in low-budget cards and up to thounsands in GPU-dedicated cards line (Tesla). There is a ready API enabling to utilize this enormous (and enormously cheap) computing power in software applications. (It integrates with VS 2005 / 2008 and from development point of view - the parallel code should be placed in a separate files [.cu], developed in plain C extended with some parallel notions. - You kind of specifying (by using special registers) which MP cluster and which processor inside of cluster is used for the specific code route.) For a now such integration is not really smooth and requires development effort, but by no doubts NVIDIA would extend it for C++ and .NET. There are some 3rd party SDK's already to integrate it with .NET actually:

Notes about future developments in multiprocessign computing

Below are engrossing notes from Intel Developers Conference by my collegue Adam Shaked Gish about future of computing, as Intel sees it.
  • There will be no more performance improvements for the single core - it is as fast it may be, as physics prohibits silicon from getting any faster.
  • Performance will be achieved by properly utilizing multiple cores. Intel is committed to this visions they already see a future in which a desktop has 100 cores inside.
  • As opposed to single core where apps gained performance when installed on new hardware for free, there is no free lunch in multi core. Engineers must be properly trained, and code properly written to utilize the cores in a scalable manner, and to write correct code (multithreading bugs can be very difficult to discover and fix).

In order to utilize the MP power you will need two things:
  1. A high level library you can use to parallelize tasks, without directly using OS primitives like threads and locks. The low level code is just too complicated to understand or maintain.
  2. A set of tools to help you analyze your performance, and find bugs and bottlenecks whithout these there is no way to achieve maximum performance.

As for C++ libraries they discussed:
  • OpenMP as the C style API to parallelize loops. Its advantage is that it is easier to introduce into existing code. Old standard supported by most modern C++ compilers.
  • TBB - a set of templates that allows to think about multi tasking in an object oriented way - you define a task objects and have them run in parallel. It is open source (a set of templates) and has ports to most major OS'es. It is also benchmarked to be faster than OpenMP. However it is more difficult to introduce into existing code and usually requires some amount of redesign.
  • An additional new technology is being researched and it will allow a user to prove the correctness of code written with it. It is still in research stages.

As for tools - Intel just released a new suite of tools named "Intel Parallel Studio". It is aimed at making parallel computing available to the mainstream developer. All tools are addins into Visual Studio:
  • Intel Parallel Composer - a compiler, and a set of libraries and compiler extensions aimed at making development of multithreaded code easier.

  • Intel Parallel Inspector - a bug finder focuses on finding memory bugs (like tools we try to use today) and threading bugs.

  • Intel Parallel Amplifier- a performance analysis tool, focused on finding threading bottlenecks and optimizing the use of multi cores.

  • The suite's retail price is 800$ per license (25% off till end of summer).

Monday, June 01, 2009

Comprehensive list of Debugger Visualizers for Visual Studio

Here is a comprehensive list of Debugger Visualizers for Visual Studio.
It's based on (sorted and merged) info from here, here and here and my own additions.

Here you go:

ASP.NET control graph visualizer -
ASP.NET Cache Visualizer -,guid,07cd8437-862e-45c6-b24e-3a286fce1b66.aspx
ASP.NET Control Visualizer -,guid,87d735a0-1592-4711-860f-8a1d29c9630f.aspx
ASP.NET Visualizers -
WebVisualizers -

Graphics & UI:
Bitmap Debugger Visualizer -
Graphics Debugger Visualizer -
ControlTree visualizer -

DataSource & Data:
Data Debugger Visualizer -
Debugger Visualizer for Visual Studio -
Mole Visualizer For All Project Types -
Righthand Dataset Debugger Visualizer -
XML Visualizer -
IEnumerable Visualizer -

DB Connection Visualizer -
LINQ Expressions DebuggerVisualizer -,guid,9160035f-490f-46bd-ab55-516b5c7545af.aspx
LINQ Expression Tree Visualizer- Look in VS 2008 Samples
LINQ to SQL Debug Visualizer -
LINQ Query Visualizer -
LINQ to SQL Visualizer -
LINQ to Entity Visualizer -

System & miscellanea:
CAB Visualization -
GUID Debugger Visualizer -
IL Visualizer -
Improving Visual C++ Debugging -
PowerShell Debug Visualizer -
Regular Expression Visualizers -
Sharepoint debug visualizer -
WindowsIdentity Debugger Visualizer -

WCF Visualizers Tool -

WPF Tree Debugger Visualizer -
DepO WPF Dependency Object Visualizer -
WPF Debugger Visualizer -
XAML Debugger Visualizer for WPF -
Snoop - a WPF Utility -

Xml Visualizer v.2 -
Lithium XML Debugger Visualizer -