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;
  3.  
  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.     }
  15.  
  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()
{
lock(this)
{
if (--Count > 0)
{
System.Threading.Monitor.Wait(this);
}
else
{
System.Threading.Monitor.PulseAll(this);
}
}
}
}


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)



Blogging

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


Productivity

  • 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).



Security

  • 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.




System

  • 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: http://www.gass-ltd.co.il/en/products/cuda.net/Releases.aspx

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, WEB:
ASP.NET control graph visualizer - http://odetocode.com/Blogs/scott/archive/2006/01/12/2726.aspx
ASP.NET Cache Visualizer - http://blog.bretts.net/PermaLink,guid,07cd8437-862e-45c6-b24e-3a286fce1b66.aspx
ASP.NET Control Visualizer - http://blog.bretts.net/PermaLink,guid,87d735a0-1592-4711-860f-8a1d29c9630f.aspx
ASP.NET Visualizers - http://weblogs.asp.net/scottgu/archive/2006/01/12/435236.aspx
WebVisualizers - http://webvisualizers.codeplex.com/


Graphics & UI:
Bitmap Debugger Visualizer - http://blogs.geekdojo.net/brian/archive/2006/08/06/bitmapvisualizer.aspx
Graphics Debugger Visualizer - http://www.codeproject.com/KB/macros/GraphicDebuggerVisualizer.aspx
ControlTree visualizer - http://odetocode.com/Blogs/scott/archive/2006/01/12/2726.aspx


DataSource & Data:
Data Debugger Visualizer - http://www.codeproject.com/KB/grid/datadebuggervisualizer.aspx
Debugger Visualizer for Visual Studio - http://coding-time.blogspot.com/2009/03/debugger-visualizer-for-visual-studio.html
Mole Visualizer For All Project Types - http://www.codeproject.com/KB/macros/MoleForVisualStudio.aspx
http://www.moleproject.com/
http://joshsmithonwpf.wordpress.com/mole/
Righthand Dataset Debugger Visualizer - http://cs.rthand.com/blogs/blog_with_righthand/pages/Righthand-Dataset-Debugger-Visualizer.aspx
XML Visualizer - http://blogs.conchango.com/howardvanrooijen/archive/2005/11/24/2424.aspx
IEnumerable Visualizer -
http://rapiddevbookcode.codeplex.com/wikipage?title=EnumerableDebugVisualizer

LINQ, DB:
DB Connection Visualizer - http://dbvisualizer.codeplex.com/
LINQ Expressions DebuggerVisualizer - http://www.manuelabadia.com/blog/PermaLink,guid,9160035f-490f-46bd-ab55-516b5c7545af.aspx
LINQ Expression Tree Visualizer- Look in VS 2008 Samples
LINQ to SQL Debug Visualizer - http://weblogs.asp.net/scottgu/archive/2007/07/31/linq-to-sql-debug-visualizer.aspx
LINQ Query Visualizer - http://msdn.microsoft.com/en-us/library/bb629285.aspx
LINQ to SQL Visualizer - http://weblogs.asp.net/scottgu/archive/2007/07/31/linq-to-sql-debug-visualizer.aspx
LINQ to Entity Visualizer - http://visualstudiogallery.msdn.microsoft.com/en-us/99468ece-689b-481c-868c-19e00e0a4e69


System & miscellanea:
CAB Visualization - http://www.codeplex.com/WorkItemVisualizer
GUID Debugger Visualizer - http://devmatter.blogspot.com/2006/04/guid-debugger-visualizer-for-visual.html
IL Visualizer - http://blogs.msdn.com/haibo_luo/archive/2006/11/16/take-two-il-visualizer.aspx
Improving Visual C++ Debugging - http://www.codeguru.com/columns/kate/article.php/c15291
PowerShell Debug Visualizer - http://poshdebugvisualizer.codeplex.com/
Regular Expression Visualizers - http://weblogs.asp.net/rosherove/archive/2005/11/26/AnnoucingRegexKit10.aspx
Sharepoint debug visualizer - http://spdv.codeplex.com/
WindowsIdentity Debugger Visualizer - http://geekswithblogs.net/khanna/archive/2006/01/05/64903.aspx


WCF:
WCF Visualizers Tool - http://wcfvisualizer.codeplex.com/


WPF:
WPF Tree Debugger Visualizer - http://wpftreevisualizer.codeplex.com/
DepO WPF Dependency Object Visualizer - http://www.codeplex.com/dathanliblikdepo
WPF Debugger Visualizer - http://blogs.oosterkamp.nl/blogs/thomas/archive/2009/03/11/wpf-debugger-visualizer.aspx
XAML Debugger Visualizer for WPF - http://www.codeproject.com/KB/WPF/XamlVisualizer.aspx
Snoop - a WPF Utility - http://blois.us/Snoop/


XML:
Xml Visualizer v.2 - http://www.codeplex.com/XmlVisualizer
Lithium XML Debugger Visualizer - http://blogs.conchango.com/howardvanrooijen/archive/2005/04/11/1267.aspx