<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Lars Holm Jensen&#039;s Code Blog</title>
	<atom:link href="http://codeblog.larsholm.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://codeblog.larsholm.net</link>
	<description>Just another WordPress codeblog on C#, Silverlight and all things .NET</description>
	<lastBuildDate>Fri, 25 Jan 2013 12:42:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4</generator>
	<div id='fb-root'></div>
					<script type='text/javascript'>
						window.fbAsyncInit = function()
						{
							FB.init({appId: null, status: true, cookie: true, xfbml: true});
						};
						(function()
						{
							var e = document.createElement('script'); e.async = true;
							e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
							document.getElementById('fb-root').appendChild(e);
						}());
					</script>	
						<item>
		<title>[Danish post] DMR webservice fra .NET / C#</title>
		<link>http://codeblog.larsholm.net/2012/08/danish-post-dmr-webservice-fra-net-c/</link>
		<comments>http://codeblog.larsholm.net/2012/08/danish-post-dmr-webservice-fra-net-c/#comments</comments>
		<pubDate>Tue, 07 Aug 2012 08:57:16 +0000</pubDate>
		<dc:creator>larsholm</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codeblog.larsholm.net/?p=126</guid>
		<description><![CDATA[Det kan være udfordrende at forbinde til DMRs webservice for sekundære erhvervsmæssige brugere fra .NET / C# med WCF. Vejledningerne på interessent-sitet er ikke særligt brugbare. Derfor har jeg valgt at lægge et lille testprojekt ud, som kræver minimale tilretninger. Du skal bruge et gyldigt certifikat fra SKAT (som også er aktiveret hos SKAT) og du [...]]]></description>
			<content:encoded><![CDATA[<p>Det kan være udfordrende at forbinde til DMRs webservice for <em>sekundære erhvervsmæssige brugere</em> fra .NET / C# med WCF. Vejledningerne på <a title="Interessent-sitet" href="https://toolkit.netcompany.com/DMR_projektsite/default.aspx">interessent-sitet</a> er ikke særligt brugbare.</p>
<p>Derfor har jeg valgt at lægge et lille <a title="testprojekt" href="https://dl.dropbox.com/u/4472595/SekundaereErhvervsmaessigeBruger.zip">testprojekt</a> ud, som kræver minimale tilretninger. Du skal bruge et gyldigt certifikat fra SKAT (som også er aktiveret hos SKAT) og du skal bruge service/server-certifikatet, som ligger på <a title="Interessent-sitet" href="https://toolkit.netcompany.com/DMR_projektsite/default.aspx">interessent-sitet</a> i Dokumenter-&gt;Produktionscertifikater (dmr_virksomhedscertifikat_prod).</p>
<p>Efter installation af begge på klientsiden behøver du kun at ændre thumbprintet i app.config under clientCertificate findValue=&#8221;<strong>&#8230;</strong>&#8221; til jeres udstedte certifikats thumbprint. Pas på ved kopiering fra certifikatdetaljerne et usynligt tegn i slutningen af thumbprintet kan let snige sig med.</p>
<p>ADVARSEL: flere forskellige sikkerhedsforanstaltninger er slået fra i testprojektet, disse skal naturligvis være slået til i produktion.</p>
<div class='wpfblike' style='height: 40px;'><fb:like href='http://codeblog.larsholm.net/2012/08/danish-post-dmr-webservice-fra-net-c/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div>]]></content:encoded>
			<wfw:commentRss>http://codeblog.larsholm.net/2012/08/danish-post-dmr-webservice-fra-net-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# string to alphanumeric</title>
		<link>http://codeblog.larsholm.net/2011/06/c-string-to-alphanumeric/</link>
		<comments>http://codeblog.larsholm.net/2011/06/c-string-to-alphanumeric/#comments</comments>
		<pubDate>Thu, 16 Jun 2011 19:32:29 +0000</pubDate>
		<dc:creator>larsholm</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[alphanumeric]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[digits]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://codeblog.larsholm.net/?p=108</guid>
		<description><![CDATA[Short and easy way to get the alphanumeric content of a string: public static string ToAlphaNumeric(this string str) { return new string(str.Where(c => char.IsLetterOrDigit(c)).ToArray()); }]]></description>
			<content:encoded><![CDATA[<p>Short and easy way to get the alphanumeric content of a string:</p>
<pre class="brush: csharp">
public static string ToAlphaNumeric(this string str)
{
    return new string(str.Where(c => char.IsLetterOrDigit(c)).ToArray());
}
</pre>
<div class='wpfblike' style='height: 40px;'><fb:like href='http://codeblog.larsholm.net/2011/06/c-string-to-alphanumeric/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div>]]></content:encoded>
			<wfw:commentRss>http://codeblog.larsholm.net/2011/06/c-string-to-alphanumeric/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Persist .NET objects to XML</title>
		<link>http://codeblog.larsholm.net/2011/06/persist-net-objects-to-xml/</link>
		<comments>http://codeblog.larsholm.net/2011/06/persist-net-objects-to-xml/#comments</comments>
		<pubDate>Thu, 16 Jun 2011 19:06:08 +0000</pubDate>
		<dc:creator>larsholm</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[persist]]></category>
		<category><![CDATA[serialize]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://codeblog.larsholm.net/?p=96</guid>
		<description><![CDATA[Here&#8217;s two extensions I use to easily persist objects to XML string in C#. Although it looks like it, it does not seem to require that the class of the object is decorated with the DataContract attribute, it just works. public static string ToXml(this object o) { StringWriter sw = new StringWriter(); XmlWriter xw = [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s two extensions I use to easily persist objects to XML string in C#. Although it looks like it, it does not seem to require that the class of the object is decorated with the DataContract attribute, it just works.</p>
<pre class="brush: csharp">
public static string ToXml(this object o)
{
    StringWriter sw = new StringWriter();
    XmlWriter xw = XmlWriter.Create(sw);
    DataContractSerializer dcs = new DataContractSerializer(o.GetType());
    dcs.WriteObject(xw, o);
    xw.Close();
    return sw.ToString();
}

public static T FromXmlTo<T>(this string s) where T : class
{
    DataContractSerializer dcs = new DataContractSerializer(typeof(T));

    StringReader sr = new StringReader(s);
    XmlReader xtr = XmlReader.Create(sr);

    return dcs.ReadObject(xtr) as T;
}
</pre>
<p>Let me here how it works out for you guys..</p>
<div class='wpfblike' style='height: 40px;'><fb:like href='http://codeblog.larsholm.net/2011/06/persist-net-objects-to-xml/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div>]]></content:encoded>
			<wfw:commentRss>http://codeblog.larsholm.net/2011/06/persist-net-objects-to-xml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Embed managed dlls easily in a .NET assembly</title>
		<link>http://codeblog.larsholm.net/2011/06/embed-dlls-easily-in-a-net-assembly/</link>
		<comments>http://codeblog.larsholm.net/2011/06/embed-dlls-easily-in-a-net-assembly/#comments</comments>
		<pubDate>Wed, 15 Jun 2011 18:10:57 +0000</pubDate>
		<dc:creator>larsholm</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[assembly]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[dll]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[include]]></category>
		<category><![CDATA[merge]]></category>
		<category><![CDATA[resources]]></category>

		<guid isPermaLink="false">http://codeblog.larsholm.net/?p=76</guid>
		<description><![CDATA[Here&#8217;s a very quick and dirty way to include managed dlls in your .exe-file. Just right-click your project in Visual Studio, choose Project Properties -&#62; Resources -&#62; Add Resource -&#62; Add Existing File&#8230; Add all your dependencies and finally include the code below in your App.xaml.cs or equivalent.. everything else is taken care of. public [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a very quick and dirty way to include managed dlls in your .exe-file. Just right-click your project in Visual Studio, choose <em>Project Properties -&gt; Resources -&gt; Add Resource -&gt; Add Existing File</em>&#8230;</p>
<p>Add all your dependencies and finally include the code below in your App.xaml.cs or equivalent.. everything else is taken care of.</p>
<pre class="brush: csharp">public App()
{
    AppDomain.CurrentDomain.AssemblyResolve +=new ResolveEventHandler(CurrentDomain_AssemblyResolve);
}

System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
    string dllName = args.Name.Contains(',') ? args.Name.Substring(0, args.Name.IndexOf(',')) : args.Name.Replace(".dll","");

    dllName = dllName.Replace(".", "_");

    if (dllName.EndsWith("_resources")) return null;

    System.Resources.ResourceManager rm = new System.Resources.ResourceManager(GetType().Namespace + ".Properties.Resources", System.Reflection.Assembly.GetExecutingAssembly());

    byte[] bytes = (byte[])rm.GetObject(dllName);

    return System.Reflection.Assembly.Load(bytes);
}</pre>
<p>The code is a little bit more complicated than need be. But I wanted to avoid using a named namespace in order to keep the code copy-paste-ready. By the way LINQPad uses a similar method, though Joe Albahari has gone a step further and encrypted his resources.</p>
<div class='wpfblike' style='height: 40px;'><fb:like href='http://codeblog.larsholm.net/2011/06/embed-dlls-easily-in-a-net-assembly/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div>]]></content:encoded>
			<wfw:commentRss>http://codeblog.larsholm.net/2011/06/embed-dlls-easily-in-a-net-assembly/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Avoid incorrect Silverlight XAP file caching</title>
		<link>http://codeblog.larsholm.net/2010/02/avoid-incorrect-caching-of-silverlight-xap-file/</link>
		<comments>http://codeblog.larsholm.net/2010/02/avoid-incorrect-caching-of-silverlight-xap-file/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 18:06:21 +0000</pubDate>
		<dc:creator>larsholm</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[force]]></category>
		<category><![CDATA[iis]]></category>
		<category><![CDATA[issue]]></category>
		<category><![CDATA[prevent]]></category>
		<category><![CDATA[problem]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[re-download]]></category>
		<category><![CDATA[stop]]></category>
		<category><![CDATA[xap]]></category>

		<guid isPermaLink="false">http://codeblog.larsholm.net/?p=49</guid>
		<description><![CDATA[The code below appends the last-write filedate of the Silverlight Application XAP file to the path in the source parametre of the Silverlight object tag. This will ensure that poorly constructed caching functionality of webbrowsers and proxy servers doesn&#8217;t incorrectly use old, wrong builds of the XAP file. However it will still allow these caches [...]]]></description>
			<content:encoded><![CDATA[<p>The code below appends the last-write filedate of the Silverlight Application XAP file to the path in the source parametre of the Silverlight object tag.<br />
This will ensure that poorly constructed caching functionality of webbrowsers and proxy servers doesn&#8217;t incorrectly use old, wrong builds of the XAP file.<br />
However it will still allow these caches to work. Furthermore a check is performed to avoid XAP file path alteration during debugging, this is to allow debugging tools such as Silverlight Spy to continue functioning.</p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 10.0pt; font-family: &amp;amp;amp; color: blue; mso-ansi-language: EN-US; mso-no-proof: yes;" lang="EN-US">&lt;</span><span style="font-size: 10.0pt; font-family: &amp;amp;amp; color: #a31515; mso-ansi-language: EN-US; mso-no-proof: yes;" lang="EN-US">object</span><span style="font-size: 10.0pt; font-family: &amp;amp;amp; mso-ansi-language: EN-US; mso-no-proof: yes;" lang="EN-US"> <span style="color: red;">id</span><span style="color: blue;">=&quot;Xaml1&quot;</span> <span style="color: red;">data</span><span style="color: blue;">=&quot;data:application/x-silverlight-2,&quot;</span> <span style="color: red;">type</span><span style="color: blue;">=&quot;application/x-silverlight-2&quot;</span></span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 10.0pt; font-family: &amp;amp;amp; mso-ansi-language: EN-US; mso-no-proof: yes;" lang="EN-US"><span style="color: blue;"><span style="color: #000000;"><span style="color: red;">width</span><span style="color: blue;">=&quot;100%&quot; <span style="color: #000000;"><span style="color: red;">height</span><span style="color: blue;">=&quot;100%&quot;&gt;</span></span></span></span></span></span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 10.0pt; font-family: &amp;amp;amp; mso-ansi-language: EN-US; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;"> </span><span style="background: yellow; mso-highlight: yellow;">&lt;%</span><span style="color: green;">&#8211;&#8211;&lt;param name=&quot;source&quot; value=&quot;ClientBin/SilverlightApp.xap&quot;/&gt;&#8211;&#8211;</span><span style="background: yellow; mso-highlight: yellow;">%&gt;</span></span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 10.0pt; font-family: &amp;amp;amp; mso-ansi-language: EN-US; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;"> </span><span style="background: yellow; mso-highlight: yellow;">&lt;%</span></span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; padding-left: 30px;"><span style="font-size: 10.0pt; font-family: &amp;amp;amp; mso-ansi-language: EN-US; mso-no-proof: yes;" lang="EN-US"><span style="color: blue;"> string</span> orgSourceValue = <span style="color: #a31515;">@&quot;ClientBin/SilverlightApp.xap&quot;</span>;</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; padding-left: 30px;"><span style="font-size: 10.0pt; font-family: &amp;amp;amp; mso-ansi-language: EN-US; mso-no-proof: yes;" lang="EN-US"><span style="color: blue;"> string</span> param;</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; padding-left: 30px;"><span style="font-size: 10.0pt; font-family: &amp;amp;amp; mso-ansi-language: EN-US; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;"> </span><span style="color: blue;"> if</span> (System.Diagnostics.<span style="color: #2b91af;">Debugger</span>.IsAttached)</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; padding-left: 60px;"><span style="font-size: 10.0pt; font-family: &amp;amp;amp; mso-ansi-language: EN-US; mso-no-proof: yes;" lang="EN-US"> param = <span style="color: #a31515;">&quot;&lt;param name=\&quot;source\&quot; value=\&quot;&quot;</span> + orgSourceValue + <span style="color: #a31515;">&quot;\&quot; /&gt;&quot;</span>;</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; padding-left: 30px;"><span style="font-size: 10.0pt; font-family: &amp;amp;amp; mso-ansi-language: EN-US; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;"> </span><span style="color: blue;"> else</span></span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; padding-left: 30px;"><span style="font-size: 10.0pt; font-family: &amp;amp;amp; mso-ansi-language: EN-US; mso-no-proof: yes;" lang="EN-US"> {</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; padding-left: 60px;"><span style="font-size: 10.0pt; font-family: &amp;amp;amp; mso-ansi-language: EN-US; mso-no-proof: yes;" lang="EN-US"><span style="color: blue;"> string</span> xappath = <span style="color: #2b91af;">HttpContext</span>.Current.Server.MapPath(<span style="color: #a31515;">@&quot;&quot;</span>) + <span style="color: #a31515;">@&quot;\&quot; </span>+ orgSourceValue;</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; padding-left: 60px;"><span style="font-size: 10.0pt; font-family: &amp;amp;amp; mso-ansi-language: EN-US; mso-no-proof: yes;" lang="EN-US"><span style="color: #2b91af;"> DateTime</span> xapCreationDate = System.IO.<span style="color: #2b91af;">File</span>.GetLastWriteTime(xappath);</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; padding-left: 60px;"><span style="font-size: 10.0pt; font-family: &amp;amp;amp; mso-ansi-language: EN-US; mso-no-proof: yes;" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; padding-left: 60px;"><span style="font-size: 10.0pt; font-family: &amp;amp;amp; mso-ansi-language: EN-US; mso-no-proof: yes;" lang="EN-US"> param = <span style="color: #a31515;">&quot;&lt;param name=\&quot;source\&quot; value=\&quot;&quot;</span> + orgSourceValue + <span style="color: #a31515;">&quot;?ignore=&quot;</span></span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; padding-left: 60px;"><span style="font-size: 10.0pt; font-family: &amp;amp;amp; mso-ansi-language: EN-US; mso-no-proof: yes;" lang="EN-US"><span style="color: #a31515;"> </span>+ xapCreationDate.ToString() + <span style="color: #a31515;">&quot;\&quot; /&gt;&quot;</span>;</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; padding-left: 30px;"><span style="font-size: 10.0pt; font-family: &amp;amp;amp; mso-ansi-language: EN-US; mso-no-proof: yes;" lang="EN-US"> </span><span style="font-size: 10.0pt; font-family: &amp;amp;amp; mso-no-proof: yes;"> }</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; padding-left: 30px;"><span style="font-size: 10.0pt; font-family: &amp;amp;amp; mso-no-proof: yes;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; padding-left: 30px;"><span style="font-size: 10.0pt; font-family: &amp;amp;amp; mso-no-proof: yes;"> Response.Write(param);</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 10.0pt; font-family: &amp;amp;amp; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="background: yellow; mso-highlight: yellow;">%&gt;</span></span></p>
<p class="MsoNormal" style="tab-stops: 418.5pt;"><span style="font-size: 10.0pt; line-height: 115%; font-family: &amp;amp;amp; mso-ansi-language: EN-US; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">param</span> <span style="color: red;">name</span><span style="color: blue;">=&quot;onError&quot;</span><span style="color: blue;"> </span><span style="color: red;">value</span><span style="color: blue;">=&quot;onSilverlightError&quot;</span><span style="color: blue;"> </span><span style="color: blue;">/&gt;<span style="mso-tab-count: 1;"> </span></span></span></p>
<div class='wpfblike' style='height: 40px;'><fb:like href='http://codeblog.larsholm.net/2010/02/avoid-incorrect-caching-of-silverlight-xap-file/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div>]]></content:encoded>
			<wfw:commentRss>http://codeblog.larsholm.net/2010/02/avoid-incorrect-caching-of-silverlight-xap-file/feed/</wfw:commentRss>
		<slash:comments>44</slash:comments>
		</item>
		<item>
		<title>FocusHelper</title>
		<link>http://codeblog.larsholm.net/2009/12/focushelper/</link>
		<comments>http://codeblog.larsholm.net/2009/12/focushelper/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 16:46:05 +0000</pubDate>
		<dc:creator>larsholm</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[element]]></category>
		<category><![CDATA[focused]]></category>
		<category><![CDATA[highlight]]></category>
		<category><![CDATA[timer]]></category>

		<guid isPermaLink="false">http://codeblog.larsholm.net/?p=35</guid>
		<description><![CDATA[Here is a little helper class I use when implementing tab navigation in Silverlight. When FocusHelper.Start() is called at application startup it simply creates a timer which attempts to give the focused element a red border and a slightly red background. When I say attempts it&#8217;s because themes and styles may prevent the changes from showing. I have [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a little helper class I use when implementing tab navigation in Silverlight. When FocusHelper.Start() is called at application startup it simply creates a timer which attempts to give the focused element a red border and a slightly red background. When I say attempts it&#8217;s because themes and styles may prevent the changes from showing. I have often found it helpful, because it is almost never clear which element in Silverlight has the focus. Notice that the functionality is disabled if your browser&#8217;s zoom is different from 100%.</p>
<div style="font-family: Courier New; font-size: 10pt; color: black; background: white;">
<pre style="margin: 0px;"><span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">FocusHelper</span></pre>
<pre style="margin: 0px;">{</pre>
<pre style="margin: 0px;">    <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">void</span> Start()</pre>
<pre style="margin: 0px;">    {</pre>
<pre style="margin: 0px;">        focusBorderBrush = <span style="color: blue;">new</span> SolidColorBrush(Colors.Red);</pre>
<pre style="margin: 0px;">        focusBackground = <span style="color: blue;">new</span> SolidColorBrush(Colors.Red);</pre>
<pre style="margin: 0px;">        focusBackground.Opacity = 0.1;</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;">        focusTimer = <span style="color: blue;">new</span> <span style="color: #2b91af;">Timer</span>(<span style="color: blue;">new</span> <span style="color: #2b91af;">TimerCallback</span>((o) =&gt;</pre>
<pre style="margin: 0px;">        {</pre>
<pre style="margin: 0px;">            <span style="color: blue;">try</span></pre>
<pre style="margin: 0px;">            {</pre>
<pre style="margin: 0px;">                System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =&gt;</pre>
<pre style="margin: 0px;">                {</pre>
<pre style="margin: 0px;">                    <span style="color: blue;">object</span> temp = <span style="color: blue;">null</span>;</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;">                    <span style="color: blue;">if</span> (System.Windows.Application.Current.Host.Content.ZoomFactor==1)</pre>
<pre style="margin: 0px;">                        temp = FocusManager.GetFocusedElement();</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;">                    <span style="color: blue;">if</span> (temp != lastFocus)</pre>
<pre style="margin: 0px;">                    {</pre>
<pre style="margin: 0px;">                        <span style="color: blue;">if</span> (temp <span style="color: blue;">is</span> Control)</pre>
<pre style="margin: 0px;">                        {</pre>
<pre style="margin: 0px;">                            <span style="color: green;">//Give the last control back its original color</span></pre>
<pre style="margin: 0px;">                            <span style="color: blue;">if</span> (lastFocus != <span style="color: blue;">null</span>)</pre>
<pre style="margin: 0px;">                            {</pre>
<pre style="margin: 0px;">                                lastFocus.BorderBrush = lastBrush;</pre>
<pre style="margin: 0px;">                                lastFocus.BorderThickness = lastThickness;</pre>
<pre style="margin: 0px;">                                lastFocus.Background = lastBackground;</pre>
<pre style="margin: 0px;">                            }</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;">                            lastFocus = temp <span style="color: blue;">as</span> Control;</pre>
<pre style="margin: 0px;">                            lastBrush = lastFocus.BorderBrush;</pre>
<pre style="margin: 0px;">                            lastThickness = lastFocus.BorderThickness;</pre>
<pre style="margin: 0px;">                            lastBackground = lastFocus.Background;</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;">                            lastFocus.BorderBrush = focusBorderBrush;</pre>
<pre style="margin: 0px;">                            lastFocus.BorderThickness = <span style="color: blue;">new</span> Thickness(1);</pre>
<pre style="margin: 0px;">                            lastFocus.Background = focusBackground;</pre>
<pre style="margin: 0px;">                        }</pre>
<pre style="margin: 0px;">                    }</pre>
<pre style="margin: 0px;">                });</pre>
<pre style="margin: 0px;">            }</pre>
<pre style="margin: 0px;">            <span style="color: blue;">catch</span></pre>
<pre style="margin: 0px;">            {</pre>
<pre style="margin: 0px;">            }</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;">        }), <span style="color: blue;">null</span>, 0, 100);</pre>
<pre style="margin: 0px;">    }</pre>
<pre style="margin: 0px;"> </pre>
<pre style="margin: 0px;">    <span style="color: blue;">private</span> <span style="color: blue;">static</span> System.Threading.<span style="color: #2b91af;">Timer</span> focusTimer;</pre>
<pre style="margin: 0px;">    <span style="color: blue;">private</span> <span style="color: blue;">static</span> Control lastFocus = <span style="color: blue;">null</span>;</pre>
<pre style="margin: 0px;">    <span style="color: blue;">private</span> <span style="color: blue;">static</span> Thickness lastThickness;</pre>
<pre style="margin: 0px;">    <span style="color: blue;">private</span> <span style="color: blue;">static</span> Brush lastBrush;</pre>
<pre style="margin: 0px;">    <span style="color: blue;">private</span> <span style="color: blue;">static</span> Brush lastBackground;</pre>
<pre style="margin: 0px;">    <span style="color: blue;">private</span> <span style="color: blue;">static</span> Brush focusBorderBrush;</pre>
<pre style="margin: 0px;">    <span style="color: blue;">private</span> <span style="color: blue;">static</span> Brush focusBackground;</pre>
<pre style="margin: 0px;">}</pre>
</div>
<div class='wpfblike' style='height: 40px;'><fb:like href='http://codeblog.larsholm.net/2009/12/focushelper/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div>]]></content:encoded>
			<wfw:commentRss>http://codeblog.larsholm.net/2009/12/focushelper/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PostponingTimer</title>
		<link>http://codeblog.larsholm.net/2009/12/postponingtimer/</link>
		<comments>http://codeblog.larsholm.net/2009/12/postponingtimer/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 22:55:06 +0000</pubDate>
		<dc:creator>larsholm</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[delay]]></category>
		<category><![CDATA[expression]]></category>
		<category><![CDATA[job]]></category>
		<category><![CDATA[lambda]]></category>
		<category><![CDATA[postpone]]></category>
		<category><![CDATA[task]]></category>
		<category><![CDATA[timer]]></category>

		<guid isPermaLink="false">http://codeblog.larsholm.net/?p=28</guid>
		<description><![CDATA[This is a small timer class that I have found useful a couple of times. It takes a job and a timeout in its Run() method, which it executes after the timeout, unless you call the Run() method again, in which case it postpones the execution of the job. I have mostly used this in [...]]]></description>
			<content:encoded><![CDATA[<div style="font-family: Courier New; font-size: 10pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: #000000;">This is a small timer class that I have found useful a couple of times.</span></p>
<p style="margin: 0px;"><span style="color: #000000;">It takes a job and a timeout in its Run() method, which it executes</span></p>
<p style="margin: 0px;"><span style="color: #000000;">after the timeout, unless you call the Run() method again, in which</span></p>
<p style="margin: 0px;"><span style="color: #000000;">case it postpones the execution of the job. I have mostly used this</span></p>
<p style="margin: 0px;"><span style="color: #000000;">in connection with some type of user input. For instance, doing</span></p>
<p style="margin: 0px;"><span style="color: #000000;">something when there has been a sufficient pause in scrolling or typing.</span></p>
<p style="margin: 0px;"><span style="color: gray;"> </span></p>
<p style="margin: 0px;"><span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;"><span style="color: gray;">///</span><span style="color: green;"> This class can be used to execute a job just once after a specified</span></p>
<p style="margin: 0px;"><span style="color: gray;">///</span><span style="color: green;"> time since the last of a series of events has fired.</span></p>
<p style="margin: 0px;"><span style="color: gray;">///</span><span style="color: green;"> For instance, when implementing an Auto-Save feature in a textbox you</span></p>
<p style="margin: 0px;"><span style="color: gray;">///</span><span style="color: green;"> might want to avoid saving on every keypress event. In this case you can</span></p>
<p style="margin: 0px;"><span style="color: gray;">///</span><span style="color: green;"> call Run(() =&gt; Save(), 5000) in each keypress event. The PostPoningTimer</span></p>
<p style="margin: 0px;"><span style="color: gray;">///</span><span style="color: green;"> will then make sure that Save() is executed one time when 5 seconds has</span></p>
<p style="margin: 0px;"><span style="color: gray;">///</span><span style="color: green;"> past since the last keypress event. Any new keypresses will of course</span></p>
<p style="margin: 0px;"><span style="color: gray;">///</span><span style="color: green;"> repeat the process.</span></p>
<p style="margin: 0px;"><span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">PostponingTimer</span></p>
<p style="margin: 0px;">{</p>
<p style="margin: 0px;">    <span style="color: blue;">private</span> Timer timer;</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">    <span style="color: blue;">private</span> Dispatcher CurrentDispatcher</p>
<p style="margin: 0px;">    {</p>
<p style="margin: 0px;">        <span style="color: blue;">get</span></p>
<p style="margin: 0px;">        {</p>
<p style="margin: 0px;"><span style="color: blue;">#if</span> SILVERLIGHT</p>
<p style="margin: 0px;"><span style="color: gray;">            return System.Windows.Deployment.Current.Dispatcher;</span></p>
<p style="margin: 0px;"><span style="color: blue;">#else</span></p>
<p style="margin: 0px;">            <span style="color: blue;">return</span> Dispatcher.CurrentDispatcher;</p>
<p style="margin: 0px;"><span style="color: blue;">#endif</span></p>
<p style="margin: 0px;">        }</p>
<p style="margin: 0px;">    }</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">    <span style="color: blue;">private</span> <span style="color: blue;">void</span> Execute(Action job, Dispatcher dispatcher)</p>
<p style="margin: 0px;">    {</p>
<p style="margin: 0px;"><span style="color: blue;">#if</span> SILVERLIGHT</p>
<p style="margin: 0px;"><span style="color: gray;">        dispatcher.BeginInvoke(job);</span></p>
<p style="margin: 0px;"><span style="color: blue;">#else</span></p>
<p style="margin: 0px;">        dispatcher.Invoke(job);</p>
<p style="margin: 0px;"><span style="color: blue;">#endif</span></p>
<p style="margin: 0px;">    }</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> If you keep calling Run() within timeout, job never gets executed.</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> Only when you stop calling Run() job will run once after timeout</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> milliseconds.</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;para&gt;</span><span style="color: green;">Job will run on calling threads dispatcher. If in silverlight</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> the UI threads dispatcher is used.</span><span style="color: gray;">&lt;/para&gt;</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&#8221;job&#8221;&gt;&lt;/param&gt;</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&#8221;timeout&#8221;&gt;&lt;/param&gt;</span></p>
<p style="margin: 0px;">    <span style="color: blue;">public</span> <span style="color: blue;">void</span> Run(Action job, <span style="color: blue;">int</span> timeout)</p>
<p style="margin: 0px;">    {</p>
<p style="margin: 0px;">        <span style="color: green;">//Make sure the timer from last call is prevented from running.</span></p>
<p style="margin: 0px;">        <span style="color: blue;">if</span> (timer != <span style="color: blue;">null</span>) timer.Dispose();</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">        <span style="color: green;">//When not in SILVERLIGHT the line below makes sure to use the</span></p>
<p style="margin: 0px;">        <span style="color: green;">//dispatcher of the calling thread.</span></p>
<p style="margin: 0px;">        <span style="color: green;">//In silverlight the UI thread dispatcher is used.</span></p>
<p style="margin: 0px;">        Dispatcher dispatcher = CurrentDispatcher;</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">        timer = <span style="color: blue;">new</span> Timer(<span style="color: blue;">new</span> TimerCallback((o) =&gt;</p>
<p style="margin: 0px;">            {</p>
<p style="margin: 0px;">                Execute(job, dispatcher);</p>
<p style="margin: 0px;">            }), <span style="color: blue;">null</span>, timeout, Timeout.Infinite);</p>
<p style="margin: 0px;">    }</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> If you keep calling Run() within timeout, job never gets executed.</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> Only when you stop calling Run() job will run once after timeout</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> milliseconds.</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;para&gt;</span><span style="color: green;">Job will run on the timer&#8217;s thread.</span><span style="color: gray;">&lt;/para&gt;</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&#8221;job&#8221;&gt;&lt;/param&gt;</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&#8221;timeout&#8221;&gt;&lt;/param&gt;</span></p>
<p style="margin: 0px;">    <span style="color: blue;">public</span> <span style="color: blue;">void</span> RunNonUI(Action job, <span style="color: blue;">int</span> timeout)</p>
<p style="margin: 0px;">    {</p>
<p style="margin: 0px;">        <span style="color: green;">//Make sure the timer from last call is prevented from running.</span></p>
<p style="margin: 0px;">        <span style="color: blue;">if</span> (timer != <span style="color: blue;">null</span>) timer.Dispose();</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">        timer = <span style="color: blue;">new</span> Timer(<span style="color: blue;">new</span> TimerCallback((o) =&gt;</p>
<p style="margin: 0px;">            {</p>
<p style="margin: 0px;">                job();</p>
<p style="margin: 0px;">            }), <span style="color: blue;">null</span>, timeout, Timeout.Infinite);</p>
<p style="margin: 0px;">    }</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> If you keep calling Run() within timeout, job never gets executed.</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> Only when you stop calling Run() job will run once after timeout</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> milliseconds.</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;para&gt;</span><span style="color: green;">Actions will run on calling threads dispatcher. If in</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> silverlight the UI threads dispatcher is used.</span><span style="color: gray;">&lt;/para&gt;</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&#8221;job&#8221;&gt;&lt;/param&gt;</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&#8221;timeout&#8221;&gt;&lt;/param&gt;</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&#8221;callback&#8221;&gt;&lt;/param&gt;</span></p>
<p style="margin: 0px;">    <span style="color: blue;">public</span> <span style="color: blue;">void</span> Run(Action job, <span style="color: blue;">int</span> timeout, Action callback)</p>
<p style="margin: 0px;">    {</p>
<p style="margin: 0px;">        <span style="color: green;">//Make sure the timer from last call is prevented from running.</span></p>
<p style="margin: 0px;">        <span style="color: blue;">if</span> (timer != <span style="color: blue;">null</span>) timer.Dispose();</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">        <span style="color: green;">//When not in SILVERLIGHT the line below makes sure to use the</span></p>
<p style="margin: 0px;">        <span style="color: green;">//dispatcher of the calling thread.</span></p>
<p style="margin: 0px;">        <span style="color: green;">//In silverlight the UI thread dispatcher is used.</span></p>
<p style="margin: 0px;">        Dispatcher dispatcher = CurrentDispatcher;</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">        timer = <span style="color: blue;">new</span> Timer(<span style="color: blue;">new</span> TimerCallback((o) =&gt;</p>
<p style="margin: 0px;">            {</p>
<p style="margin: 0px;">                Execute(job + callback, dispatcher);</p>
<p style="margin: 0px;">            }), <span style="color: blue;">null</span>, timeout, Timeout.Infinite);</p>
<p style="margin: 0px;">    }</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> If you keep calling Run() within timeout, job never gets executed.</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> Only when you stop calling Run() job will run once after timeout</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> milliseconds.</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;para&gt;</span><span style="color: green;">Actions will run on the timer&#8217;s thread.</span><span style="color: gray;">&lt;/para&gt;</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&#8221;job&#8221;&gt;&lt;/param&gt;</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&#8221;timeout&#8221;&gt;&lt;/param&gt;</span></p>
<p style="margin: 0px;">    <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&#8221;callback&#8221;&gt;&lt;/param&gt;</span></p>
<p style="margin: 0px;">    <span style="color: blue;">public</span> <span style="color: blue;">void</span> RunNonUI(Action job, <span style="color: blue;">int</span> timeout, Action callback)</p>
<p style="margin: 0px;">    {</p>
<p style="margin: 0px;">        <span style="color: green;">//Make sure the timer from last call is prevented from running.</span></p>
<p style="margin: 0px;">        <span style="color: blue;">if</span> (timer != <span style="color: blue;">null</span>) timer.Dispose();</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">        timer = <span style="color: blue;">new</span> Timer(<span style="color: blue;">new</span> TimerCallback((o) =&gt;</p>
<p style="margin: 0px;">            {</p>
<p style="margin: 0px;">                (job + callback)();</p>
<p style="margin: 0px;">            }), <span style="color: blue;">null</span>, timeout, Timeout.Infinite);</p>
<p style="margin: 0px;">    }</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">}</p>
</div>
<div class='wpfblike' style='height: 40px;'><fb:like href='http://codeblog.larsholm.net/2009/12/postponingtimer/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div>]]></content:encoded>
			<wfw:commentRss>http://codeblog.larsholm.net/2009/12/postponingtimer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Clean install of Windows 7 on your PDC 2009 Acer Tablet PC</title>
		<link>http://codeblog.larsholm.net/2009/12/newwindows7onpdc2009laptop/</link>
		<comments>http://codeblog.larsholm.net/2009/12/newwindows7onpdc2009laptop/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 22:09:21 +0000</pubDate>
		<dc:creator>larsholm</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codeblog.larsholm.net/?p=25</guid>
		<description><![CDATA[When I put an Intel SSD in the laptop I received at Microsoft PDC2009 I spend a lot of time trying to get the existing partitions moved to the new drive. I was convinced that this would be the easiest. I would have VS2010, Windows 7 activated, Office 2010, and all the drivers needed. However [...]]]></description>
			<content:encoded><![CDATA[<p>When I put an Intel SSD in the laptop I received at Microsoft PDC2009 I spend a lot of time trying to get the existing partitions moved to the new drive. I was convinced that this would be the easiest. I would have VS2010, Windows 7 activated, Office 2010, and all the drivers needed.</p>
<p>However after pretty much a whole weekend I gave up, having destroyed the MBRs of both disks and set a mixture of both Windows and Linux boot flags on random partitions. I was thinking that it would be another two days before I could enjoy my new laptop fortified with a 160 GB Intel SSD and an extra 2 gigs of ram, but then I stumpled upon this <a href="http://forum.notebookreview.com/showthread.php?t=433602"><strong>guide</strong></a> and after a very short time the little box was up and running.. with everything. New Windows 7, Drivers, VS, Office, LINQPad and so forth. All the drivers needed magically appeared in Windows Update, maybe not so weird, it sort of is a Microsoft laptop.</p>
<p>If I should do it again, here&#8217;s how (or in other words &#8217;my guide to the guide&#8217;):</p>
<p>Skip Step 1.</p>
<p>Optionally skip step 2. (I never seem to use restore images anyway)</p>
<p>Do step 3.</p>
<p>In step 4 choose <strong>B</strong> (Not really a choice) and I highly recommend <strong>Method 1</strong>. I don&#8217;t know why it says time consuming !? AH.. of course when formatting your new drive choose <em>quick format</em>. So in the <em>step 5 of the &#8217;How-to install Windows 7 from an USB stick&#8217; guide </em> the format line should be:</p>
<p>Format FS=FAT32 <strong>QUICK</strong></p>
<p>Please select the RIGHT DRIVE, that is; your new, presumably empty drive. Use an external HDD enclosure/case/thing.</p>
<p>In step 5 (of the main guide)</p>
<p>Ignore all talk about Vista.</p>
<p>Do step 6. For me section B failed because my default printer wasn&#8217;t working, so I chose the XPS printer, and it ran fine. All done.</p>
<div class='wpfblike' style='height: 40px;'><fb:like href='http://codeblog.larsholm.net/2009/12/newwindows7onpdc2009laptop/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div>]]></content:encoded>
			<wfw:commentRss>http://codeblog.larsholm.net/2009/12/newwindows7onpdc2009laptop/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ValueEquals() extension</title>
		<link>http://codeblog.larsholm.net/2009/09/valueequals-extension/</link>
		<comments>http://codeblog.larsholm.net/2009/09/valueequals-extension/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 23:44:44 +0000</pubDate>
		<dc:creator>larsholm</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[equality]]></category>
		<category><![CDATA[equals]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[value]]></category>

		<guid isPermaLink="false">http://codeblog.larsholm.net/?p=6</guid>
		<description><![CDATA[I have done what I almost never do. I have made an extension method. I don&#8217;t like extensions, I believe they increase code complexity and decrease code portability. Why allow static methods to disguise themselves as instance methods? Well, on the other hand Linq is awesome. Another move from Hejlsberg &#38; co. that I&#8217;m no [...]]]></description>
			<content:encoded><![CDATA[<p>I have done what I almost never do. I have made an extension method. I don&#8217;t like extensions, I believe they increase code complexity and decrease code portability.</p>
<p>Why allow static methods to disguise themselves as instance methods? Well, on the other hand Linq <em>is</em> awesome.</p>
<p>Another move from Hejlsberg &amp; co. that I&#8217;m no fan of, is that it is left to the creator of a class to decide if Equals() should mean that two objects are the same (ReferenceEquals()) or simply equal. And when I want the &#8216;equal&#8217; functionality, I have to implement it.</p>
<p>So I created this:</p>
<p>An extension method that recursively runs through all public fields and properties and check for value equality at node level. It does not support indexed properties, at least not yet and please notice that this uses the MoreLinq extensions.</p>
<div style="font-family: Courier New; font-size: 10pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;258</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">bool</span> ValueEquals(<span style="color: blue;">this</span> <span style="color: blue;">object</span> o, <span style="color: blue;">object</span> o2)</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;259</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;260</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #2b91af;">Type</span> oType = o.GetType();</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;261</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">if</span> (!oType.Equals(o2.GetType())) <span style="color: blue;">return</span> <span style="color: blue;">false</span>;</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;262</span>&nbsp;</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;263</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">if</span> (o == o2) <span style="color: blue;">return</span> <span style="color: blue;">true</span>;</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;264</span>&nbsp;</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;265</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">if</span> (o <span style="color: blue;">is</span> <span style="color: #2b91af;">ValueType</span> || o <span style="color: blue;">is</span> <span style="color: blue;">string</span>)</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;266</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;267</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">return</span> (o.Equals(o2));</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;268</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;269</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">else</span> <span style="color: blue;">if</span>(o <span style="color: blue;">is</span> <span style="color: #2b91af;">Array</span>)</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;270</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;271</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">return</span> (o <span style="color: blue;">as</span> <span style="color: #2b91af;">Array</span>).Cast&lt;<span style="color: blue;">object</span>&gt;().ZipLongest((o <span style="color: blue;">as</span> <span style="color: #2b91af;">Array</span>).Cast&lt;<span style="color: blue;">object</span>&gt;(), (i1, i2) =&gt; i1.ValueEquals(i2)).All(b =&gt; b);</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;272</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;273</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">else</span></p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;274</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;275</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">return</span> oType.GetFields().All(f =&gt;</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;276</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;277</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">object</span> v = f.GetValue(o);</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;278</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">if</span> (v == <span style="color: blue;">null</span>)</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;279</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;280</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">return</span> f.GetValue(o2) == <span style="color: blue;">null</span>;</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;281</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;282</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">else</span> <span style="color: blue;">if</span> (v <span style="color: blue;">is</span> <span style="color: #2b91af;">ValueType</span> || v <span style="color: blue;">is</span> <span style="color: blue;">string</span>)</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;283</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;284</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">return</span> v.Equals(f.GetValue(o2));</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;285</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;286</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">else</span></p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;287</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;288</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">return</span> v.ValueEquals(f.GetValue(o2));</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;289</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;290</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }) &amp;&amp;</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;291</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; oType.GetProperties().All(p =&gt;</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;292</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;293</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">object</span> v = <span style="color: blue;">null</span>;</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;294</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">try</span></p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;295</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;296</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; v = p.GetValue(o, <span style="color: blue;">null</span>);</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;297</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;298</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">catch</span> (<span style="color: #2b91af;">TargetParameterCountException</span>)</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;299</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;300</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">throw</span> <span style="color: blue;">new</span> <span style="color: #2b91af;">Exception</span>(<span style="color: #a31515;">&quot;Indexed properties are not supported yet&quot;</span>);</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;301</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;302</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">if</span> (v == <span style="color: blue;">null</span>)</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;303</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;304</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">return</span> p.GetValue(o2, <span style="color: blue;">null</span>) == <span style="color: blue;">null</span>;</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;305</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;306</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">else</span> <span style="color: blue;">if</span> (v <span style="color: blue;">is</span> <span style="color: #2b91af;">ValueType</span> || v <span style="color: blue;">is</span> <span style="color: blue;">string</span>)</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;307</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;308</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">return</span> v.Equals(p.GetValue(o2, <span style="color: blue;">null</span>));</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;309</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;310</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">else</span></p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;311</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;312</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">return</span> v.ValueEquals(p.GetValue(o2, <span style="color: blue;">null</span>));</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;313</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;314</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; });</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;315</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin: 0px;"><span style="color: #2b91af;">&nbsp;&nbsp;316</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
</div>
<p>Let me know how it works for you..</p>
<div class='wpfblike' style='height: 40px;'><fb:like href='http://codeblog.larsholm.net/2009/09/valueequals-extension/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div>]]></content:encoded>
			<wfw:commentRss>http://codeblog.larsholm.net/2009/09/valueequals-extension/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>BadImageFormatException</title>
		<link>http://codeblog.larsholm.net/2009/09/badimageformatexception/</link>
		<comments>http://codeblog.larsholm.net/2009/09/badimageformatexception/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 22:40:17 +0000</pubDate>
		<dc:creator>larsholm</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://codeblog.larsholm.net/?p=3</guid>
		<description><![CDATA[I have been running into some BadImageFormatException&#8217;s lately and I just discovered the reason today. I found out that I needed to change my targeted platform to the same platform as the assembly was build for, that&#8217;s it. Simply right-click the project in Visual Studio -&#62; Properties, Build -&#62; Platform target: [platform of assembly] It [...]]]></description>
			<content:encoded><![CDATA[<p>I have been running into some BadImageFormatException&#8217;s lately and I just discovered the reason today. I found out that I needed to change my targeted platform to the same platform as the assembly was build for, that&#8217;s it. Simply right-click the project in Visual Studio -&gt; Properties, Build -&gt; Platform target: [platform of assembly]</p>
<p>It solved the same issue I had with LINQPad, I rebuild my assembly and now it could be loaded. I run Windows 7 x64 so I rebuild my assembly to x64.</p>
<div class='wpfblike' style='height: 40px;'><fb:like href='http://codeblog.larsholm.net/2009/09/badimageformatexception/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div>]]></content:encoded>
			<wfw:commentRss>http://codeblog.larsholm.net/2009/09/badimageformatexception/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Object Caching 762/772 objects using disk: basic

Served from: codeblog.larsholm.net @ 2013-05-26 09:17:21 -->