<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2751800870260593323</id><updated>2012-02-17T00:09:55.824+02:00</updated><category term='C#'/><category term='Debug'/><category term='Gadgets'/><category term='Other tools'/><category term='Interesting'/><category term='Internet'/><category term='Robotics'/><category term='Trace'/><category term='WPF'/><category term='Programming'/><category term='Programming tools'/><title type='text'>MMS Programmer chronicle</title><subtitle type='html'>.NET Framework
C#
Mobile
SQL Server
Web Services
Design Patterns
Robotics
Programming tools
Gadgets
Humor</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.mvvm.ro/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>28</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-5446698130756660342</id><published>2011-10-12T22:51:00.000+03:00</published><updated>2011-10-12T22:53:18.180+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Interesting'/><category scheme='http://www.blogger.com/atom/ns#' term='Other tools'/><category scheme='http://www.blogger.com/atom/ns#' term='Gadgets'/><category scheme='http://www.blogger.com/atom/ns#' term='Internet'/><title type='text'>Enabling the PPTP for a Windows VPN behind OpenWrt router</title><content type='html'>Beside setting up the router by opening the required ports and creating the VPN server on my Windows machine i had to install the following packages to enable the pptp &lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-D20GlYf_7Zg/TpXvMMdqGWI/AAAAAAAAA3o/JaDbUpQVC5g/s1600/Capture.PNG" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="60" width="200" src="http://2.bp.blogspot.com/-D20GlYf_7Zg/TpXvMMdqGWI/AAAAAAAAA3o/JaDbUpQVC5g/s200/Capture.PNG" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-5446698130756660342?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/5446698130756660342/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=5446698130756660342' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/5446698130756660342'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/5446698130756660342'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2011/10/enabling-pptp-for-windows-vpn-behind.html' title='Enabling the PPTP for a Windows VPN behind OpenWrt router'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-D20GlYf_7Zg/TpXvMMdqGWI/AAAAAAAAA3o/JaDbUpQVC5g/s72-c/Capture.PNG' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-3461548140588765465</id><published>2011-09-15T12:41:00.001+03:00</published><updated>2011-09-15T12:46:14.404+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Interesting'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>AVL - Binary balanced tree in C#</title><content type='html'>This is my implementation of a binary search tree with both recursive and iterative insert:&lt;pre class="brush: csharp"&gt; &lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Diagnostics;&lt;br /&gt;&lt;br /&gt;namespace AVLTree&lt;br /&gt;{&lt;br /&gt;	public class AVLTree&amp;lt;ElementType&amp;gt;&lt;br /&gt;		where ElementType : IComparable&amp;lt;ElementType&amp;gt;&lt;br /&gt;	{&lt;br /&gt;		public Node Root { get; set; }&lt;br /&gt;		public Action&amp;lt;Node, ElementType&amp;gt; PerformActionOnInsertingNodesAllreadyInTheTree { get; set; }&lt;br /&gt;&lt;br /&gt;		public void Insert(ElementType value)&lt;br /&gt;		{&lt;br /&gt;			Root = Insert(value, Root);&lt;br /&gt;		}&lt;br /&gt;&lt;br /&gt;		public IEnumerable&amp;lt;ElementType&amp;gt; GetContent()&lt;br /&gt;		{&lt;br /&gt;			foreach (var item in GetContent(Root))&lt;br /&gt;				yield return item.Value;&lt;br /&gt;		}&lt;br /&gt;&lt;br /&gt;		public int GetHeight()&lt;br /&gt;		{&lt;br /&gt;			int max = int.MinValue;&lt;br /&gt;			foreach (var item in GetContent(Root))&lt;br /&gt;				max = Math.Max(max, item.Height);&lt;br /&gt;			return max;&lt;br /&gt;		}&lt;br /&gt;&lt;br /&gt;		private IEnumerable&amp;lt;Node&amp;gt; GetContent(Node node)&lt;br /&gt;		{&lt;br /&gt;			if (null == node)&lt;br /&gt;				yield break;&lt;br /&gt;&lt;br /&gt;			foreach (var item in GetContent(node.Left))&lt;br /&gt;				yield return item;&lt;br /&gt;			yield return node;&lt;br /&gt;			foreach (var item in GetContent(node.Right))&lt;br /&gt;				yield return item;&lt;br /&gt;		}&lt;br /&gt;&lt;br /&gt;		private Node Insert(ElementType value, Node subtreeNode)&lt;br /&gt;		{&lt;br /&gt;			if (null == subtreeNode)&lt;br /&gt;			{&lt;br /&gt;				subtreeNode = new Node(value);&lt;br /&gt;				return subtreeNode;&lt;br /&gt;			}&lt;br /&gt;			if (0 &amp;gt; value.CompareTo(subtreeNode.Value))&lt;br /&gt;			{&lt;br /&gt;				subtreeNode.Left = Insert(value, subtreeNode.Left);&lt;br /&gt;				if (1 &amp;lt; subtreeNode.Left.Height - Node.HeightOf(subtreeNode.Right))&lt;br /&gt;					if (0 &amp;gt; value.CompareTo(subtreeNode.Left.Value))&lt;br /&gt;						subtreeNode = subtreeNode.RotateWithLeftChild();&lt;br /&gt;					else&lt;br /&gt;						subtreeNode = subtreeNode.DoubleRotateWithLeftChild();&lt;br /&gt;			}&lt;br /&gt;			else if (0 &amp;lt; value.CompareTo(subtreeNode.Value))&lt;br /&gt;			{&lt;br /&gt;				subtreeNode.Right = Insert(value, subtreeNode.Right);&lt;br /&gt;				if (1 &amp;lt; subtreeNode.Right.Height - Node.HeightOf(subtreeNode.Left))&lt;br /&gt;					if (0 &amp;lt; value.CompareTo(subtreeNode.Right.Value))&lt;br /&gt;						subtreeNode = subtreeNode.RotateWithRightChild();&lt;br /&gt;					else&lt;br /&gt;						subtreeNode = subtreeNode.DoubleRotateWithRightChild();&lt;br /&gt;			}&lt;br /&gt;			else&lt;br /&gt;			{&lt;br /&gt;				if (null != PerformActionOnInsertingNodesAllreadyInTheTree)&lt;br /&gt;					PerformActionOnInsertingNodesAllreadyInTheTree(subtreeNode, value);&lt;br /&gt;			}&lt;br /&gt;&lt;br /&gt;			subtreeNode.Height = Math.Max(Node.HeightOf(subtreeNode.Left), Node.HeightOf(subtreeNode.Right)) + 1;&lt;br /&gt;			return subtreeNode;&lt;br /&gt;		}&lt;br /&gt;&lt;br /&gt;		public void InsertPlain(ElementType value)&lt;br /&gt;		{&lt;br /&gt;			Node current = Root;&lt;br /&gt;			Stack&amp;lt;TreeNavigationStep&amp;gt; pathToCurrentNode = new Stack&amp;lt;TreeNavigationStep&amp;gt;();&lt;br /&gt;&lt;br /&gt;			while (null != current)&lt;br /&gt;			{&lt;br /&gt;				if (0 &amp;gt; value.CompareTo(current.Value))&lt;br /&gt;				{&lt;br /&gt;					pathToCurrentNode.Push(new TreeNavigationStep(current, true, true));&lt;br /&gt;					current = current.Left;&lt;br /&gt;				}&lt;br /&gt;				else if (0 &amp;lt; value.CompareTo(current.Value))&lt;br /&gt;				{&lt;br /&gt;					pathToCurrentNode.Push(new TreeNavigationStep(current, false, true));&lt;br /&gt;					current = current.Right;&lt;br /&gt;				}&lt;br /&gt;				else&lt;br /&gt;				{&lt;br /&gt;					if (null != PerformActionOnInsertingNodesAllreadyInTheTree)&lt;br /&gt;					{&lt;br /&gt;						PerformActionOnInsertingNodesAllreadyInTheTree(current, value);&lt;br /&gt;					}&lt;br /&gt;					return;&lt;br /&gt;				}&lt;br /&gt;			}&lt;br /&gt;			Node newNode = new Node(value);&lt;br /&gt;			if (0 == pathToCurrentNode.Count)&lt;br /&gt;			{&lt;br /&gt;				Root = newNode;&lt;br /&gt;				return;&lt;br /&gt;			}&lt;br /&gt;&lt;br /&gt;			TreeNavigationStep navigationStep = pathToCurrentNode.Peek();&lt;br /&gt;			current = navigationStep.From;&lt;br /&gt;&lt;br /&gt;			if (navigationStep.ToLeft)&lt;br /&gt;			{&lt;br /&gt;				current.Left = newNode;&lt;br /&gt;			}&lt;br /&gt;			else&lt;br /&gt;			{&lt;br /&gt;				current.Right = newNode;&lt;br /&gt;			}&lt;br /&gt;&lt;br /&gt;			while(pathToCurrentNode.Count &amp;gt;0)&lt;br /&gt;			{&lt;br /&gt;				var step = pathToCurrentNode.Pop();&lt;br /&gt;				bool performedBalance = false;&lt;br /&gt;				Node parent = step.From;&lt;br /&gt;				Node nodeResultedByBalance = null;&lt;br /&gt;				if (step.FreeToBalance)&lt;br /&gt;				{&lt;br /&gt;					if (step.ToLeft)&lt;br /&gt;					{&lt;br /&gt;						if (1 &amp;lt; parent.Left.Height - Node.HeightOf(parent.Right))&lt;br /&gt;							if (0 &amp;gt; value.CompareTo(parent.Left.Value))&lt;br /&gt;							{&lt;br /&gt;								performedBalance = true;&lt;br /&gt;								nodeResultedByBalance = parent.RotateWithLeftChild();&lt;br /&gt;								if(0&amp;lt;pathToCurrentNode.Count)&lt;br /&gt;								{&lt;br /&gt;									var gradpa = pathToCurrentNode.Peek();&lt;br /&gt;									if(gradpa.ToLeft)&lt;br /&gt;										gradpa.From.Left = nodeResultedByBalance;&lt;br /&gt;									else&lt;br /&gt;										gradpa.From.Right = nodeResultedByBalance;&lt;br /&gt;								}&lt;br /&gt;								pathToCurrentNode.Push(new TreeNavigationStep(nodeResultedByBalance, false, false));&lt;br /&gt;							}&lt;br /&gt;							else&lt;br /&gt;							{&lt;br /&gt;								performedBalance = true;&lt;br /&gt;								nodeResultedByBalance = parent.DoubleRotateWithLeftChild();&lt;br /&gt;								if(0&amp;lt;pathToCurrentNode.Count)&lt;br /&gt;								{&lt;br /&gt;									var gradpa = pathToCurrentNode.Peek();&lt;br /&gt;									if(gradpa.ToLeft)&lt;br /&gt;										gradpa.From.Left = nodeResultedByBalance;&lt;br /&gt;									else&lt;br /&gt;										gradpa.From.Right = nodeResultedByBalance;&lt;br /&gt;								}&lt;br /&gt;								pathToCurrentNode.Push(new TreeNavigationStep(nodeResultedByBalance.Left, false, false));&lt;br /&gt;								pathToCurrentNode.Push(new TreeNavigationStep(nodeResultedByBalance, false, false));&lt;br /&gt;							}&lt;br /&gt;					}&lt;br /&gt;					else&lt;br /&gt;					{&lt;br /&gt;						if (1 &amp;lt; parent.Right.Height - Node.HeightOf(parent.Left))&lt;br /&gt;							if (0 &amp;lt; value.CompareTo(parent.Right.Value))&lt;br /&gt;							{&lt;br /&gt;								performedBalance = true;&lt;br /&gt;								nodeResultedByBalance = parent.RotateWithRightChild();&lt;br /&gt;								if(0&amp;lt;pathToCurrentNode.Count)&lt;br /&gt;								{&lt;br /&gt;									var gradpa = pathToCurrentNode.Peek();&lt;br /&gt;									if(gradpa.ToLeft)&lt;br /&gt;										gradpa.From.Left = nodeResultedByBalance;&lt;br /&gt;									else&lt;br /&gt;										gradpa.From.Right = nodeResultedByBalance;&lt;br /&gt;								}&lt;br /&gt;								pathToCurrentNode.Push(new TreeNavigationStep(nodeResultedByBalance, false, false));&lt;br /&gt;							}&lt;br /&gt;							else&lt;br /&gt;							{&lt;br /&gt;								performedBalance = true;&lt;br /&gt;								nodeResultedByBalance = parent.DoubleRotateWithRightChild();&lt;br /&gt;								if(0&amp;lt;pathToCurrentNode.Count)&lt;br /&gt;								{&lt;br /&gt;									var gradpa = pathToCurrentNode.Peek();&lt;br /&gt;									if(gradpa.ToLeft)&lt;br /&gt;										gradpa.From.Left = nodeResultedByBalance;&lt;br /&gt;									else&lt;br /&gt;										gradpa.From.Right = nodeResultedByBalance;&lt;br /&gt;								}&lt;br /&gt;								pathToCurrentNode.Push(new TreeNavigationStep(nodeResultedByBalance.Right, false, false));&lt;br /&gt;								pathToCurrentNode.Push(new TreeNavigationStep(nodeResultedByBalance, false, false));&lt;br /&gt;							}&lt;br /&gt;					}&lt;br /&gt;					if (performedBalance)&lt;br /&gt;						Root = nodeResultedByBalance;&lt;br /&gt;					else&lt;br /&gt;						Root = parent;&lt;br /&gt;				}&lt;br /&gt;				&lt;br /&gt;				parent.Height = Math.Max(Node.HeightOf(parent.Left), Node.HeightOf(parent.Right)) + 1;&lt;br /&gt;			}&lt;br /&gt;		}&lt;br /&gt;&lt;br /&gt;		public class TreeNavigationStep&lt;br /&gt;		{&lt;br /&gt;			public TreeNavigationStep(Node from, bool toLeftChild, bool freeToBalance)&lt;br /&gt;			{&lt;br /&gt;				From = from;&lt;br /&gt;				ToLeft = toLeftChild;&lt;br /&gt;				FreeToBalance = freeToBalance;&lt;br /&gt;			}&lt;br /&gt;			public Node From { get; set; }&lt;br /&gt;			public bool ToLeft { get; set; }&lt;br /&gt;			public bool FreeToBalance { get; set; }&lt;br /&gt;		}&lt;br /&gt;&lt;br /&gt;		[DebuggerDisplay(&amp;quot;{Value}&amp;quot;)]&lt;br /&gt;		public class Node&lt;br /&gt;		{&lt;br /&gt;			public Node(ElementType value)&lt;br /&gt;			{&lt;br /&gt;				Value = value;&lt;br /&gt;			}&lt;br /&gt;&lt;br /&gt;			public Node Left { get; set; }&lt;br /&gt;			public Node Right { get; set; }&lt;br /&gt;			public ElementType Value { get; set; }&lt;br /&gt;			public int Height { get; set; }&lt;br /&gt;&lt;br /&gt;			public Node RotateWithLeftChild()&lt;br /&gt;			{&lt;br /&gt;				Debug.Assert(null != this.Left);&lt;br /&gt;&lt;br /&gt;				Node left = this.Left;&lt;br /&gt;				this.Left = left.Right;&lt;br /&gt;				left.Right = this;&lt;br /&gt;&lt;br /&gt;				this.Height = Math.Max(HeightOf(this.Left), HeightOf(this.Right)) + 1;&lt;br /&gt;				left.Height = Math.Max(HeightOf(left.Left), this.Height) + 1;&lt;br /&gt;				return left;&lt;br /&gt;			}&lt;br /&gt;&lt;br /&gt;			public Node RotateWithRightChild()&lt;br /&gt;			{&lt;br /&gt;				Debug.Assert(null != this.Right);&lt;br /&gt;&lt;br /&gt;				Node right = this.Right;&lt;br /&gt;				this.Right = right.Left;&lt;br /&gt;				right.Left = this;&lt;br /&gt;&lt;br /&gt;				this.Height = Math.Max(HeightOf(this.Left), HeightOf(this.Right)) + 1;&lt;br /&gt;				right.Height = Math.Max(HeightOf(right.Right), this.Height) + 1;&lt;br /&gt;				return right;&lt;br /&gt;			}&lt;br /&gt;&lt;br /&gt;			public Node DoubleRotateWithLeftChild()&lt;br /&gt;			{&lt;br /&gt;				Debug.Assert(null != this.Left &amp;amp;&amp;amp; null != this.Left.Right);&lt;br /&gt;&lt;br /&gt;				this.Left = this.Left.RotateWithRightChild();&lt;br /&gt;				return this.RotateWithLeftChild();&lt;br /&gt;			}&lt;br /&gt;&lt;br /&gt;			public Node DoubleRotateWithRightChild()&lt;br /&gt;			{&lt;br /&gt;				Debug.Assert(null != this.Right &amp;amp;&amp;amp; null != this.Right.Left);&lt;br /&gt;&lt;br /&gt;				this.Right = this.Right.RotateWithLeftChild();&lt;br /&gt;				return this.RotateWithRightChild();&lt;br /&gt;			}&lt;br /&gt;&lt;br /&gt;			public static int HeightOf(Node node)&lt;br /&gt;			{&lt;br /&gt;				if (null == node)&lt;br /&gt;					return -1;&lt;br /&gt;				return node.Height;&lt;br /&gt;			}&lt;br /&gt;		}&lt;br /&gt;	}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-3461548140588765465?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/3461548140588765465/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=3461548140588765465' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/3461548140588765465'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/3461548140588765465'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2011/09/avl-binary-balanced-tree-in-c.html' title='AVL - Binary balanced tree in C#'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-8273106878611914696</id><published>2011-08-04T22:24:00.004+03:00</published><updated>2011-08-04T22:30:05.939+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Interesting'/><category scheme='http://www.blogger.com/atom/ns#' term='Internet'/><title type='text'>Changed the free DNS Hosting</title><content type='html'>Just moved from &lt;a href="http://free.editdns.net"&gt;http://free.editdns.net&lt;/a&gt; to &lt;a href="http://freedns.afraid.org"&gt;http://freedns.afraid.org&lt;/a&gt; . Tomorrow I will see if the transition was frictionless.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-8273106878611914696?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/8273106878611914696/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=8273106878611914696' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/8273106878611914696'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/8273106878611914696'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2011/08/changed-free-dns-hosting.html' title='Changed the free DNS Hosting'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-9132578582417641455</id><published>2011-03-17T23:16:00.005+02:00</published><updated>2011-03-17T23:52:30.353+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Interesting'/><category scheme='http://www.blogger.com/atom/ns#' term='Other tools'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Publish C# formatted code in blogspot</title><content type='html'>To show formatted C# code in my blog from now on i will use the &lt;a href="http://alexgorbatchev.com/SyntaxHighlighter/"&gt;SyntaxHighlighter by Alex Gorbatchev&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The quick setup is paste the following text in the blog template before the &amp;lt;/head&amp;gt; tag.&lt;br /&gt;&lt;pre class="brush: csharp"&gt;&lt;br /&gt;&amp;lt;link href=&amp;#39;http://alexgorbatchev.com/pub/sh/current/styles/shCore.css&amp;#39; rel=&amp;#39;stylesheet&amp;#39; type=&amp;#39;text/css&amp;#39;/&amp;gt;&lt;br /&gt;&amp;lt;link href=&amp;#39;http://alexgorbatchev.com/pub/sh/current/styles/shThemeRDark.css&amp;#39; rel=&amp;#39;stylesheet&amp;#39; type=&amp;#39;text/css&amp;#39;/&amp;gt;&lt;br /&gt;&amp;lt;script src=&amp;#39;http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js&amp;#39; type=&amp;#39;text/javascript&amp;#39;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;script src=&amp;#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js&amp;#39; type=&amp;#39;text/javascript&amp;#39;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;script src=&amp;#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js&amp;#39; type=&amp;#39;text/javascript&amp;#39;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;script src=&amp;#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js&amp;#39; type=&amp;#39;text/javascript&amp;#39;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;script src=&amp;#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js&amp;#39; type=&amp;#39;text/javascript&amp;#39;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;script src=&amp;#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js&amp;#39; type=&amp;#39;text/javascript&amp;#39;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;script src=&amp;#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js&amp;#39; type=&amp;#39;text/javascript&amp;#39;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;script src=&amp;#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js&amp;#39; type=&amp;#39;text/javascript&amp;#39;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;script src=&amp;#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js&amp;#39; type=&amp;#39;text/javascript&amp;#39;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;script src=&amp;#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js&amp;#39; type=&amp;#39;text/javascript&amp;#39;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;script src=&amp;#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js&amp;#39; type=&amp;#39;text/javascript&amp;#39;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;script src=&amp;#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js&amp;#39; type=&amp;#39;text/javascript&amp;#39;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;script src=&amp;#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js&amp;#39; type=&amp;#39;text/javascript&amp;#39;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;script language=&amp;#39;javascript&amp;#39;&amp;gt;&lt;br /&gt;SyntaxHighlighter.config.bloggerMode = true;&lt;br /&gt;SyntaxHighlighter.config.clipboardSwf = &amp;#39;http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf&amp;#39;;&lt;br /&gt;SyntaxHighlighter.all();&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;On posting you should enclose the Html encoded version of your code with &amp;lt;pre class=&amp;quot;brush: csharp&amp;quot;&amp;gt; &amp;lt;/pre&amp;gt; tags. For encoding in a friendly html format  you can use the &lt;a href="http://www.opinionatedgeek.com/dotnet/tools/htmlencode/encode.aspx"&gt;html encoder&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-9132578582417641455?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/9132578582417641455/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=9132578582417641455' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/9132578582417641455'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/9132578582417641455'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2011/03/publish-c-formatted-code-in-blogspot.html' title='Publish C# formatted code in blogspot'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-6448846894311683124</id><published>2011-03-17T14:24:00.010+02:00</published><updated>2011-03-26T09:32:17.851+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Sanitize strings against SQL injection using Regex</title><content type='html'>If &lt;strong&gt;SqlParameters cannot be used &lt;/strong&gt;this is an anti-pattern that will do the job: &lt;/br&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;        public static string Sanitize(this string stringValue)&lt;br /&gt;        {&lt;br /&gt;            if (null == stringValue)&lt;br /&gt;                return stringValue;&lt;br /&gt;            return stringValue&lt;br /&gt;                        .RegexReplace(&amp;quot;-{2,}&amp;quot;, &amp;quot;-&amp;quot;)                 // transforms multiple --- in - use to comment in sql scripts&lt;br /&gt;                        .RegexReplace(@&amp;quot;[*/]+&amp;quot;, string.Empty)      // removes / and * used also to comment in sql scripts&lt;br /&gt;                        .RegexReplace(@&amp;quot;(;|\s)(exec|execute|select|insert|update|delete|create|alter|drop|rename|truncate|backup|restore)\s&amp;quot;, string.Empty, RegexOptions.IgnoreCase);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        private static string RegexReplace(this string stringValue, string matchPattern, string toReplaceWith)&lt;br /&gt;        {&lt;br /&gt;            return Regex.Replace(stringValue, matchPattern, toReplaceWith);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private static string RegexReplace(this string stringValue, string matchPattern, string toReplaceWith, RegexOptions regexOptions)&lt;br /&gt;        {&lt;br /&gt;            return Regex.Replace(stringValue, matchPattern, toReplaceWith, regexOptions);&lt;br /&gt;        }&lt;/pre&gt;&lt;br /&gt;And some tests ...&lt;br /&gt;&lt;pre class="brush: csharp"&gt;        [TestMethod]&lt;br /&gt;        public void OnNullShouldReturnNull()&lt;br /&gt;        {&lt;br /&gt;            Assert.IsNull(RegexExtensions.Sanitize(null));&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        [TestMethod]&lt;br /&gt;        public void OnValidStringShouldReturnTheSameString()&lt;br /&gt;        {&lt;br /&gt;            Assert.AreEqual("a", "a".Sanitize());&lt;br /&gt;            Assert.AreEqual("aa", "aa".Sanitize());&lt;br /&gt;            Assert.AreEqual("-", "-".Sanitize());&lt;br /&gt;            Assert.AreEqual("a-", "a-".Sanitize());&lt;br /&gt;            Assert.AreEqual("-a", "-a".Sanitize());&lt;br /&gt;            Assert.AreEqual("-a-", "-a-".Sanitize());&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        [TestMethod]&lt;br /&gt;        public void OnMultipleDahsedShouldReturnJustADash()&lt;br /&gt;        {&lt;br /&gt;            Assert.AreEqual("-", "--".Sanitize());&lt;br /&gt;            Assert.AreEqual("a-", "a--".Sanitize());&lt;br /&gt;            Assert.AreEqual("-a", "--a".Sanitize());&lt;br /&gt;            Assert.AreEqual("-", "---".Sanitize());&lt;br /&gt;            Assert.AreEqual("-a-", "----a----".Sanitize());&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        [TestMethod]&lt;br /&gt;        public void ShouldRemoveGroupCommentsSymbols()&lt;br /&gt;        {&lt;br /&gt;            Assert.AreEqual(string.Empty, "/".Sanitize());&lt;br /&gt;            Assert.AreEqual(string.Empty, "*".Sanitize());&lt;br /&gt;            Assert.AreEqual(string.Empty, "/**//*/*/".Sanitize());&lt;br /&gt;            Assert.AreEqual("a", "/*a*/".Sanitize()); &lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        [TestMethod]&lt;br /&gt;        public void ShouldRemoveSQLKeyWords()&lt;br /&gt;        {&lt;br /&gt;            Assert.AreEqual("eXec", "eXec".Sanitize());&lt;br /&gt;            Assert.AreEqual(string.Empty, ";eXec ".Sanitize());&lt;br /&gt;            Assert.AreEqual(string.Empty, " eXec ".Sanitize());&lt;br /&gt;            Assert.AreEqual("  ", "  eXec  ".Sanitize());&lt;br /&gt;        }&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-6448846894311683124?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/6448846894311683124/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=6448846894311683124' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/6448846894311683124'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/6448846894311683124'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2011/03/sanitize-strings-against-sql-injection.html' title='Sanitize strings against SQL injection using Regex'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-1252880732787934062</id><published>2011-02-17T20:10:00.003+02:00</published><updated>2011-03-17T23:14:42.793+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>CustomTypeDescriptors</title><content type='html'>Mebyon Kernow had a very nice simplification to commands in wpf using custom type descriptors: http://blogs.msdn.com/b/morgan/archive/2010/06/24/simplifying-commands-in-mvvm-and-wpf.aspx&lt;br /&gt;&lt;br /&gt;I pasted some code for future reference:&lt;br /&gt;&lt;pre class="brush: csharp"&gt;&lt;br /&gt;namespace PersistingWorkflows&lt;br /&gt;{&lt;br /&gt;    /// &amp;lt;summary&amp;gt;&lt;br /&gt;    /// A map that exposes commands in a WPF binding friendly manner&lt;br /&gt;    /// &amp;lt;/summary&amp;gt;&lt;br /&gt;    [TypeDescriptionProvider(typeof(CommandMapDescriptionProvider))]&lt;br /&gt;    public class CommandMap&lt;br /&gt;    {&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Add a named command to the command map&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;commandName&amp;quot;&amp;gt;The name of the command&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;executeMethod&amp;quot;&amp;gt;The method to execute&amp;lt;/param&amp;gt;&lt;br /&gt;        public void AddCommand(string commandName, Action&amp;lt;object&amp;gt; executeMethod)&lt;br /&gt;        {&lt;br /&gt;            Commands[commandName] = new DelegateCommand(executeMethod);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Add a named command to the command map&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;commandName&amp;quot;&amp;gt;The name of the command&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;executeMethod&amp;quot;&amp;gt;The method to execute&amp;lt;/param&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;canExecuteMethod&amp;quot;&amp;gt;The method to execute to check if the command can be executed&amp;lt;/param&amp;gt;&lt;br /&gt;        public void AddCommand(string commandName, Action&amp;lt;object&amp;gt; executeMethod, Predicate&amp;lt;object&amp;gt; canExecuteMethod)&lt;br /&gt;        {&lt;br /&gt;            Commands[commandName] = new DelegateCommand(executeMethod, canExecuteMethod);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Remove a command from the command map&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        /// &amp;lt;param name=&amp;quot;commandName&amp;quot;&amp;gt;The name of the command&amp;lt;/param&amp;gt;&lt;br /&gt;        public void RemoveCommand(string commandName)&lt;br /&gt;        {&lt;br /&gt;            Commands.Remove(commandName);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Expose the dictionary of commands&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        protected Dictionary&amp;lt;string, ICommand&amp;gt; Commands&lt;br /&gt;        {&lt;br /&gt;            get&lt;br /&gt;            {&lt;br /&gt;                if (null == _commands)&lt;br /&gt;                    _commands = new Dictionary&amp;lt;string, ICommand&amp;gt;();&lt;br /&gt;&lt;br /&gt;                return _commands;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Store the commands&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        private Dictionary&amp;lt;string, ICommand&amp;gt; _commands;&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Implements ICommand in a delegate friendly way&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        private class DelegateCommand : ICommand&lt;br /&gt;        {&lt;br /&gt;            /// &amp;lt;summary&amp;gt;&lt;br /&gt;            /// Create a command that can always be executed&lt;br /&gt;            /// &amp;lt;/summary&amp;gt;&lt;br /&gt;            /// &amp;lt;param name=&amp;quot;executeMethod&amp;quot;&amp;gt;The method to execute when the command is called&amp;lt;/param&amp;gt;&lt;br /&gt;            public DelegateCommand(Action&amp;lt;object&amp;gt; executeMethod) : this(executeMethod, null) { }&lt;br /&gt;&lt;br /&gt;            /// &amp;lt;summary&amp;gt;&lt;br /&gt;            /// Create a delegate command which executes the canExecuteMethod before executing the executeMethod&lt;br /&gt;            /// &amp;lt;/summary&amp;gt;&lt;br /&gt;            /// &amp;lt;param name=&amp;quot;executeMethod&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;            /// &amp;lt;param name=&amp;quot;canExecuteMethod&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;            public DelegateCommand(Action&amp;lt;object&amp;gt; executeMethod, Predicate&amp;lt;object&amp;gt; canExecuteMethod)&lt;br /&gt;            {&lt;br /&gt;                if (null == executeMethod)&lt;br /&gt;                    throw new ArgumentNullException(&amp;quot;executeMethod&amp;quot;);&lt;br /&gt;&lt;br /&gt;                this._executeMethod = executeMethod;&lt;br /&gt;                this._canExecuteMethod = canExecuteMethod;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            public bool CanExecute(object parameter)&lt;br /&gt;            {&lt;br /&gt;                return (null == _canExecuteMethod) ? true : _canExecuteMethod(parameter);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            public event EventHandler CanExecuteChanged&lt;br /&gt;            {&lt;br /&gt;                add { CommandManager.RequerySuggested += value; }&lt;br /&gt;                remove { CommandManager.RequerySuggested -= value; }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            public void Execute(object parameter)&lt;br /&gt;            {&lt;br /&gt;                _executeMethod(parameter);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            private Predicate&amp;lt;object&amp;gt; _canExecuteMethod;&lt;br /&gt;            private Action&amp;lt;object&amp;gt; _executeMethod;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// Expose the dictionary entries of a CommandMap as properties&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        private class CommandMapDescriptionProvider : TypeDescriptionProvider&lt;br /&gt;        {&lt;br /&gt;            /// &amp;lt;summary&amp;gt;&lt;br /&gt;            /// Standard constructor&lt;br /&gt;            /// &amp;lt;/summary&amp;gt;&lt;br /&gt;            public CommandMapDescriptionProvider()&lt;br /&gt;                : this(TypeDescriptor.GetProvider(typeof(CommandMap)))&lt;br /&gt;            {&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            /// &amp;lt;summary&amp;gt;&lt;br /&gt;            /// Construct the provider based on a parent provider&lt;br /&gt;            /// &amp;lt;/summary&amp;gt;&lt;br /&gt;            /// &amp;lt;param name=&amp;quot;parent&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;            public CommandMapDescriptionProvider(TypeDescriptionProvider parent)&lt;br /&gt;                : base(parent)&lt;br /&gt;            {&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            /// &amp;lt;summary&amp;gt;&lt;br /&gt;            /// Get the type descriptor for a given object instance&lt;br /&gt;            /// &amp;lt;/summary&amp;gt;&lt;br /&gt;            /// &amp;lt;param name=&amp;quot;objectType&amp;quot;&amp;gt;The type of object for which a type descriptor is requested&amp;lt;/param&amp;gt;&lt;br /&gt;            /// &amp;lt;param name=&amp;quot;instance&amp;quot;&amp;gt;The instance of the object&amp;lt;/param&amp;gt;&lt;br /&gt;            /// &amp;lt;returns&amp;gt;A custom type descriptor&amp;lt;/returns&amp;gt;&lt;br /&gt;            public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance)&lt;br /&gt;            {&lt;br /&gt;                return new CommandMapDescriptor(base.GetTypeDescriptor(objectType, instance), instance as CommandMap);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// This class is responsible for providing custom properties to WPF - in this instance&lt;br /&gt;        /// allowing you to bind to commands by name&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        private class CommandMapDescriptor : CustomTypeDescriptor&lt;br /&gt;        {&lt;br /&gt;            /// &amp;lt;summary&amp;gt;&lt;br /&gt;            /// Store the command map for later&lt;br /&gt;            /// &amp;lt;/summary&amp;gt;&lt;br /&gt;            /// &amp;lt;param name=&amp;quot;descriptor&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;            /// &amp;lt;param name=&amp;quot;map&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;            public CommandMapDescriptor(ICustomTypeDescriptor descriptor, CommandMap map)&lt;br /&gt;                : base(descriptor)&lt;br /&gt;            {&lt;br /&gt;                _map = map;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            /// &amp;lt;summary&amp;gt;&lt;br /&gt;            /// Get the properties for this command map&lt;br /&gt;            /// &amp;lt;/summary&amp;gt;&lt;br /&gt;            /// &amp;lt;returns&amp;gt;A collection of synthesized property descriptors&amp;lt;/returns&amp;gt;&lt;br /&gt;            public override PropertyDescriptorCollection GetProperties()&lt;br /&gt;            {&lt;br /&gt;                //TODO: See about caching these properties (need the _map to be observable so can respond to add/remove)&lt;br /&gt;                PropertyDescriptor[] props = new PropertyDescriptor[_map.Commands.Count];&lt;br /&gt;&lt;br /&gt;                int pos = 0;&lt;br /&gt;&lt;br /&gt;                foreach (KeyValuePair&amp;lt;string, ICommand&amp;gt; command in _map.Commands)&lt;br /&gt;                    props[pos++] = new CommandPropertyDescriptor(command);&lt;br /&gt;&lt;br /&gt;                return new PropertyDescriptorCollection(props);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            private CommandMap _map;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;        /// A property descriptor which exposes an ICommand instance&lt;br /&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;        private class CommandPropertyDescriptor : PropertyDescriptor&lt;br /&gt;        {&lt;br /&gt;            /// &amp;lt;summary&amp;gt;&lt;br /&gt;            /// Construct the descriptor&lt;br /&gt;            /// &amp;lt;/summary&amp;gt;&lt;br /&gt;            /// &amp;lt;param name=&amp;quot;command&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;            public CommandPropertyDescriptor(KeyValuePair&amp;lt;string, ICommand&amp;gt; command)&lt;br /&gt;                : base(command.Key, null)&lt;br /&gt;            {&lt;br /&gt;                _command = command.Value;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            /// &amp;lt;summary&amp;gt;&lt;br /&gt;            /// Always read only in this case&lt;br /&gt;            /// &amp;lt;/summary&amp;gt;&lt;br /&gt;            public override bool IsReadOnly&lt;br /&gt;            {&lt;br /&gt;                get { return true; }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            /// &amp;lt;summary&amp;gt;&lt;br /&gt;            /// Nope, it&amp;#39;s read only&lt;br /&gt;            /// &amp;lt;/summary&amp;gt;&lt;br /&gt;            /// &amp;lt;param name=&amp;quot;component&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;            /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br /&gt;            public override bool CanResetValue(object component)&lt;br /&gt;            {&lt;br /&gt;                return false;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            /// &amp;lt;summary&amp;gt;&lt;br /&gt;            /// Not needed&lt;br /&gt;            /// &amp;lt;/summary&amp;gt;&lt;br /&gt;            public override Type ComponentType&lt;br /&gt;            {&lt;br /&gt;                get { throw new NotImplementedException(); }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            /// &amp;lt;summary&amp;gt;&lt;br /&gt;            /// Get the ICommand from the parent command map&lt;br /&gt;            /// &amp;lt;/summary&amp;gt;&lt;br /&gt;            /// &amp;lt;param name=&amp;quot;component&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;            /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br /&gt;            public override object GetValue(object component)&lt;br /&gt;            {&lt;br /&gt;                CommandMap map = component as CommandMap;&lt;br /&gt;&lt;br /&gt;                if (null == map)&lt;br /&gt;                    throw new ArgumentException(&amp;quot;component is not a CommandMap instance&amp;quot;, &amp;quot;component&amp;quot;);&lt;br /&gt;&lt;br /&gt;                return map.Commands[this.Name];&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            /// &amp;lt;summary&amp;gt;&lt;br /&gt;            /// Get the type of the property&lt;br /&gt;            /// &amp;lt;/summary&amp;gt;&lt;br /&gt;            public override Type PropertyType&lt;br /&gt;            {&lt;br /&gt;                get { return typeof(ICommand); }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            /// &amp;lt;summary&amp;gt;&lt;br /&gt;            /// Not needed&lt;br /&gt;            /// &amp;lt;/summary&amp;gt;&lt;br /&gt;            /// &amp;lt;param name=&amp;quot;component&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;            public override void ResetValue(object component)&lt;br /&gt;            {&lt;br /&gt;                throw new NotImplementedException();&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            /// &amp;lt;summary&amp;gt;&lt;br /&gt;            /// Not needed&lt;br /&gt;            /// &amp;lt;/summary&amp;gt;&lt;br /&gt;            /// &amp;lt;param name=&amp;quot;component&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;            /// &amp;lt;param name=&amp;quot;value&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;            public override void SetValue(object component, object value)&lt;br /&gt;            {&lt;br /&gt;                throw new NotImplementedException();&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            /// &amp;lt;summary&amp;gt;&lt;br /&gt;            /// Not needed&lt;br /&gt;            /// &amp;lt;/summary&amp;gt;&lt;br /&gt;            /// &amp;lt;param name=&amp;quot;component&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;            /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br /&gt;            public override bool ShouldSerializeValue(object component)&lt;br /&gt;            {&lt;br /&gt;                return false;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            /// &amp;lt;summary&amp;gt;&lt;br /&gt;            /// Store the command which will be executed&lt;br /&gt;            /// &amp;lt;/summary&amp;gt;&lt;br /&gt;            private ICommand _command;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-1252880732787934062?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/1252880732787934062/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=1252880732787934062' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/1252880732787934062'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/1252880732787934062'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2011/02/customtypedescriptors.html' title='CustomTypeDescriptors'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-3732672377970945471</id><published>2010-05-19T23:29:00.002+03:00</published><updated>2010-05-19T23:35:54.388+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Trace'/><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='Debug'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Tracing .net WPF</title><content type='html'>Copy from http://blogs.msdn.com/mikehillberg/archive/2006/09/14/WpfTraceSources.aspx in case that will vanish&lt;br /&gt;&lt;br /&gt;Trace sources in WPF&lt;br /&gt;&lt;br /&gt;WPF (Avalon) uses the .Net tracing system to provide some diagnostics about what’s going on inside your WPF application.  It’s not at all an exhaustive set of traces, and in fact it’s still pretty rudimentary.  But frequently it’s enough to help out when you’re trying to debug a problem.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;The short story is that WPF defines a set of TraceSource objects that you can configure and use, with all the normal .Net tracing functionality.  The TraceSource names are shown below in a sample .Config file.  In addition to the .config file, you need to set a flag in the registry.  Or you can skip the .config file and/or registry flag, and do everything with the PresentationTraceSources class, either from code or from the Visual Studio Immediate window.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Now the longer story ...&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;.Net Tracing Background&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;First a quick background on .Net tracing … The .Net platform provides some classes to allow you to send trace messages, not only to the debug output window, but to a file, or anyone else that wants to listen.  You can send traces using the static System.Diagnostics.Trace class in .Net 1.0, and in .Net 2.0 using TraceSource objects.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;The basic model is to instrument your code with calls to Trace or TraceSource of interesting events.  You (or the user of your program) can then add some entries to the application's .config file to enable those traces, filter them, and capture them (for example to a file).&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;For more background on tracing in general, the TraceSource documentation in the SDK provides a nice overview.  Also, Mike Rousos has a multi-part overview on .Net tracing ... first a basic overview, and then more details here, here, and here.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Enabling WPF Tracing in a .Config File&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;In general, you configure .Net tracing by configuring the TraceSource objects.  The easiest way to configure the traces is with a .config file for the application, or machine-wide (if you're an administrator) by adding entries to the machine.config file.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;For WPF, however, you also need to get the trace sources enabled first.  Otherwise we don’t even read the .config file to look for settings.  The WPF traces can be enabled by setting a flag in registry, or by calling PresentationTraceSources.Refresh from code.  I’ll talk more about PresentationTraceSources later in "Enabling and Configuring WPF Trace Sources Programmatically".  To enable WPF tracing in the registry, create the key&lt;br /&gt;&lt;br /&gt;"hkey_current_user\software\microsoft\tracing\wpf", add a "ManagedTracing" DWORD value, and set it to one.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Additionally, some WPF tracing is enabled automatically when you launch your app from within the debugger.  Specifically, this is the case for databinding warnings and errors.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Once you've got the registry set for the WPF trace sources, you still won't get much tracing until you turn it on with the .Config file. The easiest way to explain the rest of this is to show a sample .config file:&lt;br /&gt;&lt;br /&gt; &lt;blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;configuration&gt;&lt;br /&gt;&lt;br /&gt;  &lt;system.diagnostics&gt;&lt;br /&gt;&lt;br /&gt;    &lt;sources&gt;&lt;br /&gt;&lt;br /&gt;      &lt;!--&lt;br /&gt;&lt;br /&gt;      &lt;source name="System.Windows.Data" switchName="SourceSwitch" &gt;&lt;br /&gt;&lt;br /&gt;        &lt;listeners&gt;&lt;br /&gt;&lt;br /&gt;          &lt;add name="textListener" /&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/listeners&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/source&gt;&lt;br /&gt;&lt;br /&gt;      --&gt;&lt;br /&gt;&lt;br /&gt;      &lt;!--&lt;br /&gt;&lt;br /&gt;      &lt;source name="System.Windows.DependencyProperty" switchName="SourceSwitch" &gt;&lt;br /&gt;&lt;br /&gt;        &lt;listeners&gt;&lt;br /&gt;&lt;br /&gt;          &lt;add name="textListener" /&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/listeners&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/source&gt;&lt;br /&gt;&lt;br /&gt;      --&gt;&lt;br /&gt;&lt;br /&gt;      &lt;!--&lt;br /&gt;&lt;br /&gt;      &lt;source name="System.Windows.Freezable" switchName="SourceSwitch" &gt;&lt;br /&gt;&lt;br /&gt;        &lt;listeners&gt;&lt;br /&gt;&lt;br /&gt;          &lt;add name="textListener" /&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/listeners&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/source&gt;&lt;br /&gt;&lt;br /&gt;      --&gt;&lt;br /&gt;&lt;br /&gt;      &lt;!--&lt;br /&gt;&lt;br /&gt;      &lt;source name="System.Windows.RoutedEvent" switchName="SourceSwitch" &gt;&lt;br /&gt;&lt;br /&gt;        &lt;listeners&gt;&lt;br /&gt;&lt;br /&gt;          &lt;add name="textListener" /&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/listeners&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/source&gt;&lt;br /&gt;&lt;br /&gt;      --&gt;&lt;br /&gt;&lt;br /&gt;      &lt;!--&lt;br /&gt;&lt;br /&gt;      &lt;source name="System.Windows.Media.Animation" switchName="SourceSwitch" &gt;&lt;br /&gt;&lt;br /&gt;        &lt;listeners&gt;&lt;br /&gt;&lt;br /&gt;          &lt;add name="textListener" /&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/listeners&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/source&gt;&lt;br /&gt;&lt;br /&gt;      --&gt;&lt;br /&gt;&lt;br /&gt;      &lt;!--&lt;br /&gt;&lt;br /&gt;      &lt;source name="System.Windows.NameScope" switchName="SourceSwitch" &gt;&lt;br /&gt;&lt;br /&gt;        &lt;listeners&gt;&lt;br /&gt;&lt;br /&gt;          &lt;add name="textListener" /&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/listeners&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/source&gt;&lt;br /&gt;&lt;br /&gt;      --&gt;&lt;br /&gt;&lt;br /&gt;      &lt;!--&lt;br /&gt;&lt;br /&gt;      &lt;source name="System.Windows.ResourceDictionary" switchName="SourceSwitch" &gt;&lt;br /&gt;&lt;br /&gt;        &lt;listeners&gt;&lt;br /&gt;&lt;br /&gt;          &lt;add name="textListener" /&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/listeners&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/source&gt;&lt;br /&gt;&lt;br /&gt;      --&gt;&lt;br /&gt;&lt;br /&gt;      &lt;!--&lt;br /&gt;&lt;br /&gt;      &lt;source name="System.Windows.Markup" switchName="SourceSwitch" &gt;&lt;br /&gt;&lt;br /&gt;        &lt;listeners&gt;&lt;br /&gt;&lt;br /&gt;          &lt;add name="textListener" /&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/listeners&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/source&gt;&lt;br /&gt;&lt;br /&gt;      --&gt;&lt;br /&gt;&lt;br /&gt;      &lt;!--&lt;br /&gt;&lt;br /&gt;      &lt;source name="System.Windows.Documents" switchName="SourceSwitch" &gt;&lt;br /&gt;&lt;br /&gt;        &lt;listeners&gt;&lt;br /&gt;&lt;br /&gt;          &lt;add name="textListener" /&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/listeners&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/source&gt;&lt;br /&gt;&lt;br /&gt;      --&gt;&lt;br /&gt;&lt;br /&gt;    &lt;/sources&gt;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;    &lt;switches&gt;&lt;br /&gt;&lt;br /&gt;      &lt;add name="SourceSwitch" value="All" /&gt;&lt;br /&gt;&lt;br /&gt;      &lt;!--add name="SourceSwitch" value="Off" --&gt;&lt;br /&gt;&lt;br /&gt;      &lt;!--add name="SourceSwitch" value="Verbose" --&gt;&lt;br /&gt;&lt;br /&gt;      &lt;!--add name="SourceSwitch" value="Warning" --&gt;&lt;br /&gt;&lt;br /&gt;      &lt;!--add name="SourceSwitch" value="Activity" --&gt;&lt;br /&gt;&lt;br /&gt;    &lt;/switches&gt;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;    &lt;sharedListeners&gt;&lt;br /&gt;&lt;br /&gt;      &lt;!-- This listener sends output to the console --&gt;&lt;br /&gt;&lt;br /&gt;      &lt;add name="console"&lt;br /&gt;&lt;br /&gt;           type="System.Diagnostics.ConsoleTraceListener"&lt;br /&gt;&lt;br /&gt;           initializeData="false"/&gt;&lt;br /&gt;&lt;br /&gt;      &lt;!-- This listener sends output to an Xml file named AvTrace.xml --&gt;&lt;br /&gt;&lt;br /&gt;      &lt;add name="xmlListener"&lt;br /&gt;&lt;br /&gt;           type="System.Diagnostics.XmlWriterTraceListener"&lt;br /&gt;&lt;br /&gt;           traceOutputOptions="None"&lt;br /&gt;&lt;br /&gt;           initializeData="AvTrace.xml" /&gt;&lt;br /&gt;&lt;br /&gt;      &lt;!-- This listener sends output to a file named AvTrace.txt --&gt;&lt;br /&gt;&lt;br /&gt;      &lt;add name="textListener"&lt;br /&gt;&lt;br /&gt;           type="System.Diagnostics.TextWriterTraceListener"&lt;br /&gt;&lt;br /&gt;           initializeData="AvTrace.txt" /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;/sharedListeners&gt;&lt;br /&gt;&lt;br /&gt;    &lt;trace autoflush="true" indentsize="4"&gt;&lt;/trace&gt;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;  &lt;/system.diagnostics&gt;&lt;br /&gt;&lt;br /&gt;&lt;/configuration&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;You can put this Xml into a .config file and use it as is.  For example, to get tracing for XamlPad.exe, put this in a file named XamlPad.exe.config and put it in the same directory as XamlPad.exe.  (If you’re on Windows Vista it might not like you putting a file in to XamlPad’s directory under Program Files, but you can just copy XamlPad.exe out to another directory first.)  Note that this Xml includes the &lt;configuration&gt; tag and the &lt;system.diagnostics&gt; tag, etc.  So if you're adding these settings to an existing .config file or to the machine.config file, and it already has those tags, just copy in the content without the tags.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Notice in this Xml that it lists all of the trace sources that WPF creates.  Also note that everything is commented out.  So you need to un-comment the trace sources that you want to be used.  Once you've uncommented a section, you can configure all the settings available from the basic .Net tracing; WPF just uses that and doesn't do anything special.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;By default, the above settings write output to a file named "avtrace.txt", but you can choose other trace listeners, including custom trace listeners that you write.  You can also filter traces away from listeners by writing custom filters and adding them to the .config file.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Examining the raw output&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" &gt;&lt;br /&gt;&lt;br /&gt;  &lt;Button Name="Button1"&gt;Clack&lt;/Button&gt;&lt;br /&gt;&lt;br /&gt;&lt;/Page&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;So let's try an example.  Put the above Xml into a XamlPad.exe.config file, put it in the same directly as XamlPad.exe, and remove the comments around the System.Windows.RoutedEvent and System.Windows.NameScope sections.  Run XamlPad with the following markup, click on the Button, then close XamlPad:&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" &gt;&lt;br /&gt;&lt;br /&gt;  &lt;Button Name="Button1"&gt;Clack&lt;/Button&gt;&lt;br /&gt;&lt;br /&gt;&lt;/Page&gt;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Now look at the output in avtrace.txt, and the first thing you’ll notice is that there’s a lot of it.  The basic format of the output is several fields with:&lt;br /&gt;&lt;br /&gt;·         The trace source name&lt;br /&gt;&lt;br /&gt;·         “Start” or “Stop”&lt;br /&gt;&lt;br /&gt;·         Trace ID (each different type of trace from a trace source has its own ID number)&lt;br /&gt;&lt;br /&gt;·         Brief description of the event&lt;br /&gt;&lt;br /&gt;·         A list of parameters for the event.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;(As you look at the output, also remember that XamlPad is itself a WPF application, so most of the traces you see are from XamlPad, not your Page and Button.)&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;As I said earlier, this is all pretty rudimentary.  But by building it on the standard .Net tracing system, you can create your own tools to process or filter it, or load it into Excel, create pivot tables, etc.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;So here’s an interesting trace from the output, this shows a System.Windows.NameScope trace where the “Button1” name from your markup got registered for the Button:&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;System.Windows.NameScope Start: 1 : Name has been registered on INameScope; NameScope='System.Windows.NameScope'; NameScope.HashCode='42483779'; NameScope.Type='System.Windows.NameScope'; Name='Button1'; Object='System.Windows.Controls.Button'; Object.HashCode='46809697'; Object.Type='System.Windows.Controls.Button'&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Notice the parameters there are defined by the trace.  In the case of this trace, it shows the name, and the object getting named.  If you write a custom trace filter, you can actually look at the instance of the button.  For the standard trace listeners/filters, an object is simply written out by calling ToString, GetHashCode, and GetType.  For example, the button was represented in the above trace with:&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Object='System.Windows.Controls.Button'; Object.HashCode='46809697'; Object.Type='System.Windows.Controls.Button'&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Most of the WPF traces include the relevant object, so a quick-and-dirty way to filter the output is to grep for that object’s hash code in the name registration.  That will now show you most everything in the output related to that button, and for example filter out all the traces relating to XamlPad itself.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Now looking through this filtered output, you can more easily see traces such as the MouseEnter event when I first moved the mouse over the button:&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;System.Windows.RoutedEvent Start: 1 : Raise RoutedEvent; RoutedEvent='Mouse.MouseEnter'; RoutedEvent.HashCode='117163'; RoutedEvent.Type='System.Windows.RoutedEvent'; Element='System.Windows.Controls.Button: Clack'; Element.HashCode='46809697'; Element.Type='System.Windows.Controls.Button'; RoutedEventArgs='System.Windows.Input.MouseEventArgs'; RoutedEventArgs.HashCode='9490272'; RoutedEventArgs.Type='System.Windows.Input.MouseEventArgs'; Handled='False'&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;And you can see the button click event itself.  Here’s the traces for the click event, as well as the MouseUp event that triggered it, along with the other events that are triggered from a MouseUp (the MouseUp and Click events are highlighted):&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;System.Windows.RoutedEvent Start: 1 : Raise RoutedEvent; RoutedEvent='Mouse.MouseUp'; RoutedEvent.HashCode='7092232'; RoutedEvent.Type='System.Windows.RoutedEvent'; Element='System.Windows.Controls.Button: Clack'; Element.HashCode='46809697'; Element.Type='System.Windows.Controls.Button'; RoutedEventArgs='System.Windows.Input.MouseButtonEventArgs'; RoutedEventArgs.HashCode='63830089'; RoutedEventArgs.Type='System.Windows.Input.MouseButtonEventArgs'; Handled='False'&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;System.Windows.RoutedEvent Start: 2 : Raise RoutedEvent; RoutedEvent='UIElement.MouseLeftButtonUp'; RoutedEvent.HashCode='37599894'; RoutedEvent.Type='System.Windows.RoutedEvent'; Element='System.Windows.Controls.Button: Clack'; Element.HashCode='46809697'; Element.Type='System.Windows.Controls.Button'; RoutedEventArgs='System.Windows.Input.MouseButtonEventArgs'; RoutedEventArgs.HashCode='63830089'; RoutedEventArgs.Type='System.Windows.Input.MouseButtonEventArgs'; Handled='False'&lt;br /&gt;&lt;br /&gt;System.Windows.RoutedEvent Start: 1 : Raise RoutedEvent; RoutedEvent='Mouse.LostMouseCapture'; RoutedEvent.HashCode='2854726'; RoutedEvent.Type='System.Windows.RoutedEvent'; Element='System.Windows.Controls.Button: Clack'; Element.HashCode='46809697'; Element.Type='System.Windows.Controls.Button'; RoutedEventArgs='System.Windows.Input.MouseEventArgs'; RoutedEventArgs.HashCode='25692540'; RoutedEventArgs.Type='System.Windows.Input.MouseEventArgs'; Handled='False'&lt;br /&gt;&lt;br /&gt;System.Windows.RoutedEvent Stop: 1 : Raise RoutedEvent; RoutedEvent='Mouse.LostMouseCapture'; RoutedEvent.HashCode='2854726'; RoutedEvent.Type='System.Windows.RoutedEvent'; Element='System.Windows.Controls.Button: Clack'; Element.HashCode='46809697'; Element.Type='System.Windows.Controls.Button'; RoutedEventArgs='System.Windows.Input.MouseEventArgs'; RoutedEventArgs.HashCode='25692540'; RoutedEventArgs.Type='System.Windows.Input.MouseEventArgs'; Handled='False'&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;System.Windows.RoutedEvent Start: 1 : Raise RoutedEvent; RoutedEvent='ButtonBase.Click'; RoutedEvent.HashCode='42526340'; RoutedEvent.Type='System.Windows.RoutedEvent'; Element='System.Windows.Controls.Button: Clack'; Element.HashCode='46809697'; Element.Type='System.Windows.Controls.Button'; RoutedEventArgs='System.Windows.RoutedEventArgs'; RoutedEventArgs.HashCode='47192740'; RoutedEventArgs.Type='System.Windows.RoutedEventArgs'; Handled='False'&lt;br /&gt;&lt;br /&gt;System.Windows.RoutedEvent Stop: 1 : Raise RoutedEvent; RoutedEvent='ButtonBase.Click'; RoutedEvent.HashCode='42526340'; RoutedEvent.Type='System.Windows.RoutedEvent'; Element='System.Windows.Controls.Button: Clack'; Element.HashCode='46809697'; Element.Type='System.Windows.Controls.Button'; RoutedEventArgs='System.Windows.RoutedEventArgs'; RoutedEventArgs.HashCode='47192740'; RoutedEventArgs.Type='System.Windows.RoutedEventArgs'; Handled='False'&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;System.Windows.RoutedEvent Stop: 2 : Raise RoutedEvent; RoutedEvent='Mouse.MouseUp'; RoutedEvent.HashCode='7092232'; RoutedEvent.Type='System.Windows.RoutedEvent'; Element='System.Windows.Controls.Button: Clack'; Element.HashCode='46809697'; Element.Type='System.Windows.Controls.Button'; RoutedEventArgs='System.Windows.Input.MouseButtonEventArgs'; RoutedEventArgs.HashCode='63830089'; RoutedEventArgs.Type='System.Windows.Input.MouseButtonEventArgs'; Handled='True'&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;WPF Trace Sources&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;As you can see from the sample config file above, there are several trace sources created by WPF.  They’re all named after the type or namespace that implements them.  Here’s a description of all the sources:&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;·         System.Windows.Data&lt;br /&gt;This is probably the most useful trace source, and provides all kinds of information about WPF databinding, including warnings when it wasn’t possible to resolve a binding.  This trace source does one thing that the other WPF trace sources do not, it enables itself automatically when you start your app in the debugger.&lt;br /&gt;&lt;br /&gt;·         System.Windows.DependencyProperty&lt;br /&gt;This is probably the least useful trace source, and just provides information about registration of DPs.  Unfortunately it doesn’t provide information such as property values being set and calculated.&lt;br /&gt;&lt;br /&gt;·         System.Windows.Freezable&lt;br /&gt;This provides tracing about Freezable problems that don’t cause an exception.  For example, if you call the CanFreeze method on a Freezable and it returns false, this tracing might be able to help you determine what exactly couldn’t be frozen.&lt;br /&gt;&lt;br /&gt;·         System.Windows.RoutedEvent&lt;br /&gt;Provides tracing information on the routing of RoutedEvents, including a trace indicating what event listener handled the event.&lt;br /&gt;&lt;br /&gt;·         System.Windows.Media.Animation&lt;br /&gt;Sends traces when storyboards are started, stopped, paused, resumed, etc.&lt;br /&gt;&lt;br /&gt;·         System.Windows.NameScope&lt;br /&gt;Sends a trace when a name is registered, providing the name and the object.&lt;br /&gt;&lt;br /&gt;·         System.Windows.ResourceDictionary&lt;br /&gt;Sends traces when a resource is set, removed, looked up, etc.  Since there could be multiple resource dictionaries that define the same resource, this can be a useful way to determine where the resource is actually coming from.&lt;br /&gt;&lt;br /&gt;·         System.Windows.Markup&lt;br /&gt;This sends traces when Xaml (or Baml) is loaded, with information such as the objects being created, the properties being set, and the type converters being used.&lt;br /&gt;&lt;br /&gt;·         System.Windows.Documents&lt;br /&gt;Traces information about page formatting errors for paginated documents.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Enabling and Configuring WPF Trace Sources Programmatically&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Instead of, or in addition to, the .config file, you can configure the WPF traces from code in your app.  The PresentationTraceSources class holds all of the TraceSource objects described above.  As a result, you can simply configure the sources with the TraceSource API.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Of special note is the PresentationTraceSources.Refresh method.  One thing that this does is call Trace.Refresh, which causes all TraceSource objects in the application (including WPF’s) to re-read the .Config file.  But in addition this causes the WPF traces to be enabled first, as if the registry flag described earlier had been set.  That is, calling Refresh is a way to turn on WPF debugging without actually modifying the registry.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;And you can equivalently call the Refresh method from the Immediate window in Visual Studio for any app; you don’t have to actually call it from code in the app.  If you have a .config file, it will be read and trace sources will be configured appropriately.  If you don’t have a .config file set, you can still set up the trace sources manually in the Immediate window.  For example, running these commands enables the WPF trace sources, and sets up for all RoutedEvent traces to go to the debug output window:&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;PresentationTraceSources.Refresh()&lt;br /&gt;&lt;br /&gt;PresentationTraceSources.RoutedEventSource.Listeners.Add(new DefaultTraceListener() )&lt;br /&gt;&lt;br /&gt;PresentationTraceSources.RoutedEventSource.Switch.Level = SourceLevels.All&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Trace Switch Levels&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;As described in the .Net tracing documentation, a TraceSource has a Switch property that can be used to indicate what level of traces should be sent by the source.  These switch levels can be set in the .config file, or programmatically via the PresentationTraceSources. &lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;The interesting levels for WPF traces are Warning, ActivityTracing, and All.  Not all of the trace sources in WPF provide warnings, but the Freezable and ResourceDictionary provide a few, and Data provides a lot of useful Warning traces as well as Error traces.  The ActivityTracing level tends to get a lot more verbose, and of course the simplest thing to do is use All.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;The WPF trace sources do one additional thing on top of what TraceSource does automatically.  If you’re running under the debugger, and the trace source is enabled in the .config file but set with a level of “Off”.  The side-effect of this is that if you set the level to “Off” in the .config file, it will still get promoted to “Warning”, and you’ll see all Warning/Error/Critical traces.  To work around this, rather than setting the level to “Off”, set it to “Critical”, as none of the WPF traces are at this high level.  If you enable WPF traces by calling PresentationTraceSources.Refresh() from code or from the Immediate Window in Visual Studio, this promotion doesn’t occur.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;That’s It&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;That’s all the gory details … TraceSource objects for WPF features, you can configure them with a .Config file (the big gray block of Xml back at the beginning), you need to enable them with a registry setting, and/or you can configure and enable them with the PresentationTraceSources class, and sometimes a level of “Off” gets promoted to “Warning”.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Finally, for the registry setting, you can do it from the command prompt by putting the following into a file and running it with regini:&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;hkey_current_user\software\microsoft\tracing\wpf&lt;br /&gt;&lt;br /&gt;    ManagedTracing = REG_DWORD 1&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-3732672377970945471?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/3732672377970945471/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=3732672377970945471' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/3732672377970945471'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/3732672377970945471'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2010/05/tracing-net-wpf.html' title='Tracing .net WPF'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-4648268397370378152</id><published>2010-05-19T23:15:00.003+03:00</published><updated>2010-05-19T23:38:57.722+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Trace'/><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='Debug'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>WPF &amp; Silverlight binding trace &amp; debug</title><content type='html'>A copy from http://bea.stollnitz.com/blog/?p=52 in case that this resource will vanish&lt;br /&gt;&lt;br /&gt;Data Binding can be tricky to debug. In this post, I will share the techniques I use to debug WPF bindings, including the new debugging improvements we implemented in the latest 3.5 release. I will discuss the following four techniques:&lt;br /&gt;&lt;br /&gt;    * Scanning Visual Studio’s Output window for errors.&lt;br /&gt;    * Using Trace Sources for maximum control.&lt;br /&gt;    * Using the new property introduced in WPF 3.5 PresentationTraceSources.TraceLevel.&lt;br /&gt;    * Adding a breakpoint to a Converter.&lt;br /&gt;&lt;br /&gt;The DataContext of this app is set to a new instance of Star, which is a class that contains two properties: Picture and Caption. Picture is of type BitmapImage and contains an image of the sun, which I included in the project. Caption is a string property that takes a while to be initialized (more details about this later).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Output Window&lt;br /&gt;&lt;br /&gt;In the XAML of this application, I have an Image whose Source is data bound to an incorrect property name. This is a simple scenario that causes a Binding to fail.&lt;br /&gt;&lt;br /&gt;    &lt;Image Source="{Binding Path=PictureWrong}" Width="300" Height="300" Grid.Row="0"/&gt;&lt;br /&gt;&lt;br /&gt;Every time a Binding fails, the binding engine prints an informative message in the Output window of Visual Studio. In this case, I get the following message:&lt;br /&gt;&lt;br /&gt;    System.Windows.Data Error: 35 : BindingExpression path error: ‘PictureWrong’ property not found on ‘object’ ”Star’ (HashCode=49535530)’. BindingExpression:Path=PictureWrong; DataItem=’Star’ (HashCode=49535530); target element is ‘Image’ (Name=”); target property is ‘Source’ (type ‘ImageSource’)&lt;br /&gt;&lt;br /&gt;This message should give you enough information to quickly figure out the mistake in the property name.&lt;br /&gt;&lt;br /&gt;Advantage of this technique:&lt;br /&gt;&lt;br /&gt;    * It is very easy to look at the Output window, and in most cases it’s sufficient. It should be the first approach you consider when you have a problem with your bindings.&lt;br /&gt;&lt;br /&gt;Disadvantage of this technique:&lt;br /&gt;&lt;br /&gt;    * Most real world applications print so much information to the Output window that it may be hard to find the error you’re looking for.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Trace Sources&lt;br /&gt;&lt;br /&gt;The Trace Sources solution was already around in WPF 3.0. It adds a lot more flexibility to the previous solution by allowing you to control the level of detail you care about, where you want that messages to be printed and the WPF feature you want to debug.&lt;br /&gt;&lt;br /&gt;The Trace Sources solution relies on a config file for the configuration of its behavior – the App.config file. Here is a portion of the contents of that file:&lt;br /&gt;&lt;br /&gt;    &lt;configuration&gt;&lt;br /&gt;         &lt;system.diagnostics&gt;&lt;br /&gt;            &lt;sources&gt;&lt;br /&gt;    &lt;br /&gt;            &lt;source name="System.Windows.Data" switchName="SourceSwitch" &gt;&lt;br /&gt;                &lt;listeners&gt;&lt;br /&gt;                    &lt;add name="textListener" /&gt;&lt;br /&gt;                &lt;/listeners&gt;&lt;br /&gt;            &lt;/source&gt;&lt;br /&gt;            …&lt;br /&gt;        &lt;br /&gt;            &lt;switches&gt;&lt;br /&gt;                …&lt;br /&gt;                &lt;add name="SourceSwitch" value="All" /&gt;&lt;br /&gt;            &lt;/switches&gt;&lt;br /&gt;        &lt;br /&gt;            &lt;sharedListeners&gt;&lt;br /&gt;                …&lt;br /&gt;                &lt;add name="textListener"&lt;br /&gt;                type="System.Diagnostics.TextWriterTraceListener"&lt;br /&gt;                initializeData="DebugTrace.txt" /&gt;&lt;br /&gt;                …&lt;br /&gt;            &lt;/sharedListeners&gt;&lt;br /&gt;        &lt;br /&gt;            &lt;trace autoflush="true" indentsize="4"&gt;&lt;/trace&gt;&lt;br /&gt;        &lt;br /&gt;        &lt;/system.diagnostics&gt;&lt;br /&gt;    &lt;/configuration&gt;&lt;br /&gt;&lt;br /&gt;In this file, I am specifying that:&lt;br /&gt;&lt;br /&gt;    * I want only messages generated in the Data subarea to be printed. If you’re trying to debug, for example, animations, you would instead add the area System.Windows.Media.Animation.&lt;br /&gt;    * I want as much information as possible about data binding. This was done by setting the switch to All. Other possible values are Off, Error, Warning. For a complete list, look up SourceLevels in .NET Reflector.&lt;br /&gt;    * I want the messages to be printed to an external file called DebugTrace.txt, instead of the Output Window. This file will be created in the bindebug folder for the application. If you run this application twice, the messages generated the second time will be appended to the existing messages in this file. If you don’t want this behavior, remember to delete the file before running the app.&lt;br /&gt;&lt;br /&gt;Other pre-defined listeners allow printing to the Console (ConsoleTraceListener), or to an external file in XML format (XmlWriterTraceListener).&lt;br /&gt;&lt;br /&gt;If you run the application with the settings above, you should find a DebugTrace.txt file in the bindebug directory. If you open it, you will see the data binding error we saw previously in the Output Window, plus four “Information” messages. These lower-priority messages are printed because I specified in the switch that I want all the information available about the bindings.&lt;br /&gt;&lt;br /&gt;If you want to learn more about this topic, I recommend Mike Hillberg’s blog. He wrote the best article I’ve read about Trace Sources, which I use frequently as a reference.&lt;br /&gt;&lt;br /&gt;Advantages of this technique:&lt;br /&gt;&lt;br /&gt;    * It separates the debug messages you care about from the rest of the information printed in the Output window.&lt;br /&gt;    * This solution may help you debug other areas in WPF, not just binding.&lt;br /&gt;    * You can get lower-priority messages (such as information or warnings) that are not typically printed to the Output window.&lt;br /&gt;&lt;br /&gt;Disadvantages of this technique:&lt;br /&gt;&lt;br /&gt;    * The text file (or whatever form of output you choose) will contain debug messages about all the bindings in your application. Although this is not as much clutter as the Output window, it may still require some digging for you to find exactly the information you need.&lt;br /&gt;    * It won’t help you in scenarios where your Binding actually succeeds, but you still don’t see what you expect in the UI. The first and second techniques I show here only help in scenarios where the Binding fails.&lt;br /&gt;&lt;br /&gt;Before you move on, make sure you correct the Path in the Image’s Source so that these errors won’t interfere with the ones I show next.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Trace Level – new in 3.5&lt;br /&gt;&lt;br /&gt;In order to understand this feature, let’s start by uncommenting the first TextBlock in the XAML of this application:&lt;br /&gt;&lt;br /&gt;    &lt;TextBlock Text="{Binding Path=Caption}" … /&gt;&lt;br /&gt;&lt;br /&gt;This TextBlock attempts to bind to Caption, a property whose value is slow to be initialized. In this case, I am simulating a slow data source by adding a Dispatcher timer to the constructor, but in reality this delay could have many different causes. Notice also that I am *not* raising a property changed notification when Caption changes value.&lt;br /&gt;&lt;br /&gt;    public string Caption&lt;br /&gt;    {&lt;br /&gt;        private set&lt;br /&gt;        {&lt;br /&gt;            this.caption= value;&lt;br /&gt;            //OnPropertyChanged("Caption");&lt;br /&gt;        }&lt;br /&gt;        get&lt;br /&gt;        {&lt;br /&gt;            return caption;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    public Star()&lt;br /&gt;    {&lt;br /&gt;        this.Picture = new BitmapImage(new Uri("Images\sun.jpg", UriKind.Relative));&lt;br /&gt;        this.Caption = String.Empty;&lt;br /&gt;        DispatcherTimer timer = new DispatcherTimer();&lt;br /&gt;        timer.Interval = new TimeSpan(0, 0, 3);&lt;br /&gt;        timer.Tick += new EventHandler(Timer_Tick);&lt;br /&gt;        timer.Start();&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    private void Timer_Tick(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        this.Caption = "Sun";&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;In this scenario, the Binding will succeed (it will bind to the initial value of empty string), but you don’t see what you expect to see in the UI. The unwanted behavior is caused by the fact that the events happen in an order different from what you expect: the Binding will be evaluated before Caption gets its real value. In this case, there are no errors in the Output window or DebugTrace.txt because the Binding succeeds.&lt;br /&gt;&lt;br /&gt;You can use the new debugging feature in 3.5 to debug this scenario by adding the attached property PresentationTraceSources.TraceLevel to the Binding, which can be set to None, Low, Medium and High. Since PresentationTraceSource is not in the default namespace mappings for WPF, you will have to write the following XAML:&lt;br /&gt;&lt;br /&gt;    &lt;Window …&lt;br /&gt;    xmlns:diagnostics="clr-namespace:System.Diagnostics;assembly=WindowsBase"&lt;br /&gt;    /&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;TextBlock Text="{Binding Path=Caption, diagnostics:PresentationTraceSources.TraceLevel=High}" … /&gt;&lt;br /&gt;&lt;br /&gt;If you look at the Output window, you will notice that the binding engine generated debug information for every task that may help users find problems with this particular binding:&lt;br /&gt;&lt;br /&gt;    System.Windows.Data Warning: 47 : Created BindingExpression (hash=25209742) for Binding (hash=3888474)&lt;br /&gt;    …&lt;br /&gt;    System.Windows.Data Warning: 91 : BindingExpression (hash=25209742): GetValue at level 0 from Star (hash=31609076) using RuntimePropertyInfo(Caption): ‘ ‘&lt;br /&gt;    System.Windows.Data Warning: 71 : BindingExpression (hash=25209742): TransferValue – got raw value ‘ ‘&lt;br /&gt;    System.Windows.Data Warning: 78 : BindingExpression (hash=25209742): TransferValue – using final value ‘ ‘&lt;br /&gt;&lt;br /&gt;In this case, we can scan the debug messages quickly to see that there were no errors, and look at the last few messages to understand that the value found at the Source was the empty string. This information will help you come to the conclusion that there is some timing issue with the scenario.&lt;br /&gt;&lt;br /&gt;Advantages of this technique:&lt;br /&gt;&lt;br /&gt;    * This feature is particularly useful when you know exactly which binding you want to find out more about, which is the most common scenario.&lt;br /&gt;    * It allows you to know more about bindings that succeed, which many times helps you find the mistake in your logic.&lt;br /&gt;&lt;br /&gt;Disadvantages of this technique:&lt;br /&gt;&lt;br /&gt;    * If you forget to remove the property after you found the problem, it adds to the clutter of the Output Window (which adds to the time it takes to start your application in debug mode).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Converter&lt;br /&gt;&lt;br /&gt;The last solution is extremely simple: you can simply add a no-op Converter to your binding and put a breakpoint in its Convert method. This is what this solution looks like:&lt;br /&gt;&lt;br /&gt;    &lt;TextBlock Text="{Binding Path=Caption, Converter={StaticResource converter}}" …/&gt;&lt;br /&gt;&lt;br /&gt;    public class DebuggingConverter : IValueConverter&lt;br /&gt;    {&lt;br /&gt;        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)&lt;br /&gt;        {&lt;br /&gt;            return value; // Add the breakpoint here!!&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)&lt;br /&gt;        {&lt;br /&gt;            throw new NotImplementedException("This method should never be called");&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;If you run this code and set a breakpoint inside the Convert method, you can simply hover over the “value” parameter to see what is being passed from the source to the target. In this case, you will see that “value” contains an empty string. This may help you realize that the source of your binding does not have the value you thought it had.&lt;br /&gt;&lt;br /&gt;Advantages of this technique:&lt;br /&gt;&lt;br /&gt;    * It is really easy to implement. It relies on a concept that most data binding users are familiar with.&lt;br /&gt;    * It does not depend on the Output window.&lt;br /&gt;    * It helps you find out more about scenarios where the binding doesn’t fail.&lt;br /&gt;&lt;br /&gt;Disadvantages to this technique:&lt;br /&gt;&lt;br /&gt;    * It doesn’t provide as much information as the TraceLevel technique.&lt;br /&gt;    * If the Binding fails early, the Converter may not be called.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-4648268397370378152?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/4648268397370378152/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=4648268397370378152' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/4648268397370378152'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/4648268397370378152'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2010/05/wpf-silverlight-binding-trace-debug.html' title='WPF &amp; Silverlight binding trace &amp; debug'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-5813305763984899842</id><published>2010-03-03T19:31:00.001+02:00</published><updated>2010-03-03T19:32:23.921+02:00</updated><title type='text'>C# html editor</title><content type='html'>http://stackoverflow.com/questions/394751/anyone-know-a-code-editor-i-can-embed-in-a-wpf-window-or-windows-forms&lt;br /&gt;&lt;br /&gt;scintilla &amp; sharpdevelop&lt;br /&gt;custom compiler on codeproject&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-5813305763984899842?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/5813305763984899842/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=5813305763984899842' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/5813305763984899842'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/5813305763984899842'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2010/03/c-html-editor.html' title='C# html editor'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-2739945054127812540</id><published>2009-08-31T16:30:00.000+03:00</published><updated>2009-08-31T16:31:25.082+03:00</updated><title type='text'>Free GeoCoding ?</title><content type='html'>Backup pt http://www.viawindowslive.com/Articles/VirtualEarth/Freereversegeocoding.aspx&lt;br /&gt;&lt;br /&gt;This article describes how a website VoyageMap.com utilises a free reverse geocoding &lt;br /&gt;data dump from Geonames.org&lt;br /&gt;&lt;br /&gt;I restricted the locations to worldwide cities with greater than 1000 residents. This file was available from http://www.geonames.org/ as a data dump. But you can use their free webservice as well by providing Lat and Long values to http://ws.geonames.org/findNearbyPlaceName?lat=47.3&amp;lng=9&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Free reverse geocoding by supplying Lat and Long values.&lt;br /&gt;After downloading Cities data dump and importing into my local database I set up a stored procedure to bring back locations that meet the radius parameter and passed in Lat Long values in following sql&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    SELECT TOP 3&lt;br /&gt;    Country.name as country, City.geonameid,City.name, City.latitude, City.longitude,&lt;br /&gt;    Avg(3958.75 * ACos(Sin(@Latitude/57.2958) *&lt;br /&gt;    Sin(City.Latitude/57.2958) +&lt;br /&gt;    Cos(@Latitude/57.2958) *&lt;br /&gt;    Cos(City.Latitude/57.2958) *&lt;br /&gt;    Cos(City.Longitude/57.2958 - @Longitude/57.2958))) AS miles&lt;br /&gt;    FROM&lt;br /&gt;    dbo.GeoNamesCity City&lt;br /&gt;    join dbo.GeoNamesCountry Country on City.[country code] = Country.[iso alpha2]&lt;br /&gt;    WHERE City.Longitude IS NOT NULL AND City.Longitude &lt;&gt; 0&lt;br /&gt;    AND City.Latitude IS NOT NULL AND City.Latitude &lt;&gt; 0&lt;br /&gt;    AND @Miles &gt;=&lt;br /&gt;    (&lt;br /&gt;    3958.75 * ACos(Sin(@Latitude/57.2958) *&lt;br /&gt;    Sin(City.Latitude/57.2958) +&lt;br /&gt;    Cos(@Latitude/57.2958) *&lt;br /&gt;    Cos(City.Latitude/57.2958) *&lt;br /&gt;    Cos(City.Longitude/57.2958 - @Longitude/57.2958))&lt;br /&gt;    )&lt;br /&gt;    GROUP BY Country.name, City.geonameid,City.name, City.latitude, City.longitude&lt;br /&gt;    ORDER BY miles&lt;br /&gt;  Website users can retrieve upto 3 nearest cities to add travel review by right clicking on map&lt;br /&gt;&lt;br /&gt;I used the following code to register the click event&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    map.AttachEvent("onclick",PopupMenu);&lt;br /&gt;  Following is how the event is then handled to popup a menu for users to click on to add review, you can see that left click removes the menu&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    function PopupMenu(e)&lt;br /&gt;    {&lt;br /&gt;      if (e.eventName == "onclick")&lt;br /&gt;      {&lt;br /&gt;        if (e.leftMouseButton)&lt;br /&gt;        {&lt;br /&gt;          RemovePopupMenu(e);&lt;br /&gt;        }&lt;br /&gt;        else if (e.rightMouseButton)&lt;br /&gt;        {&lt;br /&gt;          var menu = document.getElementById('popupmenu');&lt;br /&gt;          menu.style.left = e.mapX + 'px' ;&lt;br /&gt;          menu.style.top = e.mapY + 'px' ;&lt;br /&gt;          menu.style.display='block';&lt;br /&gt;          popupmenupoint = DoPixelToLL(e.clientX,e.clientY);&lt;br /&gt;        }&lt;br /&gt;      }&lt;br /&gt;    }&lt;br /&gt;   &lt;br /&gt;&lt;br /&gt;To remove the menu&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    document.getElementById('popupmenu').style.display='none'&lt;br /&gt;  I used a web service to query the database and bring back list of cities (you can also use geonames webservice rather than setup your own), the popupmenupoint variable in javascript holds the LatLong values to run against the geonames data dump.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;The site heavily uses AJAX model to give users a seamless experience&lt;br /&gt;&lt;br /&gt;Conclusion:&lt;br /&gt;For private websites on a limited budget using MapPoint API is an expensive part of retrieving locations by passing Lat Long values, however with free data sources and web services available you can easily integrate reverse lookup into your website.&lt;br /&gt;&lt;br /&gt;I would like to thank geonames.org and viavirtualearth.com to allow me to use their data and code snippets that helped in producing this website.&lt;br /&gt;&lt;br /&gt;Article contributed by Mo Majad (VoyageMap.com). Have you got something to contribute?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-2739945054127812540?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/2739945054127812540/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=2739945054127812540' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/2739945054127812540'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/2739945054127812540'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2009/08/free-geocoding.html' title='Free GeoCoding ?'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-5178687084620036780</id><published>2009-06-13T23:28:00.010+03:00</published><updated>2009-06-13T23:34:53.121+03:00</updated><title type='text'>JX4201BH &amp; JX4201BH 2 Digit LED Display Datasheet tips</title><content type='html'>10 pins double digits. The pins are counted from left to right down up counter clockwise facing the part 8.8.&lt;br /&gt;Digits are shown by providing current between 5,6 and [1-4,7-10]&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-5178687084620036780?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/5178687084620036780/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=5178687084620036780' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/5178687084620036780'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/5178687084620036780'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2009/06/jx4201bh-jx4201bh-2-digit-led-display.html' title='JX4201BH &amp; JX4201BH 2 Digit LED Display Datasheet tips'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-8624213463003498152</id><published>2009-02-25T14:09:00.002+02:00</published><updated>2009-02-25T14:32:32.156+02:00</updated><title type='text'>Windows Mobile Emulator network</title><content type='html'>Microsoft Pocket PC Emulator and Network&lt;br /&gt;&lt;br /&gt;If you have to develop a software with Microsoft Visual Studio 2005 for a mobile device (for example Pocket PC 2003) which has to access to your network (local area or internet) you must enable the support for the network into the emulator. These are the steps:&lt;br /&gt;&lt;br /&gt;   1. Download and install the Virtual Machine Network Driver for Microsoft Device Emulator at this address.&lt;br /&gt;      I suggest to do the setup with Visual Studio 2005 and the emulator turned off.&lt;br /&gt;   2. From the Network Settings select the Local Area Connection, right click and select Properties, check the box near Virtual Machine Network Services&lt;br /&gt;   3. In Visual Studio open Tools -&gt; Options&lt;br /&gt;   4. Open the Device Tools -&gt; Devices node&lt;br /&gt;   5. Select Pocket PC 2003 Emulator and click Properties&lt;br /&gt;   6. From the Transport section select the TCP Connect Transport&lt;br /&gt;   7. Click the Configure button and select Obtain an IP address automatically using ActiveSync, then close the dialog box&lt;br /&gt;   8. Click Emulator Options..., tab Network, check the box Enable NE2000 PCMIA network adapter and bind to: and from the drop down list select your network card&lt;br /&gt;   9. Close all the dialog boxes, run your application, in the emulator open then File -&gt; Configure dialog box&lt;br /&gt;  10. Check the box or verify the state of the Enable NE2000 PCMIA network adapter and bind to: box, it must be checked&lt;br /&gt;&lt;br /&gt;Now from your software you can use the code to connect to internet, databases servers and so on.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-8624213463003498152?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/8624213463003498152/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=8624213463003498152' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/8624213463003498152'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/8624213463003498152'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2009/02/windows-mobile-emulator-network.html' title='Windows Mobile Emulator network'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-2588884860022340105</id><published>2009-02-03T09:17:00.003+02:00</published><updated>2011-03-17T23:33:16.615+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Alone in the dark - mutex use for single instance of application</title><content type='html'>Drawback is a denial of service approach&lt;br /&gt;&lt;pre class="brush: csharp"&gt;&lt;br /&gt;static class Program&lt;br /&gt;{&lt;br /&gt; [STAThread]&lt;br /&gt; static void Main()&lt;br /&gt; {&lt;br /&gt;  bool onlyInstance = false;&lt;br /&gt;  string mutexName = AssemblyGuid;&lt;br /&gt;  // if you want your app to be limited to a single instance across ALL SESSIONS (multiple users &amp;amp; terminal services), then use the following line instead:&lt;br /&gt;  // string mutexName = String.Format(&amp;quot;Global\\{0}&amp;quot;, AssemblyGuid);&lt;br /&gt;  Mutex mutex = new Mutex(true, mutexName, out onlyInstance);&lt;br /&gt;  if (!onlyInstance) {&lt;br /&gt;   IntPtr hwndFirstInstance = WinApi.FindWindow(null, applicationName); // For FindWindow to work, applicationName must be the same as the title (the Text property) of your MainForm.&lt;br /&gt;   WinApi.PostMessage(&lt;br /&gt;    hwndFirstInstance,&lt;br /&gt;    WinApi.WM_SHOWFIRSTINSTANCE,&lt;br /&gt;    IntPtr.Zero,&lt;br /&gt;    IntPtr.Zero);&lt;br /&gt;   return;&lt;br /&gt;  }&lt;br /&gt;  Application.Run(new MainForm);&lt;br /&gt;  GC.KeepAlive(mutex);&lt;br /&gt; }&lt;br /&gt; const string applicationName = &amp;quot;YourApplicationNameGoesHere&amp;quot;;&lt;br /&gt; static public string ApplicationName&lt;br /&gt; {&lt;br /&gt;  get { return applicationName; } // You could use an Assembly Attribute Accessor instead of a variable, but it involves a bit more code.&lt;br /&gt; }&lt;br /&gt; static public string AssemblyGuid&lt;br /&gt; {&lt;br /&gt;  get&lt;br /&gt;  {&lt;br /&gt;   object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(System.Runtime.InteropServices.GuidAttribute), false);&lt;br /&gt;   if (attributes.Length == 0) {&lt;br /&gt;    return String.Empty;&lt;br /&gt;   }&lt;br /&gt;   return ((System.Runtime.InteropServices.GuidAttribute)attributes[0]).Value;&lt;br /&gt;  }&lt;br /&gt; } &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class WinApi&lt;br /&gt;{&lt;br /&gt; public static readonly int WM_SHOWFIRSTINSTANCE = RegisterWindowMessage(&amp;quot;WM_SHOWFIRSTINSTANCE&amp;quot;);&lt;br /&gt;&lt;br /&gt; [DllImport(&amp;quot;user32&amp;quot;)]&lt;br /&gt; public static extern bool PostMessage(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam);&lt;br /&gt; &lt;br /&gt; [DllImport(&amp;quot;user32&amp;quot;)]&lt;br /&gt; public static extern int RegisterWindowMessage(string message);&lt;br /&gt; &lt;br /&gt; [DllImport(&amp;quot;user32.dll&amp;quot;)]&lt;br /&gt; public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);&lt;br /&gt; &lt;br /&gt; [DllImport(&amp;quot;user32.dll&amp;quot;)]&lt;br /&gt; public static extern bool SetForegroundWindow(IntPtr hWnd);&lt;br /&gt; &lt;br /&gt; [DllImport(&amp;quot;user32.dll&amp;quot;)]&lt;br /&gt; public static extern IntPtr FindWindow (string lpClassName, string lpWindowName);&lt;br /&gt;&lt;br /&gt; public static void ShowToFront(string windowName)&lt;br /&gt; {&lt;br /&gt;  IntPtr window = FindWindow(null, windowName);&lt;br /&gt;  ShowWindow(window, 1);&lt;br /&gt;  SetForegroundWindow(window);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public partial class MainForm : System.Windows.Forms.Form&lt;br /&gt;{&lt;br /&gt;        bool minimizedToTray;&lt;br /&gt;&lt;br /&gt; public MainForm()&lt;br /&gt; {&lt;br /&gt;  InitializeComponent();&lt;br /&gt;  this.Text = Program.ApplicationName;&lt;br /&gt; }&lt;br /&gt;        private void btnMinToTray_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;  MinimizeToTray();&lt;br /&gt;        } &lt;br /&gt;        void MinimizeToTray()&lt;br /&gt;        {&lt;br /&gt;  notifyIcon = new NotifyIcon();&lt;br /&gt;  notifyIcon.Click += new EventHandler(NotifyIconClick);&lt;br /&gt;  notifyIcon.Icon = this.Icon;&lt;br /&gt;  notifyIcon.Text = Program.ApplicationName;&lt;br /&gt;  notifyIcon.Visible = true;&lt;br /&gt;  this.ShowInTaskbar = false;&lt;br /&gt;  this.Hide();&lt;br /&gt;  minimizedToTray = true;&lt;br /&gt;        }&lt;br /&gt;        public void ShowWindow()&lt;br /&gt;        {&lt;br /&gt;  if (minimizedToTray) {&lt;br /&gt;   notifyIcon.Visible = false;&lt;br /&gt;   this.ShowInTaskbar = true;&lt;br /&gt;   this.Show();&lt;br /&gt;   minimizedToTray = false;&lt;br /&gt;  } else {&lt;br /&gt;   WinApi.ShowToFront(this.Text);&lt;br /&gt;  }&lt;br /&gt;        }&lt;br /&gt;        void NotifyIconOpen(Object sender, System.EventArgs e)&lt;br /&gt;        {&lt;br /&gt;  ShowWindow();&lt;br /&gt;        }&lt;br /&gt; protected override void WndProc(ref Message message)&lt;br /&gt; {&lt;br /&gt;  if (message.Msg == WinApi.WM_SHOWFIRSTINSTANCE) {&lt;br /&gt;   ShowWindow();&lt;br /&gt;  }&lt;br /&gt;  base.WndProc(ref message);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-2588884860022340105?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/2588884860022340105/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=2588884860022340105' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/2588884860022340105'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/2588884860022340105'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2009/02/alone-in-dark-mutex-use-for-single.html' title='Alone in the dark - mutex use for single instance of application'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-582950004777269071</id><published>2009-01-29T16:42:00.001+02:00</published><updated>2009-01-29T16:44:07.693+02:00</updated><title type='text'>SQL Server triggers used to prevent users to modify data</title><content type='html'>IF  EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[InterzicereModificari]'))&lt;br /&gt;DROP TRIGGER [InterzicereModificari]&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;CREATE TRIGGER dbo.DenyWrite_ViramenteAntet &lt;br /&gt;   ON  [dbo].[Viramente - antet]&lt;br /&gt;   AFTER INSERT,DELETE,UPDATE&lt;br /&gt;AS &lt;br /&gt;BEGIN&lt;br /&gt; RAISERROR ('Nu mai aveti dreptul de a modifica din acest program', 16, 1);&lt;br /&gt;END&lt;br /&gt;GO&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-582950004777269071?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/582950004777269071/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=582950004777269071' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/582950004777269071'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/582950004777269071'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2009/01/sql-server-triggers-used-to-prevent.html' title='SQL Server triggers used to prevent users to modify data'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-3290556277794457453</id><published>2009-01-16T11:55:00.005+02:00</published><updated>2011-03-17T23:35:31.148+02:00</updated><title type='text'>MemoryDictionaryCache reminder</title><content type='html'>&lt;pre class="brush: csharp"&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt; ICache&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;void&lt;/span&gt; Reset();&lt;br /&gt;            &lt;span class="kwrd"&gt;void&lt;/span&gt; Load();&lt;br /&gt;            &lt;span class="kwrd"&gt;string&lt;/span&gt; LoadMessage { get; set; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; MemoryDictionaryCache&amp;lt;T, Z&amp;gt; : ICache &lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;public&lt;/span&gt; MemoryDictionaryCache(Func&amp;lt;Dictionary&amp;lt;T, Z&amp;gt;&amp;gt; loadCache, &lt;span class="kwrd"&gt;string&lt;/span&gt; loadMessage, Func&amp;lt;Dictionary&amp;lt;T,Z&amp;gt;, T, Z&amp;gt; retrieveValue)&lt;br /&gt;            {&lt;br /&gt;                _load = loadCache;&lt;br /&gt;                LoadMessage = loadMessage;&lt;br /&gt;                _retrieveValue = retrieveValue;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;private&lt;/span&gt; Func&amp;lt;Dictionary&amp;lt;T, Z&amp;gt;&amp;gt; _load;&lt;br /&gt;            Func&amp;lt;Dictionary&amp;lt;T, Z&amp;gt;, T, Z&amp;gt; _retrieveValue;&lt;br /&gt;            &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; LoadMessage { get; set; }&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;private&lt;/span&gt; Dictionary&amp;lt;T, Z&amp;gt; _cache = &lt;span class="kwrd"&gt;null&lt;/span&gt;;&lt;br /&gt;            &lt;span class="kwrd"&gt;private&lt;/span&gt; Dictionary&amp;lt;T, Z&amp;gt; Cache&lt;br /&gt;            {&lt;br /&gt;                get&lt;br /&gt;                {&lt;br /&gt;                    &lt;span class="kwrd"&gt;if&lt;/span&gt; (_cache == &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br /&gt;                        Load();&lt;br /&gt;                    &lt;span class="kwrd"&gt;return&lt;/span&gt; _cache;&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Reset()&lt;br /&gt;            {&lt;br /&gt;                _cache = &lt;span class="kwrd"&gt;null&lt;/span&gt;;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Load()&lt;br /&gt;            {&lt;br /&gt;                &lt;span class="kwrd"&gt;using&lt;/span&gt; (var waitWindow = &lt;span class="kwrd"&gt;new&lt;/span&gt; WaitWindow(LoadMessage ?? &lt;span class="str"&gt;"Asteptati incarcarea datelor"&lt;/span&gt;))&lt;br /&gt;                {&lt;br /&gt;                    _cache = _load();&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;public&lt;/span&gt; Z GetValue(T forKey)&lt;br /&gt;            {&lt;br /&gt;                &lt;span class="kwrd"&gt;return&lt;/span&gt; _retrieveValue(Cache, forKey);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; Dictionary&amp;lt;Type, ICache&amp;gt; _caches = &lt;span class="kwrd"&gt;new&lt;/span&gt; Dictionary&amp;lt;Type, ICache&amp;gt;();&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Initialize()&lt;br /&gt;        {&lt;br /&gt;            _caches.Add(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(ContractID), &lt;span class="kwrd"&gt;new&lt;/span&gt; MemoryDictionaryCache&amp;lt;ContractID, ContractEntity&amp;gt;(&lt;br /&gt;                ()=&amp;gt;&lt;span class="kwrd"&gt;new&lt;/span&gt; Dictionary&amp;lt;ContractID, ContractEntity&amp;gt;(),&lt;br /&gt;                &lt;span class="str"&gt;"Incarc contractele"&lt;/span&gt;,&lt;br /&gt;                (dic, contractID)=&amp;gt;dic.GetValue(contractID)));&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; ContractEntity GetContractul(ContractID contractID)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; ((MemoryDictionaryCache&amp;lt;ContractID, ContractEntity&amp;gt;)_caches[&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(ContractID)]).GetValue(contractID);&lt;br /&gt;        }&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-3290556277794457453?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/3290556277794457453/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=3290556277794457453' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/3290556277794457453'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/3290556277794457453'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2009/01/reminder.html' title='MemoryDictionaryCache reminder'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-8224820211131996443</id><published>2008-12-12T10:53:00.002+02:00</published><updated>2008-12-12T10:58:12.784+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Interesting'/><category scheme='http://www.blogger.com/atom/ns#' term='Gadgets'/><title type='text'>Toys for boys</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_Yp-_3i1VVgk/SUIncmMwFTI/AAAAAAAAAk0/6yU6R5e1zkA/s1600-h/ubw32.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 200px; height: 62px;" src="http://3.bp.blogspot.com/_Yp-_3i1VVgk/SUIncmMwFTI/AAAAAAAAAk0/6yU6R5e1zkA/s200/ubw32.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5278825085475493170" /&gt;&lt;/a&gt;&lt;br /&gt;I can't wait for grab something like this &lt;a href="http://www.sparkfun.com/commerce/product_info.php?products_id=8971"&gt;toy for programmers&lt;/a&gt;&lt;br /&gt;Some of the specs:&lt;br /&gt;&lt;br /&gt;    * 80MHz&lt;br /&gt;    * 512K flash storage&lt;br /&gt;    * 32K RAM&lt;br /&gt;    * 3 pushbuttons&lt;br /&gt;    * 5 LEDs&lt;br /&gt;    * 5V voltage regulator&lt;br /&gt;    * Terminal emulator command interface&lt;br /&gt;    * USB bootloader&lt;br /&gt;    * SMD resistor pads for every I/O pin&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-8224820211131996443?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/8224820211131996443/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=8224820211131996443' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/8224820211131996443'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/8224820211131996443'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2008/12/toys-for-boys.html' title='Toys for boys'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_Yp-_3i1VVgk/SUIncmMwFTI/AAAAAAAAAk0/6yU6R5e1zkA/s72-c/ubw32.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-4974200995565289892</id><published>2008-12-10T10:13:00.002+02:00</published><updated>2008-12-10T10:30:39.048+02:00</updated><title type='text'>Lambda expressions closure fix</title><content type='html'>Is quite a time from my last post. My wife and I were blessed with a baby boy, and the time frozen for me, between the child needs and the job.&lt;br /&gt;&lt;br /&gt;Today i had read an article very interesting about closure fix in Enumerator context. &lt;br /&gt;http://geekswithblogs.net/jolson/archive/2008/06/13/lambdas---know-your-closures.aspx&lt;br /&gt;below is a copy paste of it in case that page disappear:&lt;br /&gt;&lt;br /&gt;Lambdas - Know Your Closures&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In this post I want to discuss with you the importance of realizing how lambdas work (and why you should care). Let's dive right in with some code.&lt;br /&gt;&lt;br /&gt;Given the following code snippet, what would you expect the output to be (no cheating :P)?&lt;br /&gt;&lt;br /&gt;            var actions = new List&lt;Action&gt;();&lt;br /&gt;&lt;br /&gt;            for (int i = 0; i &lt; 10; i++)&lt;br /&gt;            {&lt;br /&gt;                actions.Add(() =&gt; Console.WriteLine(i));&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            foreach (var action in actions)&lt;br /&gt;            {&lt;br /&gt;                action();&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;Would you believe me if I told you this is the output you get?&lt;br /&gt;&lt;br /&gt;    10&lt;br /&gt;    10&lt;br /&gt;    10&lt;br /&gt;    10&lt;br /&gt;    10&lt;br /&gt;    10&lt;br /&gt;    10&lt;br /&gt;    10&lt;br /&gt;    10&lt;br /&gt;    10&lt;br /&gt;&lt;br /&gt;At first glance, one might expect this output:&lt;br /&gt;&lt;br /&gt;    0&lt;br /&gt;    1&lt;br /&gt;    2&lt;br /&gt;    3&lt;br /&gt;    4&lt;br /&gt;    5&lt;br /&gt;    6&lt;br /&gt;    7&lt;br /&gt;    8&lt;br /&gt;    9&lt;br /&gt;&lt;br /&gt;But all tens are output instead. Why does this happen? Let's crank open Reflector and find out why...&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;The first thing you'll notice is that the compiler has created a helper class to enable the closure we have. This helper class created by the compiler contains a local variable that we use to iterate over and a method that our delegate is contained within. This helper class is especially interesting because it is where the magic happens.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;[CompilerGenerated]&lt;br /&gt;private sealed class &lt;&gt;c__DisplayClass2&lt;br /&gt;{&lt;br /&gt;    // Fields&lt;br /&gt;    public int i;&lt;br /&gt;&lt;br /&gt;    // Methods&lt;br /&gt;    public void &lt;Main&gt;b__0()&lt;br /&gt;    {&lt;br /&gt;        Console.WriteLine(this.i);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Rather than diving into MSIL, let's look at some pseudo-code of what the compiler _actually_ executes with the original code above (based on the generated MSIL):&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;var actions = new List&lt;Action&gt;();&lt;br /&gt;&lt;br /&gt;&lt;&gt;c__DisplayClass2 localFrame = new &lt;&gt;c__DisplayClass2();&lt;br /&gt;for (localFrame.i = 0; localFrame.i &lt; 10; localFrame.i++)&lt;br /&gt;{&lt;br /&gt; actions.Add(localFrame.&lt;Main&gt;b__0);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;foreach (var action in actions)&lt;br /&gt;{&lt;br /&gt; action();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Perhaps now you can see where the problem is. The "problem" in our original code exists because of the scope that our closures are defined. The local index from our for loop is now stored in our helper class &lt;&gt;c__DisplayClass2. And the code that is executed by the action is contained within the compiler generated &lt;Main&gt;b__0() method now. So the Console.WriteLine() method now uses the local variable from &lt;&gt;c__DisplayClass2 when it is executed.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;So while we are looping through building all our actions, we are also incrementing the property i in localFrame (an instance of &lt;&gt;c__DisplayClass2). Then at the end when we are actually executing the actions, the &lt;Main&gt;b__0() is called and uses the local i property (which by this time, has already been incremented to 10 from our loop). And that's why every action we execute prints "10" instead of the 0 through 9 like we expected.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;So, why do you need to know how these work? Take the following code that outputs items from an array of strings:&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;            var actions = new List&lt;Action&gt;();&lt;br /&gt;            string[] urls = &lt;br /&gt;            { &lt;br /&gt;                "http://www.url.com", &lt;br /&gt;                "http://www.someurl.com", &lt;br /&gt;                "http://www.someotherurl.com", &lt;br /&gt;                "http://www.yetanotherurl.com" &lt;br /&gt;            };&lt;br /&gt;&lt;br /&gt;            for (int i = 0; i &lt; urls.Length; i++)&lt;br /&gt;            {&lt;br /&gt;                actions.Add(() =&gt; Console.WriteLine(urls[i]));&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            foreach (var action in actions)&lt;br /&gt;            {&lt;br /&gt;                action();&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;This code looks pretty innocuous. Our bounds are protected, and we just index into our array to output a string. But, is that what we're really doing? Remember how closures work from above. The actual thing that happens when I run this code is this:&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Confusing&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Interesting. Even though our index variable should only even be less than the length of our url array, an exception is thrown because the index variable is actually equal to the length of our url array (and hence outside of the bounds thanks to 0-based indices).&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Well, that wasn't what we were probably expecting. But now that we are having this "problem", what is the easiest way to resolve it? Remember that the problem is happening because of the scope of the variable within our closure. So to fix this, we can essentially declare a temporary variable that is unique in scope to this specific iteration through our array:&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;            for (int i = 0; i &lt; urls.Length; i++)&lt;br /&gt;            {&lt;br /&gt;                string localUrl = urls[i];&lt;br /&gt;                actions.Add(() =&gt; Console.WriteLine(localUrl));&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;And now the code is fixed.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Understanding how lambdas work is especially important when you start developing with a library that leverages lambdas heavily like LINQ does, or Parallel Extensions to the .NET Framework. And don't worry, even those people that know how lambdas work occasionally get bitten by this behavior.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-4974200995565289892?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/4974200995565289892/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=4974200995565289892' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/4974200995565289892'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/4974200995565289892'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2008/12/lambda-expressions-closure-fix.html' title='Lambda expressions closure fix'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-4124436391048746386</id><published>2008-07-22T10:11:00.002+03:00</published><updated>2008-07-22T10:16:00.312+03:00</updated><title type='text'>A good laugh speech recognition in Vista</title><content type='html'>I know how hard is to make such a tool, but I can't stop to lol about outcome&lt;br /&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/2Y_Jp6PxsSQ&amp;hl=en&amp;fs=1"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/2Y_Jp6PxsSQ&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/KyLqUf4cdwc&amp;hl=en&amp;fs=1"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/KyLqUf4cdwc&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-4124436391048746386?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/4124436391048746386/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=4124436391048746386' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/4124436391048746386'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/4124436391048746386'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2008/07/good-laugh.html' title='A good laugh speech recognition in Vista'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-6721777915480022033</id><published>2008-05-22T21:16:00.004+03:00</published><updated>2008-05-22T21:39:42.219+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Robotics'/><title type='text'>MRSD how to change default port for host projects</title><content type='html'>[MRSD(Microsoft Robotics Developer Studio) installation folder]\tools\Templates\CSharp\ contains a zip file named CS_Hosting_2.0.730.3.zip that contains a template for a c# host project. Change the program.cs in that archive to use the new ports instead of defaults 50000 and 50001.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-6721777915480022033?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/6721777915480022033/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=6721777915480022033' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/6721777915480022033'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/6721777915480022033'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2008/05/mrsd-how-to-change-default-port-for.html' title='MRSD how to change default port for host projects'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-538308645428052293</id><published>2008-05-22T09:45:00.010+03:00</published><updated>2008-05-23T10:52:17.893+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming tools'/><title type='text'>A critic over your shoulder</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_Yp-_3i1VVgk/SDUYClHJ9VI/AAAAAAAAAAc/h3AwvwoyheI/s1600-h/PexWeb.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_Yp-_3i1VVgk/SDUYClHJ9VI/AAAAAAAAAAc/h3AwvwoyheI/s200/PexWeb.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5203091377097405778" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://research.microsoft.com/pex/"&gt;Pex&lt;/a&gt; could be the critic you need for your code. If you don't have a friend to criticize when you make a mistake or to laugh his ass off, then you should find one. Pex is a testing engine, that make code analysis and generate unit tests accordingly. The final scope is to increase the quality of your unit tests by raising your test code coverage.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-538308645428052293?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/538308645428052293/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=538308645428052293' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/538308645428052293'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/538308645428052293'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2008/05/critic-over-your-shoulder.html' title='A critic over your shoulder'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_Yp-_3i1VVgk/SDUYClHJ9VI/AAAAAAAAAAc/h3AwvwoyheI/s72-c/PexWeb.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-3048753121041328087</id><published>2008-05-21T17:05:00.004+03:00</published><updated>2008-12-10T10:33:32.871+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Smat tags in runtime  Windows.Forms</title><content type='html'>A very interesting topic about&lt;a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2081315&amp;SiteID=1&amp;pageid=0"&gt;Smart tags in runtime on Windows.Forms&lt;/a&gt;. I just made a copy:&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;You have to create a DesignerOptions with UseSmartTags property set to true, add the DesignerOptions to DesignerOptionService, after which add this service to the DesignerSurface, I write the following sample which host a TextBox and a DataGridView control on the designer surface.&lt;br /&gt;&lt;br /&gt;Code Snippet&lt;br /&gt;&lt;br /&gt;namespace Sample25&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;    public partial class Form2 : Form&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        public Form2()&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            InitializeComponent();&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;        private void Form2_Load(object sender, EventArgs e)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            myDesignSurface surface = new myDesignSurface();&lt;br /&gt;&lt;br /&gt;            IDesignerHost host = surface.GetService(typeof(IDesignerHost)) as IDesignerHost;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;            UserControl root = host.CreateComponent(typeof(UserControl)) as UserControl;&lt;br /&gt;&lt;br /&gt;            root.Width = this.panel1.Width - 30;&lt;br /&gt;&lt;br /&gt;            root.Height = this.panel1.Height - 30;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;            TextBox textbox = host.CreateComponent(typeof(TextBox)) as TextBox;&lt;br /&gt;&lt;br /&gt;            textbox.Location = new Point(100, 90);&lt;br /&gt;&lt;br /&gt;            textbox.Text = "textbox";&lt;br /&gt;&lt;br /&gt;            root.Controls.Add(textbox);&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;            DataGridView dgv = host.CreateComponent(typeof(DataGridView)) as DataGridView;&lt;br /&gt;&lt;br /&gt;            dgv.Location = new Point(100, 130);&lt;br /&gt;&lt;br /&gt;            dgv.Text = "DataGridView";&lt;br /&gt;&lt;br /&gt;            root.Controls.Add(dgv);&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;            Control c = surface.View as Control;&lt;br /&gt;&lt;br /&gt;            c.Dock = DockStyle.Fill;&lt;br /&gt;&lt;br /&gt;            c.BackColor = Color.White;&lt;br /&gt;&lt;br /&gt;            c.Parent = this.panel1;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;    class myDesignSurface : DesignSurface&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        public myDesignSurface()&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            MyDesignerOptionService optionService = new MyDesignerOptionService();&lt;br /&gt;&lt;br /&gt;            this.ServiceContainer.AddService(typeof(DesignerOptionService), optionService);&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;    class MyDesignerOptionService : DesignerOptionService&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        protected override void PopulateOptionCollection(DesignerOptionCollection options)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            if (options.Parent == null)&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                DesignerOptionCollection doc =&lt;br /&gt;                    this.CreateOptionCollection(options, "WindowsFormsDesigner", null);&lt;br /&gt;&lt;br /&gt;                DesignerOptions doptions = new DesignerOptions();&lt;br /&gt;&lt;br /&gt;                doptions.UseSmartTags = true;&lt;br /&gt;&lt;br /&gt;                this.CreateOptionCollection(doc, "General", doptions);&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-3048753121041328087?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/3048753121041328087/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=3048753121041328087' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/3048753121041328087'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/3048753121041328087'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2008/05/smat-tags-in-runtime-windowsforms.html' title='Smat tags in runtime  Windows.Forms'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-5050016843983886327</id><published>2008-05-21T11:37:00.008+03:00</published><updated>2008-05-21T12:22:55.523+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Robotics'/><title type='text'>Changing learning curve ... is developer's learning effort</title><content type='html'>How easy is to change the learning curve for the users of your programs? The answer lays on your response to &lt;span style="font-style:italic;"&gt;What is ergonomics?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Example of not to do: to name &lt;span style="font-weight:bold;"&gt;Arbiter.Choise&lt;&gt;()&lt;/span&gt; (is suggesting a decision to make by using a predicate ) instead of &lt;span style="font-weight:bold;"&gt;Arbiter.TakeFirstArrivingFrom&lt;&gt;()&lt;/span&gt; (more clear for the reader) or &lt;span style="font-weight:bold;"&gt;Arbiter.FirstReceivedFrom()&lt;/span&gt; or even &lt;span style="font-weight:bold;"&gt;Arbiter.Any&lt;&gt;()&lt;/span&gt; sounds better.&lt;br /&gt;&lt;br /&gt;I polluted my mind with &lt;a href="http://www.codeguru.com/cpp/cpp/algorithms/math/article.php/c15171__1/"&gt;Implementing a Simple 2D Object Tracker&lt;/a&gt;. I'm sorry right now, because i want to make my own system of recognition, or at least to take the time to think the best approach. After that to see other programmer's solutions.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-5050016843983886327?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/5050016843983886327/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=5050016843983886327' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/5050016843983886327'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/5050016843983886327'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2008/05/changing-learning-curve-is-developers.html' title='Changing learning curve ... is developer&apos;s learning effort'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-5740041465771262930</id><published>2008-05-20T10:15:00.003+03:00</published><updated>2008-05-20T10:32:25.671+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Interesting'/><title type='text'>Nature is fighting back - the suicide ants</title><content type='html'>&lt;a href="http://www.networkworld.com/cgi-bin/mailto/x.cgi?pagetosend=/export/home/httpd/htdocs/news/2008/051508-nasa-moves-to-save-computers.html&amp;pagename=/news/2008/051508-nasa-moves-to-save-computers.html&amp;pageurl=http://www.networkworld.com/news/2008/051508"&gt;NASA moves to save computers from swarming ants&lt;/a&gt;.&lt;br /&gt;I'm remember &lt;span style="font-style:italic;"&gt;Ants&lt;/span&gt; a great animation movie and the &lt;span style="font-style:italic;"&gt;Ants&lt;/span&gt; and &lt;span style="font-style:italic;"&gt;The Day of the ants&lt;/span&gt; by Webber great sci-fi books all in category must see and read&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-5740041465771262930?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/5740041465771262930/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=5740041465771262930' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/5740041465771262930'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/5740041465771262930'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2008/05/nature-is-fighting-back-suicide-ants.html' title='Nature is fighting back - the suicide ants'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-8572101810753835809</id><published>2008-05-20T08:47:00.013+03:00</published><updated>2008-05-20T17:29:10.020+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Robotics'/><category scheme='http://www.blogger.com/atom/ns#' term='Interesting'/><category scheme='http://www.blogger.com/atom/ns#' term='Other tools'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Falling in the pit of success</title><content type='html'>First service that control a robot. Is very simple in his nature, but is the first little big step.&lt;br /&gt;&lt;br /&gt;Prepare yourself for staring at &lt;a href="http://www.youtube.com/watch?v=W1czBcnX1Ww"&gt;amazing movie - great work Boston Dynamics&lt;/a&gt;&lt;br /&gt;&lt;object width="425" height="355"&gt;&lt;param name="movie" value="http://www.youtube.com/v/W1czBcnX1Ww&amp;hl=en"&gt;&lt;/param&gt;&lt;param name="wmode" value="transparent"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/W1czBcnX1Ww&amp;hl=en" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;At this time I'm a &lt;a href="http://www.doolwind.com/index.php?page=11"&gt;PHSC&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.infoworld.com/archives/emailPrint.jsp?R=printThis&amp;A=/article/08/05/19/Popular-open-source-spam-filter-gets-boost_1.html"&gt;SpamAssasin with the Traffic control tool&lt;/a&gt; a good news.&lt;br /&gt;&lt;br /&gt;Some steganography (let the user to hide data in plain view) tools &lt;a href="http://sourceforge.net/projects/hide-in-picture/"&gt;Hide in Picture&lt;/a&gt;, &lt;a href="http://wbstego.wbailer.com/"&gt;PDF's, HTML files or bitmaps&lt;/a&gt;, &lt;a href="http://www.petitcolas.net/fabien/steganography/mp3stego/"&gt;mp3stego&lt;/a&gt;&lt;br /&gt;To hide a folder, just rename it to Alt+255, change the icon representation to a blank icon.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.codeproject.com/KB/cs/mouse_gesture.aspx"&gt;Mouse gesture&lt;/a&gt; in C#, to think of some usage in the future solutions.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-8572101810753835809?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/8572101810753835809/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=8572101810753835809' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/8572101810753835809'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/8572101810753835809'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2008/05/falling-in-pit-of-success.html' title='Falling in the pit of success'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-9042069224677394289</id><published>2008-05-18T09:42:00.013+03:00</published><updated>2008-05-20T17:04:44.494+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Robotics'/><title type='text'>Starting is hard sometimes</title><content type='html'>I just watched the architecture getting started video for Microsoft Robotics Studio (MSRS) and decided to play with Visual Programming Language for MSRS. Is very intuitive and I made a hello world application in 30 seconds. But when tried to run I got: &lt;blockquote&gt;&lt;em&gt;A valid transport port was not specified.&lt;/em&gt;&lt;/blockquote&gt; This setback is easy to resolve by using &lt;blockquote&gt;netstat -a -o&lt;/blockquote&gt; and see if the ports are used already by your system and make a decision if you want to terminate the program that is using the ports or to use other ports. To change what ports to use is fairly simple. From the &lt;strong&gt;Run&lt;/strong&gt; menu choose &lt;strong&gt;Port Settings&lt;/strong&gt; and enter the desired unused port numbers (let say 55004 and 55504).&lt;br /&gt;Running again I got other error:&lt;br /&gt;&lt;blockquote&gt;&lt;em&gt;DsspForwarder:CreateRequestFrowarder. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: Transport not found in local ServiceEnvironment instance, for scheme:http&lt;/em&gt;&lt;/blockquote&gt; ouch. Error that is hiding other error in other service:&lt;br /&gt;&lt;blockquote&gt;&lt;em&gt;Cannot create a TCP Listener.&lt;/em&gt;&lt;/blockquote&gt;  Error was raised because my operating system was Vista, and UAC (User Account Control) is on. The right solution for this is to use httpreserve, not to disable the UAC. I run DSS Command Prompt from the menu group Microsoft Robotics Developer Studio as administrator and executed the command &lt;strong&gt;httpreserve /port:55004 /user:me&lt;/strong&gt; ( 55004 is the http port and me is current vista user logged in). After this application run smoothly and a hello appear.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-9042069224677394289?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/9042069224677394289/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=9042069224677394289' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/9042069224677394289'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/9042069224677394289'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2008/05/starting-is-hard-sometimes.html' title='Starting is hard sometimes'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-1386100005333468980</id><published>2008-05-16T09:58:00.004+03:00</published><updated>2008-05-16T10:58:48.504+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Interesting'/><category scheme='http://www.blogger.com/atom/ns#' term='Other tools'/><title type='text'>Social integration</title><content type='html'>Google &lt;a href="http://translate.google.com/translate_t"&gt;http://translate.google.com/translate_t&lt;/a&gt; now allow me to translate text from English in Romanian. Is not perfect, but what is?&lt;br /&gt;&lt;br /&gt;A very funny toy &lt;a href="http://phun.cs.umu.se/wiki/Download"&gt;http://phun.cs.umu.se/wiki/Download&lt;/a&gt; to learn physics.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.flazx.com"&gt;http://www.FlazX.com&lt;/a&gt; is a very nice site, it makes me to want to live forever.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-1386100005333468980?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/1386100005333468980/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=1386100005333468980' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/1386100005333468980'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/1386100005333468980'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2008/05/social-integration.html' title='Social integration'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-36425374095383619</id><published>2008-05-15T11:20:00.004+03:00</published><updated>2008-05-16T10:57:42.610+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Gadgets'/><title type='text'>Future is now</title><content type='html'>Microsoft TouchWall is very impressive and is more practical then Surface table.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-36425374095383619?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/36425374095383619/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=36425374095383619' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/36425374095383619'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/36425374095383619'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2008/05/future-is-now.html' title='Future is now'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2751800870260593323.post-805646396160123516</id><published>2008-05-15T00:47:00.004+03:00</published><updated>2008-05-16T09:45:26.530+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming tools'/><title type='text'>Sharping the axe before cutting the tree</title><content type='html'>LinqPad from &lt;a href="http://www.linqpad.net"&gt;http://www.linqpad.net&lt;/a&gt; is a nice learning tool. It comes with a challenge. I will subscribe to it.&lt;br /&gt;&lt;br /&gt;It seems that saving(inserting) bulk in SQL Server is much more efficient. So our framework will gain a new functionality. There are scenarios when allot of calculated records will get home by this new bus.&lt;br /&gt;&lt;br /&gt;I'm disappointed by Entities Framework I hope that will evolve in a real tool in the near future. &lt;br /&gt;&lt;br /&gt;It seems that the day is getting smaller for me, even the light period is increasing.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2751800870260593323-805646396160123516?l=www.mvvm.ro' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.mvvm.ro/feeds/805646396160123516/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2751800870260593323&amp;postID=805646396160123516' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/805646396160123516'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2751800870260593323/posts/default/805646396160123516'/><link rel='alternate' type='text/html' href='http://www.mvvm.ro/2008/05/shaping-axe-before-cutting-tree.html' title='Sharping the axe before cutting the tree'/><author><name>Yo_Da</name><uri>http://www.blogger.com/profile/09369438986484211464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp0.blogger.com/_Yp-_3i1VVgk/SCtb9iXdD_I/AAAAAAAAAAQ/2pOxsh5wc9c/S220/Yo_Da.bmp'/></author><thr:total>0</thr:total></entry></feed>
