<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://wardyit.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Michael O'Dea-Jones' Blog</title><subtitle type="html">

</subtitle><id>http://wardyit.com/blog/michaelodeajones/atom.aspx</id><link rel="alternate" type="text/html" href="http://wardyit.com/blog/michaelodeajones/default.aspx" /><link rel="self" type="application/atom+xml" href="http://wardyit.com/blog/michaelodeajones/atom.aspx" /><generator uri="http://communityserver.org" version="2.1.61025.2">Community Server</generator><updated>2008-07-29T11:33:00Z</updated><entry><title>Previous Versions of a File/Folder under Vista</title><link rel="alternate" type="text/html" href="http://wardyit.com/blog/michaelodeajones/archive/2008/12/03/previous-versions-of-a-file-folder-under-vista.aspx" /><id>http://wardyit.com/blog/michaelodeajones/archive/2008/12/03/previous-versions-of-a-file-folder-under-vista.aspx</id><published>2008-12-03T01:00:36Z</published><updated>2008-12-03T01:00:36Z</updated><content type="html">&lt;p&gt;Did you know that when enabled, select versions of Microsoft Vista store previous copies of your files and folders? This means that you can get them back if you need them. 
&lt;/p&gt;&lt;p&gt;To view the previous versions of a folder open Windows Explorer, navigate to the folder, right click on the folder and select Properties. Then select the Previous Versions tab e.g. &lt;a href="http://www.wardyit.com/michaelodeajones/Blog/PreviousVersionsVista/FolderProperties.png"&gt;Link&lt;/a&gt;.
&lt;/p&gt;&lt;p&gt;To view previous versions of a File just right click on the file and select "Restore previous versions".
&lt;/p&gt;&lt;p&gt;If you have time check out this video: &lt;a href="http://video.msn.com/video.aspx?mkt=en-us&amp;amp;vid=d28114f9-12cd-4a3e-8424-a16ce9be620a"&gt;Link&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://wardyit.com/aggbug.aspx?PostID=10699" width="1" height="1"&gt;</content><author><name>michael@wardyit.com</name><uri>http://wardyit.com/members/michael%40wardyit.com.aspx</uri></author></entry><entry><title>What to do when Visual Studio can’t create Private Accessors in your Unit Tests</title><link rel="alternate" type="text/html" href="http://wardyit.com/blog/michaelodeajones/archive/2008/12/03/what-to-do-when-visual-studio-can-t-create-private-accessors-in-your-unit-tests.aspx" /><id>http://wardyit.com/blog/michaelodeajones/archive/2008/12/03/what-to-do-when-visual-studio-can-t-create-private-accessors-in-your-unit-tests.aspx</id><published>2008-12-03T00:47:14Z</published><updated>2008-12-03T00:47:14Z</updated><content type="html">&lt;p&gt;I came across this issue recently when trying to create unit tests with Microsoft Visual Studio 2008 SP1. Test stubs were created for the Public methods of the class but VS2008 could not create a Private Accessor for the Private methods e.g.:
&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;
			&lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt;
			&lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;summary&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;
			&lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt;A test for TrimTimeOffDate
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;
			&lt;span style="color:gray;"&gt;///&amp;lt;/summary&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;        [TestMethod()]
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;        [DeploymentItem(&lt;span style="color:#a31515;"&gt;"WardyIT.Services.Hermes.Plugins.dll"&lt;/span&gt;)]
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;
			&lt;span style="color:blue;"&gt;public&lt;/span&gt;
			&lt;span style="color:blue;"&gt;void&lt;/span&gt; TrimTimeOffDateTest()
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;        {
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;
			&lt;span style="color:green;"&gt;// Creation of the private accessor for 'Microsoft.VisualStudio.TestTools.TypesAndSymbols.Assembly' failed
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;            Assert.Inconclusive(&lt;span style="color:#a31515;"&gt;"Creation of the private accessor for \'Microsoft.VisualStudio.TestTools.TypesAndSy"&lt;/span&gt; +
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;
			&lt;span style="color:#a31515;"&gt;"mbols.Assembly\' failed"&lt;/span&gt;);
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;        }
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;After Googling I came across a site that talked about running Visual Studio as Administrator on Microsoft Vista. To do this I right clicked on the Visual Studio 2008 menu item and selected "Run as administrator". Once I did this the Private Accessors were successfully created e.g.:
&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;
			&lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt;
			&lt;/span&gt;&lt;span style="color:gray;"&gt;&amp;lt;summary&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;
			&lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt;A test for TrimTimeOffDate
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;
			&lt;span style="color:gray;"&gt;///&amp;lt;/summary&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;        [&lt;span style="color:#2b91af;"&gt;TestMethod&lt;/span&gt;()]
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;        [&lt;span style="color:#2b91af;"&gt;DeploymentItem&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;"WardyIT.Services.Hermes.Plugins.dll"&lt;/span&gt;)]
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;
			&lt;span style="color:blue;"&gt;public&lt;/span&gt;
			&lt;span style="color:blue;"&gt;void&lt;/span&gt; TrimTimeOffDateTest()
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;        {
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;
			&lt;span style="color:#2b91af;"&gt;SchedulingEngine_Accessor&lt;/span&gt; target = &lt;span style="color:blue;"&gt;new&lt;/span&gt;
			&lt;span style="color:#2b91af;"&gt;SchedulingEngine_Accessor&lt;/span&gt;(); &lt;span style="color:green;"&gt;// TODO: Initialize to an appropriate value
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;
			&lt;span style="color:#2b91af;"&gt;DateTime&lt;/span&gt; DateToTrim = &lt;span style="color:blue;"&gt;new&lt;/span&gt;
			&lt;span style="color:#2b91af;"&gt;DateTime&lt;/span&gt;(); &lt;span style="color:green;"&gt;// TODO: Initialize to an appropriate value
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;
			&lt;span style="color:#2b91af;"&gt;DateTime&lt;/span&gt; expected = &lt;span style="color:blue;"&gt;new&lt;/span&gt;
			&lt;span style="color:#2b91af;"&gt;DateTime&lt;/span&gt;(); &lt;span style="color:green;"&gt;// TODO: Initialize to an appropriate value
&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;
			&lt;span style="color:#2b91af;"&gt;DateTime&lt;/span&gt; actual;
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;            actual = target.TrimTimeOffDate(DateToTrim);
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;
			&lt;span style="color:#2b91af;"&gt;Assert&lt;/span&gt;.AreEqual(expected, actual);
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;
			&lt;span style="color:#2b91af;"&gt;Assert&lt;/span&gt;.Inconclusive(&lt;span style="color:#a31515;"&gt;"Verify the correctness of this test method."&lt;/span&gt;);
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;        }
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Other suggestions were:
&lt;/p&gt;&lt;ol style="margin-left:38pt;"&gt;&lt;li&gt;It's bad practice to test Private Methods. &lt;a href="http://www.dzone.com/links/do_not_test_private_methods.html"&gt;Link&lt;/a&gt;
		&lt;/li&gt;&lt;li&gt;It's bad practice to have too many classes because you have split out Private Methods into new classes. &lt;a href="http://www.infoq.com/news/2008/01/private-methods-tdd-design"&gt;Link&lt;/a&gt;
		&lt;/li&gt;&lt;li&gt;To use the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.privateobject.aspx"&gt;PrivateObject&lt;/a&gt; Class if you can't use the Private Accessor. &lt;a href="http://infosysblogs.com/microsoft/2008/01/aspnet_unit_testing_issue_on_i.html"&gt;Link&lt;/a&gt;
		&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Other Links:
&lt;/p&gt;&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-au/library/ms379625.aspx"&gt;A Unit Testing Walkthrough with Visual Studio Team Test&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;img src="http://wardyit.com/aggbug.aspx?PostID=10698" width="1" height="1"&gt;</content><author><name>michael@wardyit.com</name><uri>http://wardyit.com/members/michael%40wardyit.com.aspx</uri></author></entry><entry><title>Want to script Data? The SQL Database Publishing Wizard is your friend!</title><link rel="alternate" type="text/html" href="http://wardyit.com/blog/michaelodeajones/archive/2008/12/02/want-to-script-data-the-sql-database-publishing-wizard-is-your-friend.aspx" /><id>http://wardyit.com/blog/michaelodeajones/archive/2008/12/02/want-to-script-data-the-sql-database-publishing-wizard-is-your-friend.aspx</id><published>2008-12-02T04:45:01Z</published><updated>2008-12-02T04:45:01Z</updated><content type="html">&lt;p&gt;Guess what I discovered today? The SQL Database Wizard for Visual Studio! This solves the age old problem of scripting your database structure so that you can create your database on a remote/hosted server. What's more the SQL Database Wizard also has the capability to script your data as well. Yes, you heard right, script your data as well! 
&lt;/p&gt;&lt;p&gt;Version 1.2 of the SQL Database Publishing Wizard was incorporated into Visual Studio 2008 RTM because it was a very popular add-in for Visual Studio 2005. It has subsequently been upgraded to 1.3 in Visual Studio 2008 Service Pack 1 and you can use it to script databases for SQL 2000, 2005 and 2008 Servers. You can script Data only, Structure only and Data and Structure. Check it out on the &lt;a href="http://blogs.msdn.com/webdevtools/archive/2007/10/15/sql-database-publishing-wizard-is-now-in-visual-studio-orcas.aspx"&gt;Visual Developer Team&lt;/a&gt; or &lt;a href="http://weblogs.asp.net/scottgu/archive/2006/12/22/recipe-deploying-a-sql-database-to-a-remote-hosting-environment-part-1.aspx"&gt;Scot Guthrie's Blogs&lt;/a&gt;. For those in Visual Studio 2005 you can download the &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=56E5B1C5-BF17-42E0-A410-371A838E570A&amp;amp;displaylang=en"&gt;Microsoft SQL Server Database Publishing Wizard 1.1&lt;/a&gt;.
&lt;/p&gt;&lt;p&gt;The one question I have is "Why didn't someone tell me about this sooner?"&lt;/p&gt;&lt;img src="http://wardyit.com/aggbug.aspx?PostID=10691" width="1" height="1"&gt;</content><author><name>michael@wardyit.com</name><uri>http://wardyit.com/members/michael%40wardyit.com.aspx</uri></author></entry><entry><title>TabPage.Hide() doesn’t Hide the TabPage</title><link rel="alternate" type="text/html" href="http://wardyit.com/blog/michaelodeajones/archive/2008/12/01/tabpage-hide-doesn-t-hide-the-tabpage.aspx" /><id>http://wardyit.com/blog/michaelodeajones/archive/2008/12/01/tabpage-hide-doesn-t-hide-the-tabpage.aspx</id><published>2008-12-01T03:15:05Z</published><updated>2008-12-01T03:15:05Z</updated><content type="html">&lt;p&gt;Here's something that just got me. The TabPage.Hide() method doesn't hide the TabPage. You have to remove the TabPage from the &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.tabpages.aspx"&gt;TabControl&lt;span style="color:#0033cc;"&gt;.&lt;/span&gt;TabPages&lt;/a&gt;&lt;span style="color:black;"&gt; collection:&lt;span style="font-family:Verdana;font-size:8pt;"&gt;
			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;font-size:10pt;"&gt;ProductTabControl.TabPages.Remove(PurchasingTabPage);
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.top.aspx"&gt;Top&lt;/a&gt;, &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.height.aspx"&gt;Height&lt;/a&gt;, &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.left.aspx"&gt;Left&lt;/a&gt;, &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.width.aspx"&gt;Width&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.show.aspx"&gt;Show&lt;/a&gt; have no effect too. Read more on &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.tabpage.aspx"&gt;MSDN&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://wardyit.com/aggbug.aspx?PostID=10681" width="1" height="1"&gt;</content><author><name>michael@wardyit.com</name><uri>http://wardyit.com/members/michael%40wardyit.com.aspx</uri></author></entry><entry><title>Bankers Rounding. Don’t Bank on it. It’s the Default.</title><link rel="alternate" type="text/html" href="http://wardyit.com/blog/michaelodeajones/archive/2008/11/30/bankers-rounding-don-t-bank-on-it-it-s-the-default.aspx" /><id>http://wardyit.com/blog/michaelodeajones/archive/2008/11/30/bankers-rounding-don-t-bank-on-it-it-s-the-default.aspx</id><published>2008-11-29T23:11:03Z</published><updated>2008-11-29T23:11:03Z</updated><content type="html">&lt;p&gt;They say you learn something new every day. In IT I learn at least a dozen new things every day. Did you know that there are two different rounding methods in .Net? I didn't. Now I've come across them in two different applications in the same week. They are &lt;em&gt;To Even&lt;/em&gt; (Bankers) and &lt;em&gt;Away from Zero&lt;/em&gt;.
&lt;/p&gt;&lt;p&gt;&lt;strong&gt;To Even&lt;/strong&gt;: When a number is halfway between two others, it is rounded toward the nearest even number.&lt;strong&gt;
		&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Away From Zero&lt;/strong&gt;: When a number is halfway between two others, it is rounded toward the nearest number that is away from zero.
&lt;/p&gt;&lt;p&gt;The default MidpointRounding method is MidpointRounding.ToEven. The following are equivalent and both return 0D: 
&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:10pt;"&gt;&lt;span style="color:blue;"&gt;Double&lt;/span&gt; roundedValue = &lt;/span&gt;&lt;span style="font-size:8pt;"&gt;Math.Round(0.5D)&lt;/span&gt;&lt;span style="font-size:10pt;"&gt;&lt;br /&gt;&lt;span style="color:blue;"&gt;Double&lt;/span&gt; roundedValue = &lt;/span&gt;&lt;span style="font-size:8pt;"&gt;Math.Round(0.5D, MidpointRounding.ToEven)&lt;/span&gt;&lt;span style="font-size:10pt;"&gt;
			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;When MidpointRounding.AwayFromZero is specified then the result is 1D: 
&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:10pt;"&gt;&lt;span style="color:blue;"&gt;Double&lt;/span&gt; roundedValue = &lt;/span&gt;&lt;span style="font-size:8pt;"&gt;Math.Round(0.5D, MidpointRounding.AwayFromZero)&lt;/span&gt;&lt;span style="font-size:10pt;"&gt;
			&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;img src="http://wardyit.com/aggbug.aspx?PostID=10678" width="1" height="1"&gt;</content><author><name>michael@wardyit.com</name><uri>http://wardyit.com/members/michael%40wardyit.com.aspx</uri></author></entry><entry><title>The Mo Stays. The Hair Goes.</title><link rel="alternate" type="text/html" href="http://wardyit.com/blog/michaelodeajones/archive/2008/11/27/the-mo-stays-the-hair-goes.aspx" /><id>http://wardyit.com/blog/michaelodeajones/archive/2008/11/27/the-mo-stays-the-hair-goes.aspx</id><published>2008-11-27T12:59:00Z</published><updated>2008-11-27T12:59:00Z</updated><content type="html">&lt;p&gt;Just in case you didn't know, I have been growing a moustache as part of &lt;a href="http://au.movember.com/"&gt;Movember&lt;/a&gt;. I would now like to introduce you to my &lt;a href="http://www.wardyit.com/michaelodeajones/Blog/Movember/MODJ_Movember2008.jpg"&gt;Mo&lt;/a&gt;. This is the first moustache I have ever grown and I am quite proud of my effort. Apart from the dribbling, it's a great companion. I have also decided to keep my hair short. Some of the things people have said about my Mo:
&lt;/p&gt;&lt;ul&gt;&lt;li&gt;With the orange shirt and no hair, you look totally prisoner, man!
&lt;/li&gt;&lt;li&gt;It suites you.
&lt;/li&gt;&lt;li&gt;You look artistic.
&lt;/li&gt;&lt;li&gt;You remind me of &lt;a href="http://en.wikipedia.org/wiki/Fu_Manchu_moustache"&gt;Fu Manchu&lt;/a&gt;. And you laugh like him too!
&lt;/li&gt;&lt;li&gt;You just scared the hell out of me!!!!!!! WOW. Like the Mo but I have to ask where is your hair?
&lt;/li&gt;&lt;li&gt;Does your hair grow at different rates on various parts of your head?
&lt;/li&gt;&lt;li&gt;I'm thinking you've just transplanted it from your scalp to your upper lip!
&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;So far I have raised enough money that they sent me a shaving kit! I had fun. No one got hurt. Money was raised. Now I'm scary on the outside too!
&lt;/p&gt;&lt;p&gt;To donate to my Mo you can either:
&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Click this link:&amp;nbsp; &lt;a href="https://www.movember.com/au/donate/donate-details.php?action=sponsorlink&amp;amp;rego=1851911&amp;amp;country=au" target="_blank"&gt;https://www.movember.com/au/donate/donate-details.php?action=sponsorlink&amp;amp;rego=1851911&amp;amp;country=au&lt;/a&gt; and donate online using your credit card or PayPal account, or
&lt;/li&gt;&lt;li&gt;Write a cheque payable to 'Movember Foundation', referencing my Registration Number 1851911 and mailing it to:
&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;                                            Movember Foundation &lt;br&gt;                                            PO Box 292&lt;br&gt;                                            Prahran VIC 3181
&lt;/p&gt;&lt;p&gt;Remember, all donations over $2 are tax deductible.&lt;br&gt;&lt;br&gt;The money raised by Movember is used to raise awareness of men's health issues and donated to the Prostate Cancer Foundation of Australia and &lt;i&gt;beyondblue - the national depression initiative. &lt;/i&gt;The PCFA and &lt;i&gt;beyondblue&lt;/i&gt; will use the funds to fund research and increase support networks for those men who suffer from prostate cancer and depression.
&lt;/p&gt;&lt;p&gt;Did you know:
&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Depression affects 1 in 6 men....most don't seek help. Untreated depression is a leading risk factor for suicide. 
&lt;/li&gt;&lt;li&gt;Last year in Australia 18,700 men were diagnosed with prostate cancer and more than 2,900 died of prostate cancer - equivalent to the number of women who will die from *** cancer annually.
&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;i&gt;Movember is proudly grown by Holden and Schick.&lt;/i&gt;
	&lt;/p&gt;&lt;p&gt;&lt;i&gt;Movember is proud partners with the Prostate Cancer Foundation of Australia and beyondblue - the national depression initiative.&lt;/i&gt;
	&lt;/p&gt;&lt;img src="http://wardyit.com/aggbug.aspx?PostID=10663" width="1" height="1"&gt;</content><author><name>michael@wardyit.com</name><uri>http://wardyit.com/members/michael%40wardyit.com.aspx</uri></author></entry><entry><title>Rule “Restart Computer” Failed</title><link rel="alternate" type="text/html" href="http://wardyit.com/blog/michaelodeajones/archive/2008/11/27/rule-restart-computer-failed.aspx" /><id>http://wardyit.com/blog/michaelodeajones/archive/2008/11/27/rule-restart-computer-failed.aspx</id><published>2008-11-26T23:49:13Z</published><updated>2008-11-26T23:49:13Z</updated><content type="html">&lt;p&gt;Something hinky went wrong when I installed SQL Server 2008 on my Development machine and the "Restart Computer" rule kept failing no matter how many times I rebooted. After some Googling I found &lt;a href="http://forums.microsoft.com/msdn/showpost.aspx?postid=3656807&amp;amp;siteid=1&amp;amp;sb=0&amp;amp;d=1&amp;amp;at=7&amp;amp;ft=11&amp;amp;tf=0&amp;amp;pageid=1"&gt;this&lt;/a&gt; page which suggested clearing the &lt;strong&gt;HKEY_LOCAL_MACHINE&lt;/strong&gt;\&lt;strong&gt;SYSTEM&lt;/strong&gt;\&lt;strong&gt;CurrentControlSet&lt;/strong&gt;\&lt;strong&gt;Control&lt;/strong&gt;\&lt;strong&gt;Session Manager&lt;/strong&gt;\&lt;strong&gt;PendingFileRenameOperations &lt;/strong&gt;Registry key. I cleared the key and I now the Restart Computer rule passed. Yeah!&lt;/p&gt;&lt;img src="http://wardyit.com/aggbug.aspx?PostID=10662" width="1" height="1"&gt;</content><author><name>michael@wardyit.com</name><uri>http://wardyit.com/members/michael%40wardyit.com.aspx</uri></author></entry><entry><title>How to work out how long a SQL Instance has been running</title><link rel="alternate" type="text/html" href="http://wardyit.com/blog/michaelodeajones/archive/2008/11/24/how-to-work-out-how-long-a-sql-instance-has-been-running.aspx" /><id>http://wardyit.com/blog/michaelodeajones/archive/2008/11/24/how-to-work-out-how-long-a-sql-instance-has-been-running.aspx</id><published>2008-11-24T01:42:00Z</published><updated>2008-11-24T01:42:00Z</updated><content type="html">&lt;P&gt;Recently I had to come up with a way of determining how long a SQL Instance had been running. It turns out that there are a few ways to do it and here is my preferred way: &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:blue;"&gt;SELECT&lt;/SPAN&gt; crdate &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:blue;"&gt;FROM&lt;/SPAN&gt; sysdatabases &lt;BR&gt;&lt;SPAN style="COLOR:blue;"&gt;WHERE&lt;/SPAN&gt; [name] &lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR:red;"&gt;'tempdb'&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;This works because the tempdb database is recreated every time the SQL Service is started. As an alternative you could get the date from the first entry in the current SQL Log: &lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.wardyit.com/michaelodeajones/Blog/How%20to%20work%20out%20how%20long%20a%20SQL%20Instance%20has%20been%20running/SQLLog.png"&gt;SQL Log&lt;/A&gt; &lt;/P&gt;&lt;img src="http://wardyit.com/aggbug.aspx?PostID=10639" width="1" height="1"&gt;</content><author><name>michael@wardyit.com</name><uri>http://wardyit.com/members/michael%40wardyit.com.aspx</uri></author></entry><entry><title>Liberation Day, Cloud Computing and Steve Balmer</title><link rel="alternate" type="text/html" href="http://wardyit.com/blog/michaelodeajones/archive/2008/11/24/liberation-day-cloud-computing-and-steve-balmer.aspx" /><id>http://wardyit.com/blog/michaelodeajones/archive/2008/11/24/liberation-day-cloud-computing-and-steve-balmer.aspx</id><published>2008-11-24T00:47:00Z</published><updated>2008-11-24T00:47:00Z</updated><content type="html">&lt;P&gt;On the 6&lt;SUP&gt;th&lt;/SUP&gt; of November I joined other local developers at the Microsoft Offices in Brisbane and around the world to listen to Steve Balmer talk to developers&lt;SUP&gt;1&lt;/SUP&gt;. He was excited and so was I. Steve confirmed one of my truths which is that "the really cool stuff that goes on the IT industry is done by developers". Wow! I love developing software. I'm passionate about it. I'm fascinated by computers, how they work and I really enjoy solving problems with software. &lt;/P&gt;
&lt;P&gt;Steve's talk reminded me of when Bob Atkinson (the Queensland Police Commissioner) said that the Charge Prep Project (that I was working on) was the most significant project we would ever work on in our professional careers. This was because it was going to reshape the charging process: how charges were delivered to the Department of Justice (electronically), improve the quality of the charges being produced, speed up the charging process and deliver much needed reporting capabilities. I was touched. The thought that your work would be used by thousands every day, all over Queensland, for years touched me. I really do like working on those ground breaking systems that take people and organisations into a whole new space. &lt;/P&gt;
&lt;P&gt;When I was deciding on a career I followed the old axiom to "choose a job that allows you to do the thing you love." I had three choices Priesthood, Secondary Teaching and Programming. I chose Programming and haven't looked back. Here is a quote from The Pragmatic Programmer that sums up my programming experience: &lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Programming is a craft. At its simplest, it comes down to getting a computer to do what you want it to do (or what your user wants it to do). As a programmer you are part listener, part advisor, part interpreter, and part dictator. You try to capture elusive requirements and find a way of expressing them so that a mere machine can do them justice. You try to document your work so that others can understand it, and you try to engineer your work so that others can build on it. What's more, you try to do all this against the relentless ticking of the project clock. You work small miracles every day.&lt;SUP&gt;2 &lt;/SUP&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;What Steve Balmer said resonated with me and I am truly excited about Cloud Computing. I can see so many applications for it. At Wardy IT we are in the process of packaging some products we've been working on to sell online. One of them called Hermes (light weight messaging and middleware framework) could be deployed to the Cloud giving customers virtually unlimited scalability. The way I think about Cloud Computing is similar to the way I experienced the Internet. It's a new technology, a platform, a paradigm that promises great power and new possibilities. I say "bring it on!" &lt;/P&gt;
&lt;P&gt;1 &lt;A href="http://www.microsoft.com/australia/powertodevelopers/"&gt;Liberation Day&lt;/A&gt;&lt;BR&gt;2 &lt;A href="http://www.pragprog.com/the-pragmatic-programmer"&gt;The Pragmatic Programmer&lt;/A&gt; Preface xvii.&lt;/P&gt;&lt;img src="http://wardyit.com/aggbug.aspx?PostID=10638" width="1" height="1"&gt;</content><author><name>michael@wardyit.com</name><uri>http://wardyit.com/members/michael%40wardyit.com.aspx</uri></author></entry><entry><title>Bridge to Brisbane – Mouth Wide Shut!</title><link rel="alternate" type="text/html" href="http://wardyit.com/blog/michaelodeajones/archive/2008/09/08/bridge-to-brisbane-mouth-wide-shut.aspx" /><id>http://wardyit.com/blog/michaelodeajones/archive/2008/09/08/bridge-to-brisbane-mouth-wide-shut.aspx</id><published>2008-09-08T13:51:00Z</published><updated>2008-09-08T13:51:00Z</updated><content type="html">&lt;P&gt;It's 6:45 AM on a Sunday morning. I am running up the Gateway Bridge with thousands of other runners. There are so many I have to go slow and watch my every step. All I can hear is the sound of shoes hitting the bitumen. The sky is blue, there is no wind. What a wonderful way to start Fathers day! I completed the Bridge to Brisbane 10 Km fun run in 60 minutes. That's 10 Km per hour and I did it breathing only through my nose! Not bad seeing as this was my first 10 Km run. I normally only run 4 Km's. &lt;/P&gt;
&lt;P&gt;Today "I can't feel my legs!"&lt;/P&gt;
&lt;P&gt;&lt;A href="http://wardyit.com/michaelodeajones/blog/b2b08/BridgeToBrisbane2008.blogsize.jpg"&gt;Wardy IT Bridge To Brisbane Team Photo&lt;/A&gt;&lt;/P&gt;&lt;img src="http://wardyit.com/aggbug.aspx?PostID=10127" width="1" height="1"&gt;</content><author><name>michael@wardyit.com</name><uri>http://wardyit.com/members/michael%40wardyit.com.aspx</uri></author></entry><entry><title>My SEAF Down Under Experience</title><link rel="alternate" type="text/html" href="http://wardyit.com/blog/michaelodeajones/archive/2008/09/08/my-seaf-down-under-experience.aspx" /><id>http://wardyit.com/blog/michaelodeajones/archive/2008/09/08/my-seaf-down-under-experience.aspx</id><published>2008-09-08T13:05:00Z</published><updated>2008-09-08T13:05:00Z</updated><content type="html">&lt;P&gt;Have you ever swum in a creek or water hole that's dark and murky? Have you ever let yourself sink down into the water and watched as the sun's rays disappear through the green algae and dirt? Have you ever held your breath while the fear rises in you, the darkness surrounds you and the chill of the unknown depths creeps up your legs? I have, and to this day I still wonder how deep the water hole really was and if there was some prehistoric predator at the bottom licking its lips. Till last week designing and managing databases evoked in me similar feelings. The wonderful rush of adrenalin flowing from living on the edge mixed with the fear that something could have gone wrong. &lt;/P&gt;
&lt;P&gt;Last week (1&lt;SUP&gt;st&lt;/SUP&gt; and 2&lt;SUP&gt;nd&lt;/SUP&gt; of Sept) I attended the SQL Enterprise Architects Forum (SEAF) at the Sydney Convention and Exhibition Centre. I found it very enlightening. Finally I was getting reliable information from the experts of the SQL Server Customer Advisory Team (CAT) - part of Microsoft's SQL development team based in Redmond, California. It felt good. It was like scuba diving in the water hole with oxygen, powerful torches and diving buddies. Clustering, Log Shipping, Replication and Mirroring lost their mystery when explained in context. There were no scary monsters. I'm no guru and I was able to follow most of what was said. I felt a little like Sir Edmund Hillary who described his feelings as ones of "quiet satisfaction, almost a little bit of surprise" when he climbed Mt Everest. In my case the satisfaction and surprise came from the realisation that many of my thoughts were validated.&lt;/P&gt;&lt;img src="http://wardyit.com/aggbug.aspx?PostID=10126" width="1" height="1"&gt;</content><author><name>michael@wardyit.com</name><uri>http://wardyit.com/members/michael%40wardyit.com.aspx</uri></author></entry><entry><title>BindingNavigator + Validation = Grief</title><link rel="alternate" type="text/html" href="http://wardyit.com/blog/michaelodeajones/archive/2008/08/10/bindingnavigator-validation-grief.aspx" /><id>http://wardyit.com/blog/michaelodeajones/archive/2008/08/10/bindingnavigator-validation-grief.aspx</id><published>2008-08-10T05:54:00Z</published><updated>2008-08-10T05:54:00Z</updated><content type="html">&lt;P&gt;I received a rather nasty shock to discover that you can't use the BindingNavigator Validating event to stop navigating to the next, previous, first or last record in a DataSource if there are validation errors on your Form. If you are using a DataGridView then set e.Cancel to true in the DataGridView's RowValidating event: &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:blue;"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;void&lt;/SPAN&gt; form1Form_Load(&lt;SPAN style="COLOR:blue;"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR:#2b91af;"&gt;EventArgs&lt;/SPAN&gt; e) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:blue;"&gt;this&lt;/SPAN&gt;.jobTableAdapter.Fill(&lt;SPAN style="COLOR:blue;"&gt;this&lt;/SPAN&gt;.hermesDataSet.Job); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;form1DataSet.Job.ColumnChanging += &lt;SPAN style="COLOR:blue;"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR:#2b91af;"&gt;DataColumnChangeEventHandler&lt;/SPAN&gt;(Job_ColumnChanging); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;jobDataGridView.RowValidating += &lt;SPAN style="COLOR:blue;"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR:#2b91af;"&gt;DataGridViewCellCancelEventHandler&lt;/SPAN&gt;(jobDataGridView_RowValidating); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:blue;"&gt;void&lt;/SPAN&gt; Job_ColumnChanging(&lt;SPAN style="COLOR:blue;"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR:#2b91af;"&gt;DataColumnChangeEventArgs&lt;/SPAN&gt; e) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:blue;"&gt;if&lt;/SPAN&gt; (e.Column.ColumnName == &lt;SPAN style="COLOR:#a31515;"&gt;"JobItem"&lt;/SPAN&gt;) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:blue;"&gt;if&lt;/SPAN&gt; (&lt;SPAN style="COLOR:blue;"&gt;string&lt;/SPAN&gt;.IsNullOrEmpty(e.ProposedValue.ToString())) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;e.Row.SetColumnError(e.Column.ColumnName, &lt;SPAN style="COLOR:#a31515;"&gt;"Item cannot be empty"&lt;/SPAN&gt;); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:blue;"&gt;else &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;e.Row.SetColumnError(e.Column.ColumnName, &lt;SPAN style="COLOR:blue;"&gt;string&lt;/SPAN&gt;.Empty); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:blue;"&gt;void&lt;/SPAN&gt; jobDataGridView_RowValidating(&lt;SPAN style="COLOR:blue;"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR:#2b91af;"&gt;DataGridViewCellCancelEventArgs&lt;/SPAN&gt; e) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:blue;"&gt;if&lt;/SPAN&gt; (hermesDataSet.Job.HasErrors) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="BACKGROUND-COLOR:#ffc000;"&gt;e.Cancel = &lt;SPAN style="COLOR:blue;"&gt;true&lt;/SPAN&gt;;&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;}&lt;/SPAN&gt; &lt;/P&gt;
&lt;P&gt;If you are aren't using a DataGridView then set e.Cancel to true in the Control's (e.g. TextBox ) Validating event: &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:blue;"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;void&lt;/SPAN&gt; taskStateNameTextBox_Validating(&lt;SPAN style="COLOR:blue;"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR:#2b91af;"&gt;CancelEventArgs&lt;/SPAN&gt; e) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:blue;"&gt;if&lt;/SPAN&gt; (&lt;SPAN style="COLOR:blue;"&gt;string&lt;/SPAN&gt;.IsNullOrEmpty(taskStateNameTextBox.Text)) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;taskStateErrorProvider.SetError(taskStateNameTextBox, &lt;SPAN style="COLOR:#a31515;"&gt;"Name cannot be empty"&lt;/SPAN&gt;); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="BACKGROUND-COLOR:#ffc000;"&gt;e.Cancel = &lt;SPAN style="COLOR:blue;"&gt;true&lt;/SPAN&gt;;&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:blue;"&gt;else &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;taskStateErrorProvider.SetError(taskStateNameTextBox, &lt;SPAN style="COLOR:blue;"&gt;string&lt;/SPAN&gt;.Empty); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://wardyit.com/aggbug.aspx?PostID=9932" width="1" height="1"&gt;</content><author><name>michael@wardyit.com</name><uri>http://wardyit.com/members/michael%40wardyit.com.aspx</uri></author></entry><entry><title>Windows Forms Videos</title><link rel="alternate" type="text/html" href="http://wardyit.com/blog/michaelodeajones/archive/2008/07/30/windows-forms-videos.aspx" /><id>http://wardyit.com/blog/michaelodeajones/archive/2008/07/30/windows-forms-videos.aspx</id><published>2008-07-30T12:48:00Z</published><updated>2008-07-30T12:48:00Z</updated><content type="html">&lt;P&gt;If there is one consistent thing that I have learned about programming it is that there is always more to know. Being a visual learner, I gravitate towards videos. Here are some excellent videos on Windows Forms Controls, Data Binding and Windows Forms "under the hood": &lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/vcsharp/aa336766.aspx"&gt;Visual C# Developer Center&lt;/A&gt; : &lt;A href="http://msdn.microsoft.com/en-us/vcsharp/bb798022.aspx"&gt;Visual C# How Do I Video Series&lt;/A&gt; &lt;BR&gt;&lt;A href="http://windowsclient.net/learn/"&gt;WindowsClient.Net&lt;/A&gt; : &lt;A href="http://windowsclient.net/learn/videos.aspx"&gt;Windows Forms Videos&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;The videos I found most interesting were: &lt;/P&gt;
&lt;P&gt;&lt;A href="http://download.microsoft.com/download/3/b/e/3bec9119-a287-41ca-ba3a-6ad19633e1d3/WinVideo-06%20Notify%20Icon%20-%20CS.zip"&gt;How to create a System Tray application using the NotifyIcon control&lt;/A&gt;&lt;BR&gt;&lt;A href="http://download.microsoft.com/download/f/1/4/f1414045-e4aa-4730-92e3-99a673e6c954/WinVideo-07%20Process%20Control%20-%20CS.zip"&gt;How to call other applications using the Process control&lt;/A&gt;&lt;BR&gt;&lt;A href="http://download.microsoft.com/download/4/d/a/4dad092c-5601-4c0a-a070-7dcc4ac8446c/WinVideo-20%20Tree%20View%20Control%20-%20CS.zip"&gt;How to use the TreeView control&lt;/A&gt;&lt;BR&gt;&lt;A href="http://download.microsoft.com/download/0/8/1/08186385-98a1-4630-8ab9-20b5576da8b9/WinVideo-21%20Web%20Browser%20Control%20-%20CS.zip"&gt;How to use the WebBrowser control&lt;/A&gt;&lt;BR&gt;&lt;A href="http://wm.microsoft.com/ms/msdn/vstudio/express/AbsoluteBeginner/VB/09VB.wmv"&gt;Databinding Data to User Interface Controls&lt;/A&gt;&lt;BR&gt;&lt;A href="http://msevents.microsoft.com/cui/WebCastEventDetails.aspx?EventID=1032285141&amp;amp;EventCategory=4&amp;amp;culture=en-US&amp;amp;CountryCode=US"&gt;MSDN Webcast: How Microsoft Technology Works: Windows Forms (Level 200)&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Also I must say that I liked the web cast so much that I went to both of Jessica (aka jfo's) Blogs: &lt;A href="http://blogs.msdn.com/jfoscoding/default.aspx"&gt;MSDN&lt;/A&gt;, &lt;A href="http://jfoscoding.blogspot.com/"&gt;jfo's coding&lt;/A&gt;. In particular I found jfo's &lt;A href="http://jfoscoding.blogspot.com/2006/12/advice-to-myself-i-wish-i-had-had.html"&gt;"Advice to myself, I wish I had had starting out"&lt;/A&gt; well worth the read. &lt;/P&gt;
&lt;P&gt;Mental note: "must learn WPF".&lt;/P&gt;&lt;img src="http://wardyit.com/aggbug.aspx?PostID=9809" width="1" height="1"&gt;</content><author><name>michael@wardyit.com</name><uri>http://wardyit.com/members/michael%40wardyit.com.aspx</uri></author></entry><entry><title>Double Buffering Windows Forms</title><link rel="alternate" type="text/html" href="http://wardyit.com/blog/michaelodeajones/archive/2008/07/30/double-buffering-windows-forms.aspx" /><id>http://wardyit.com/blog/michaelodeajones/archive/2008/07/30/double-buffering-windows-forms.aspx</id><published>2008-07-30T11:14:00Z</published><updated>2008-07-30T11:14:00Z</updated><content type="html">&lt;P&gt;I'm working on an application where the presentation is very important and I want it to look great. I am overriding the Form's OnPaint() method so that I can create a Gradient background. I thought that I had done a fantastic job until I started to resize the Form and Noticed that it was flickering. Not to be outdone I researching the issue I came across a technique called Double Buffering that made a big difference. &lt;/P&gt;
&lt;P&gt;Double Buffering is the process whereby the Painting is done in memory first and then the result is copied to the screen. This is different from the default mode where the painting is done directly to the screen. Another contributing factor was that the Form was painting the Background and Foreground in two separate actions. These two actions can be combined to reduce flickering. &lt;/P&gt;
&lt;P&gt;In order to configure Double Buffering you need to apply three Styles to the Control and then force the Control to apply the new styles. Here are the three Styles: &lt;/P&gt;
&lt;OL style="MARGIN-LEFT:38pt;"&gt;
&lt;LI&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:#2b91af;"&gt;ControlStyles&lt;/SPAN&gt;.AllPaintingInWmPaint&lt;/SPAN&gt; &lt;/DIV&gt;
&lt;OL&gt;
&lt;LI&gt;Ignores Background Paint messages. The Control's Background and Foreground are painted at the same time. &lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:#2b91af;"&gt;ControlStyles&lt;/SPAN&gt;.UserPaint&lt;/SPAN&gt; &lt;/DIV&gt;
&lt;OL&gt;
&lt;LI&gt;Configures the Control to execute the OnPaint and OnPaintBackground Methods. &lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:#2b91af;"&gt;ControlStyles&lt;/SPAN&gt;.DoubleBuffer&lt;/SPAN&gt; &lt;/DIV&gt;
&lt;OL&gt;
&lt;LI&gt;Paints the Control in memory first and then copied the result to the screen. &lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Invoke the Form's &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.setstyle.aspx"&gt;SetStyle()&lt;/A&gt; method to configure it for Double Buffering: &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:blue;"&gt;protected&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;override&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;void&lt;/SPAN&gt; OnLoad(&lt;SPAN style="COLOR:#2b91af;"&gt;EventArgs&lt;/SPAN&gt; e) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:blue;"&gt;base&lt;/SPAN&gt;.OnLoad(e); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="COLOR:green;"&gt;// Double Buffer to reduce flickering &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:blue;"&gt;this&lt;/SPAN&gt;.SetStyle(&lt;SPAN style="COLOR:#2b91af;"&gt;ControlStyles&lt;/SPAN&gt;.AllPaintingInWmPaint | &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:#2b91af;"&gt;ControlStyles&lt;/SPAN&gt;.UserPaint | &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:#2b91af;"&gt;ControlStyles&lt;/SPAN&gt;.DoubleBuffer, &lt;SPAN style="COLOR:blue;"&gt;true&lt;/SPAN&gt;); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:blue;"&gt;this&lt;/SPAN&gt;.UpdateStyles(); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;}&lt;/SPAN&gt; &lt;/P&gt;&lt;img src="http://wardyit.com/aggbug.aspx?PostID=9805" width="1" height="1"&gt;</content><author><name>michael@wardyit.com</name><uri>http://wardyit.com/members/michael%40wardyit.com.aspx</uri></author></entry><entry><title>Why is Thread.CurrentPrincipal.Identity.Name empty?</title><link rel="alternate" type="text/html" href="http://wardyit.com/blog/michaelodeajones/archive/2008/07/29/why-is-thread-currentprincipal-identity-name-empty.aspx" /><id>http://wardyit.com/blog/michaelodeajones/archive/2008/07/29/why-is-thread-currentprincipal-identity-name-empty.aspx</id><published>2008-07-29T01:33:00Z</published><updated>2008-07-29T01:33:00Z</updated><content type="html">&lt;P&gt;I am trying to get an audit trail going and want to record the user who created and modified the record in the database. I'm developing a .Net Windows Forms Application and assumed that the Current Principal's Identity was being set magically to the current user's identity. That's where my assumption was wrong. Apparently you have to set the Principal yourself. Here is the code that you can use to set the Application thread's Principal to the current User: &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:#2b91af;"&gt;Thread&lt;/SPAN&gt;.CurrentPrincipal = &lt;SPAN style="COLOR:blue;"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR:#2b91af;"&gt;WindowsPrincipal&lt;/SPAN&gt;(&lt;SPAN style="COLOR:#2b91af;"&gt;WindowsIdentity&lt;/SPAN&gt;.GetCurrent());&lt;/SPAN&gt;&lt;BR&gt;&lt;BR&gt;I added this line of code to the Main method in the Program class: &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:blue;"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;class&lt;/SPAN&gt; &lt;SPAN style="COLOR:#2b91af;"&gt;Program &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:gray;"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR:green;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;&amp;lt;summary&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:gray;"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR:green;"&gt; The main entry point for the application. &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:gray;"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR:green;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;&amp;lt;/summary&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;[&lt;SPAN style="COLOR:#2b91af;"&gt;STAThread&lt;/SPAN&gt;] &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:blue;"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;void&lt;/SPAN&gt; Main() &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:#2b91af;"&gt;Thread&lt;/SPAN&gt;.CurrentPrincipal = &lt;SPAN style="COLOR:blue;"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR:#2b91af;"&gt;WindowsPrincipal&lt;/SPAN&gt;(&lt;SPAN style="COLOR:#2b91af;"&gt;WindowsIdentity&lt;/SPAN&gt;.GetCurrent()); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:#2b91af;"&gt;Application&lt;/SPAN&gt;.EnableVisualStyles(); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:#2b91af;"&gt;Application&lt;/SPAN&gt;.SetCompatibleTextRenderingDefault(&lt;SPAN style="COLOR:blue;"&gt;false&lt;/SPAN&gt;); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:#2b91af;"&gt;Application&lt;/SPAN&gt;.Run(&lt;SPAN style="COLOR:blue;"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR:#2b91af;"&gt;ProcessForm&lt;/SPAN&gt;()); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;For custom security situations you can create your own Generic Identity and set the current thread's Identity to it: &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:blue;"&gt;string&lt;/SPAN&gt;[] Roles = { "Employee" }; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:#2b91af;"&gt;GenericIdentity&lt;/SPAN&gt; Identity = &lt;SPAN style="COLOR:blue;"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR:#2b91af;"&gt;GenericIdentity&lt;/SPAN&gt;("Michael"); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:#2b91af;"&gt;GenericPrincipal&lt;/SPAN&gt; Principal = &lt;SPAN style="COLOR:blue;"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR:#2b91af;"&gt;GenericPrincipal&lt;/SPAN&gt;(Identity, Roles); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:Courier New;"&gt;&lt;SPAN style="COLOR:#2b91af;"&gt;Thread&lt;/SPAN&gt;.CurrentPrincipal = Principal;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://wardyit.com/aggbug.aspx?PostID=9772" width="1" height="1"&gt;</content><author><name>michael@wardyit.com</name><uri>http://wardyit.com/members/michael%40wardyit.com.aspx</uri></author></entry></feed>