<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Richard Szalay</title>
	<atom:link href="http://blog.richardszalay.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.richardszalay.com</link>
	<description>Walking down a country road, unaware of the sheep conspiring to kill me</description>
	<lastBuildDate>Fri, 23 Mar 2012 13:47:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.richardszalay.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Richard Szalay</title>
		<link>http://blog.richardszalay.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.richardszalay.com/osd.xml" title="Richard Szalay" />
	<atom:link rel='hub' href='http://blog.richardszalay.com/?pushpress=hub'/>
		<item>
		<title>Configuring TDD-style isolated tests for Windows Phone</title>
		<link>http://blog.richardszalay.com/2011/08/11/wp7-tdd/</link>
		<comments>http://blog.richardszalay.com/2011/08/11/wp7-tdd/#comments</comments>
		<pubDate>Thu, 11 Aug 2011 14:18:54 +0000</pubDate>
		<dc:creator>Richard Szalay</dc:creator>
				<category><![CDATA[unit-testing]]></category>
		<category><![CDATA[windows-phone]]></category>

		<guid isPermaLink="false">http://blog.richardszalay.com/?p=108</guid>
		<description><![CDATA[This article describes the setup instructions for configuring an environment to run isolated unit tests that are intended to run quicky, easily and often to enable test driven development. For integration tests that access isolated storage, web services or phone &#8230; <a href="http://blog.richardszalay.com/2011/08/11/wp7-tdd/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.richardszalay.com&amp;blog=16719208&amp;post=108&amp;subd=richardszalay&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This article describes the setup instructions for configuring an environment to run isolated unit tests that are intended to run quicky, easily and often to enable test driven development. For integration tests that access isolated storage, web services or phone features, see the <a href="http://wp7ci.codeplex.com">WP7-CI project</a>.</p>
<p>This configuration works with all features of the Silverlight Unit Testing framework, including <a href="http://blog.richardszalay.com/2011/08/08/writing-asynchronous-unit-tests-with-rx-and-the-silverlight-unit-testing-framework/">asynchronous tests</a>.</p>
<p><em>NOTE:</em> These instructions describe the setup for unit MSTest. Why? I personally prefer NUnit, but I use MSTest for my integration tests because of its support for asynchronous Silverlight tests and my preference for a consistant test framework trumps my preference for NUnit.</p>
<p>Before continuing, it is assumed that you have created a Windows Phone application.</p>
<h3>Adding a test project</h3>
<ol>
<li>Add a &#8220;Silverlight Class Library&#8221; project to your solution and select &#8220;Silverlight 4&#8243; as the version</li>
<li>Add a reference to your Windows Phone project</li>
<li>Add a reference to <strong>System.Xml</strong> and <strong>System.Windows.Browser</strong></li>
<li>Add a reference to <strong>Microsoft.Silverlight.Testing</strong> and <strong>Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight</strong> from the <a href="http://silverlight.codeplex.com/">Silverlight Toolkit</a> (not the WP7 version)</li>
</ol>
<h3>Referencing Windows Phone assemblies</h3>
<p>Since this is a Silverlight 4 project, accessing Phone assemblies should be avoided. However, some assemblies, like Microsoft.Phone.Reactive, may be necessary.</p>
<p>Since the assemblies won&#8217;t be in the &#8220;Target Framework Directory&#8221; (Silverlight 4 in this project), you have two choices on how you reference them:</p>
<ol>
<li>Copy the assemblies to your project from <em>%programfiles%\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\Profile\WindowsPhone</em> <sup>1</sup> and reference them from there</li>
<li>Add the following snippet to your tests project file after the &lt;ProjectExtensions&gt; that contains &lt;SilverlightProjectProperties&gt; and reference the assemblies from their original location.</li>
</ol>
<p><pre class="brush: xml;">
&lt;PropertyGroup&gt;
  &lt;WindowsPhoneFrameworkDirectory Condition=&quot; '$(WindowsPhoneFrameworkDirectory)' == '' &quot;&gt;
    $(FrameworkPathOverride)\Profile\WindowsPhone
  &lt;/WindowsPhoneFrameworkDirectory&gt;
  &lt;ResolveAssemblyReferencesDependsOn&gt;
    $(ResolveAssemblyReferencesDependsOn);AppendWindowsPhoneAssemblyPath
  &lt;/ResolveAssemblyReferencesDependsOn&gt;
&lt;/PropertyGroup&gt;
&lt;Target Name=&quot;AppendWindowsPhoneAssemblyPath&quot;&gt;
  &lt;PropertyGroup&gt;
    &lt;AssemblySearchPaths&gt;
      $(AssemblySearchPaths);$(WindowsPhoneFrameworkDirectory)
    &lt;/AssemblySearchPaths&gt;
  &lt;/PropertyGroup&gt;
&lt;/Target&gt;
</pre></p>
<p>Either way, <u>you must make sure <strong>Copy Local</strong> is set to <strong>true</strong> for any Windows Phone specific assemblies</u></p>
<p><sup>1</sup> For Mango, use <em>%programfiles%\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\Profile\WindowsPhone71</em></p>
<h3>Adding a simple test</h3>
<p>For the sake of having a test to run, let&#8217;s create a simple one now.</p>
<p>Create a class called &#8220;SampleTest&#8221;:</p>
<p><pre class="brush: csharp;">
using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass]
public class SampleTest
{
    [TestMethod]
    public void AlwaysPasses()
    {
        Assert.IsTrue(true);
    }
}
</pre></p>
<h3>Running the tests from Visual Studio</h3>
<ul>
<li><strong>Visual Studio Test</strong>: Silverlight tests are not supported by the built in test runner</li>
<li><strong>TestDriven.NET</strong>: Run as Silverlight tests
<li><strong>ReSharper</strong>: Install the <a href="http://agunit.codeplex.com/">AgUnit plugin</a> (you might need to disable the MSTest plugin for AgUnit to work correctly)
</ul>
<h3>Running the tests from the command line (or CI server)</h3>
<p>Use the StatLight command line utility:</p>
<p><code>statlight.exe -d="path\to\assembly.dll" -o=MSTest -v=Feb2011 -r="path\to\log.xml"</code></p>
<p>By default, StatLight outputs the results in its own format. Alternatively, you can:</p>
<ul>
<li>Use the &#8220;-MSGenericTestFormat&#8221; flag to output in MSTest&#8217;s output format</li>
<li>Use the <a href="https://github.com/andywhitfield/StatLightToNUnitReportGenerator">StatLight To NUnit Report Generator</a> to convert the default output to the NUnit format</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/richardszalay.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/richardszalay.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/richardszalay.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/richardszalay.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/richardszalay.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/richardszalay.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/richardszalay.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/richardszalay.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/richardszalay.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/richardszalay.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/richardszalay.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/richardszalay.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/richardszalay.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/richardszalay.wordpress.com/108/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.richardszalay.com&amp;blog=16719208&amp;post=108&amp;subd=richardszalay&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.richardszalay.com/2011/08/11/wp7-tdd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7eaba3dd7c0fdce655ab50f001f23cc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">richardszalay</media:title>
		</media:content>
	</item>
		<item>
		<title>Writing asynchronous unit tests with Rx and the Silverlight Unit Testing Framework</title>
		<link>http://blog.richardszalay.com/2011/08/08/writing-asynchronous-unit-tests-with-rx-and-the-silverlight-unit-testing-framework/</link>
		<comments>http://blog.richardszalay.com/2011/08/08/writing-asynchronous-unit-tests-with-rx-and-the-silverlight-unit-testing-framework/#comments</comments>
		<pubDate>Mon, 08 Aug 2011 13:40:43 +0000</pubDate>
		<dc:creator>Richard Szalay</dc:creator>
				<category><![CDATA[Rx]]></category>
		<category><![CDATA[unit-testing]]></category>
		<category><![CDATA[windows-phone]]></category>

		<guid isPermaLink="false">http://blog.richardszalay.com/?p=93</guid>
		<description><![CDATA[The Reactive Extensions provide a great way for composing asynchronous actions, particularly on Windows Phone where IO operations are asynchronous-only. The Silverlight Unit Testing framework (including my CI-supporting port) supports asynchronous unit tests, but if you&#8217;ve attempted to use them &#8230; <a href="http://blog.richardszalay.com/2011/08/08/writing-asynchronous-unit-tests-with-rx-and-the-silverlight-unit-testing-framework/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.richardszalay.com&amp;blog=16719208&amp;post=93&amp;subd=richardszalay&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The Reactive Extensions provide a great way for composing asynchronous actions, particularly on Windows Phone where IO operations are asynchronous-only. </p>
<p>The Silverlight Unit Testing framework (including <a href="http://wp7ci.codeplex.com/">my CI-supporting port</a>) supports asynchronous unit tests, but if you&#8217;ve attempted to use them with Rx you&#8217;ve likely run into a few problems.</p>
<h3>Avoiding asynchronous tests</h3>
<p>In reality, the simplest way to do an asynchronous test is to avoid making it asynchronous. There are two ways of synchronously testing asynchronous APIs that are based on Rx:</p>
<p>If you are writing an isolated unit test and using a &#8220;System.Reactive&#8221; build of the framework, you can use the <a href="http://msdn.microsoft.com/en-us/library/hh242967(v=VS.103).aspx">Rx Testing Framework</a> to simulate asynchrony without having to write an actual asynchronous test. If you are using the Windows Phone &#8220;baked&#8221; build (Microsoft.Phone.Reactive), however, the testing framework is not available to you.</p>
<p>The other way is to block until the first value is returned by using <a href="http://msdn.microsoft.com/en-us/library/ff707880(v=VS.92).aspx">First</a>. This will not work with a number of built in asynchronous actions (like HTTP requests) as they internally utilise the UI thread to return the value, so blocking the UI thread results in a hang.</p>
<h3>Controlling the stack</h3>
<p>On the surface, creating asynchronous tests seems fairly simple and involves three steps:</p>
<ol>
<li>Have your test class inherit Microsoft.Testing.Silverlight.WorkItemTest</li>
<li>Mark your test method with [Asynchronous]</li>
<li>Call base.TestComplete() when you are done</li>
</ol>
<p>This works well until your tests fail, either from a failed assertion or from an unhandled Rx call to OnError. When that happens, the error will bubble to the surface and the application will terminate. The problem lies in the call stack, simplified below:</p>
<p><code><br />
Microsoft.VisualStudio.TestTools.UnitTesting.Assert()<br />
Your.Code.TestClass.TestMethod()<br />
System.Windows.dll!System.Net.Browser.ClientHttpWebRequest.InvokeGetResponseCallback()<br />
mscorlib.dll!System.Threading.ThreadPool.WorkItem.doWork()<br />
mscorlib.dll!System.Threading.Timer.ring()<br />
</code></p>
<p>When the exception is thrown by the assertion, it reaches the top of the stack and the application is terminated. The code that throws the error needs to be called by the testing framework in order for it to register the failure.</p>
<p>In order to re-introduce the testing framework into the stack, the WorkItemTest base class provides the EnqueueCallback method:</p>
<p><pre class="brush: csharp; light: true;">void EnqueueCallback(Action testCallbackDelegate)</pre></p>
<p>While we <em>could</em> call this method directly for each call to the observer, the Rx framework already provides a mechanism for controlling execution: schedulers. The IScheduler interface provides the means to schedule work, and the ObserveOn method marshals observer calls to a scheduler.</p>
<p>Here&#8217;s an adapter implementation of IScheduler that marshals calls to a WorkItemTest class. It also cancels any pending actions when the test completes to avoid executing any asynchronous test case after the test has completed, since doing so can cause an exception to be thrown if the following test is sycnrhonous</p>
<p><pre class="brush: csharp;">
public class WorkItemTestScheduler : IScheduler, IDisposable
{
    private readonly WorkItemTest test;
    private readonly CompositeDisposable scheduledActions = new CompositeDisposable();

    private bool disposed = false;

    public WorkItemTestScheduler(WorkItemTest test)
    {
        this.test = test;

        IDisposable completionSubscription = 
            Observable.FromEvent&lt;TestMethodCompletedEventArgs&gt;(
                h =&gt; test.UnitTestHarness.TestMethodCompleted += h,
                h =&gt; test.UnitTestHarness.TestMethodCompleted -= h
            )
            .Take(1)
            .Subscribe(_ =&gt; Dispose());

        scheduledActions.Add(completionSubscription);
    }

    public DateTimeOffset Now
    {
        get { return DateTimeOffset.Now; }
    }

    public IDisposable Schedule(Action action, TimeSpan dueTime)
    {
        if (disposed)
        {
            return Disposable.Empty;
        }

        if (dueTime != TimeSpan.Zero)
        {
            throw new NotSupportedException(&quot;Only immediate schedules are supported&quot;);
        }

        var disposable = new BooleanDisposable();

        scheduledActions.Add(disposable);

        test.EnqueueCallback(() =&gt;
        {
            if (!disposable.IsDisposed)
            {
                action();
            }
        });

        return Disposable.Create(() =&gt; scheduledActions.Remove(disposable));
    }

    public IDisposable Schedule(Action action)
    {
        return Schedule(action, TimeSpan.Zero);
    }

    public void Dispose()
    {
        scheduledActions.Dispose();

        disposed = true;
    }
}
</pre></p>
<p>To make things easier, we&#8217;ll introduce an extension method that creates the scheduler for us:</p>
<p><pre class="brush: csharp;">
public static class ObservableExtensions
{
    public static IObservable&lt;T&gt; ObserveOnTest&lt;T&gt;(this IObservable&lt;T&gt; source, WorkItemTest test)
    {
        return source
            .ObserveOn(new WorkItemTestScheduler(test));
    }
}
</pre></p>
<h3>Writing an example test</h3>
<p>Here is an example test that attempts to load content from a URL. If the assertion fails or if the server is down, the test framework will log the error and continue execution:</p>
<p><pre class="brush: csharp;">
[TestClass]
public class SampleTestClass : WorkItemTest
{
    [Test]
    [Asynchronous]
    public void LoadUrlContent()
    {
        var request = WebRequest.CreateHttp(&quot;http://blog.richardszalay.com&quot;);

        Observable.FromAsyncPattern&lt;WebResponse&gt;(
            request.BeginGetResponse, request.EndGetResponse
            )()
            .ObserveOnTest(this)
            .Subscribe(response =&gt;
            {
                Assert.IsTrue(response.ContentLength &gt; 1024);

                TestComplete();
            });
    }
}
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/richardszalay.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/richardszalay.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/richardszalay.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/richardszalay.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/richardszalay.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/richardszalay.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/richardszalay.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/richardszalay.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/richardszalay.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/richardszalay.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/richardszalay.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/richardszalay.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/richardszalay.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/richardszalay.wordpress.com/93/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.richardszalay.com&amp;blog=16719208&amp;post=93&amp;subd=richardszalay&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.richardszalay.com/2011/08/08/writing-asynchronous-unit-tests-with-rx-and-the-silverlight-unit-testing-framework/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7eaba3dd7c0fdce655ab50f001f23cc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">richardszalay</media:title>
		</media:content>
	</item>
		<item>
		<title>Practical support for custom light/dark theme resources on Windows Phone 7</title>
		<link>http://blog.richardszalay.com/2011/06/11/practical-support-for-light-dark-themes-on-windows-phone-7/</link>
		<comments>http://blog.richardszalay.com/2011/06/11/practical-support-for-light-dark-themes-on-windows-phone-7/#comments</comments>
		<pubDate>Sat, 11 Jun 2011 10:22:53 +0000</pubDate>
		<dc:creator>Richard Szalay</dc:creator>
				<category><![CDATA[windows-phone]]></category>

		<guid isPermaLink="false">http://blog.richardszalay.com/?p=71</guid>
		<description><![CDATA[Windows Phone 7&#8242;s dark/light themes, which allow the user to choose between white-on-black or black-on-white, expose default resource keys for your application to consume. However, since this support doesn&#8217;t extend to declaring your own light/dark resources, I thought I&#8217;d look &#8230; <a href="http://blog.richardszalay.com/2011/06/11/practical-support-for-light-dark-themes-on-windows-phone-7/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.richardszalay.com&amp;blog=16719208&amp;post=71&amp;subd=richardszalay&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Windows Phone 7&#8242;s dark/light themes, which allow the user to choose between white-on-black or black-on-white, expose <a href="http://msdn.microsoft.com/en-us/library/ff769552(v=VS.92).aspx">default resource keys</a> for your application to consume. However, since this support doesn&#8217;t extend to declaring your <em>own</em> light/dark resources, I thought I&#8217;d look into a practical solution.</p>
<p>I had a few requirements for the implementation:</p>
<ul>
<li>It not should require user code to select between specific resources</li>
<li>It should support standard resource dictionary files and not require specific naming</li>
<li>It should not have a runtime performance penalty</li>
<li>It should work in the Visual Studio &#8220;cider&#8221; designer</li>
<li>It should work in Expression Blend</li>
</ul>
<p>The result is a solution that manages 4 (or 4.5, depending on how you look at it) of those 5, and involves a subclassed <code>ResourceDictionary</code></p>
<p><pre class="brush: csharp;">
namespace ThemeManagement
{
    /// &lt;summary&gt;
    /// Provides automatic selection of resources based on the current theme
    /// &lt;/summary&gt;
    public class ThemeResourceDictionary : ResourceDictionary
    {
        private ResourceDictionary lightResources;
        private ResourceDictionary darkResources;

        /// &lt;summary&gt;
        /// Gets or sets the &lt;see cref=&quot;ResourceDictioary&quot;/&gt; to use when in the &quot;light&quot; theme
        /// &lt;/summary&gt;
        public ResourceDictionary LightResources
        {
            get { return lightResources; }
            set
            {
                lightResources = value;

                if (!IsDarkTheme &amp;&amp; value != null)
                {
                    MergedDictionaries.Add(value);
                }
            }
        }

        /// &lt;summary&gt;
        /// Gets or sets the &lt;see cref=&quot;ResourceDictioary&quot;/&gt; to use when in the &quot;dark&quot; theme
        /// &lt;/summary&gt;
        public ResourceDictionary DarkResources
        {
            get { return darkResources; }
            set
            {
                darkResources = value;

                if (IsDarkTheme &amp;&amp; value != null)
                {
                    MergedDictionaries.Add(value);
                }
            }
        }

        /// &lt;summary&gt;
        /// Determines if the application is running in the dark theme
        /// &lt;/summary&gt;
        private bool IsDarkTheme
        {
            get
            {
                if (IsDesignMode)
                {
                    return true;
                }
                else
                {
                    return (Visibility)Application.Current.Resources[&quot;PhoneDarkThemeVisibility&quot;]
                        == Visibility.Visible;
                }
            }
        }

        /// &lt;summary&gt;
        /// Determines if the application is being run by a design tool
        /// &lt;/summary&gt;
        private bool IsDesignMode
        {
            get
            {
                // VisualStudio sometimes returns false for DesignMode, DesignTool is our backup
                return DesignerProperties.GetIsInDesignMode(this) ||
                    DesignerProperties.IsInDesignTool;
            }
        }
    }
}
</pre></p>
<p>To test it out, I will create a page that contains an <code>Image</code> wrapped in a <code>Border</code> with the intention of using resources for the ImageSource and BorderBrush, respectively:</p>
<p><pre class="brush: xml;">
&lt;Border BorderThickness=&quot;5&quot; BorderBrush=&quot;{StaticResource ImageBorderBrush}&quot;&gt;
    &lt;Image Source=&quot;{StaticResource ThemedImage}&quot; /&gt;
&lt;/Border&gt;
</pre></p>
<p>(Notice that it&#8217;s still using <code>StaticResource</code>)</p>
<p>Next, I created two resource dictionaries in <code>/Resources/Light.xaml</code> and <code>/Resources/Dark.xaml</code>, which looked like this:</p>
<p><pre class="brush: xml;">
&lt;!-- Light.xaml --&gt;
&lt;ResourceDictionary xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
                    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;&gt;

    &lt;SolidColorBrush x:Key=&quot;ImageBorderBrush&quot; Color=&quot;Red&quot; /&gt;
    &lt;BitmapImage x:Key=&quot;ThemedImage&quot;
                 UriSource=&quot;/ThemeManagement;component/Content/ImageLight.png&quot; /&gt;
&lt;/ResourceDictionary&gt;
</pre></p>
<p>&nbsp;</p>
<p><pre class="brush: xml;">
&lt;!-- Dark.xaml --&gt;
&lt;ResourceDictionary xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
                    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;&gt;

    &lt;SolidColorBrush x:Key=&quot;ImageBorderBrush&quot; Color=&quot;Green&quot; /&gt;
    &lt;BitmapImage x:Key=&quot;ThemedImage&quot;
                 UriSource=&quot;/ThemeManagement;component/Content/ImageDark.png&quot; /&gt;
&lt;/ResourceDictionary&gt;
</pre></p>
<p><em>NOTE: <strong>ThemeManagement</strong> is the name of the project</em></p>
<p>Finally, I added the custom resource dictionary to the <code>App.xaml</code>:</p>
<p><pre class="brush: xml;">
&lt;Application.Resources&gt;
    &lt;custom:ThemeResourceDictionary&gt;
        &lt;custom:ThemeResourceDictionary.LightResources&gt;
            &lt;ResourceDictionary Source=&quot;/ThemeManagement;component/Resources/Light.xaml&quot; /&gt;
        &lt;/custom:ThemeResourceDictionary.LightResources&gt;
        &lt;custom:ThemeResourceDictionary.DarkResources&gt;
            &lt;ResourceDictionary Source=&quot;/ThemeManagement;component/Resources/Dark.xaml&quot; /&gt;
        &lt;/custom:ThemeResourceDictionary.DarkResources&gt;
    &lt;/custom:ThemeResourceDictionary&gt;
&lt;/Application.Resources&gt;
</pre></p>
<p><em>NOTE: <strong>ThemeManagement</strong> is the name of the project</em></p>
<p>Now we can take it for a test toast:</p>
<ol>
<li>Run the app</li>
<li>Push the start button on the phone/emulator</li>
<li>Go to Settings and change the theme to light</li>
<li>Push Back a few times until you&#8217;re in the app again</li>
</ol>
<p><strong>UPDATE:</strong> The above test will not work in Mango due to a <a href="http://stackoverflow.com/questions/7324476/is-there-a-bug-when-changing-themes-when-app-is-deactivated-and-reactivated-in-w">unfortunate side effect of multitasking</a>. The correct theme will be applied if the application is relaunched from Start.</p>
<table>
<tbody>
<tr>
<td><img src="http://richardszalay.files.wordpress.com/2011/06/thememanagementdark.jpg?w=640" alt="" /></td>
<td><img src="http://richardszalay.files.wordpress.com/2011/06/thememanagementlight.jpg?w=640" alt="" /></td>
</tr>
<tr>
<td><em>Dark Theme</em></td>
<td><em>Light Theme</em></td>
</tr>
</tbody>
</table>
<p>We can also confirm that it works in Cider by switching to the design view:</p>
<p><img src="http://richardszalay.files.wordpress.com/2011/06/thememanagementcider.jpg?w=640" alt="" /></p>
<p>However, since Cider cannot change themes, we can only see the dark theme.</p>
<p><a name="limitations"></a></p>
<h2>Limitations</h2>
<p>Unfortunately, this solution does not work in Expression Blend. For some reason, Blend parses the Resource BAML (compiled XAML) itself and manually supports <code>Source</code> and <code>MergedDictionary</code> attributes. Because of this, the custom ResourceDictionary code never runs and we Blend can&#8217;t find the resources and you&#8217;ll receive a warning when the project is opened.</p>
<p>The workaround is to select a theme file for design time resources (you can do so from the Blend warning dialog). I recommend choosing Light, since Cider forces us to use Dark. It is unfortunate that both themes can&#8217;t be supported, though, as Blend is the one environment that supports swapping between them on the fly.</p>
<p><img src="http://richardszalay.files.wordpress.com/2011/06/thememanagementblendlight.jpg?w=640" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/richardszalay.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/richardszalay.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/richardszalay.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/richardszalay.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/richardszalay.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/richardszalay.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/richardszalay.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/richardszalay.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/richardszalay.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/richardszalay.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/richardszalay.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/richardszalay.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/richardszalay.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/richardszalay.wordpress.com/71/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.richardszalay.com&amp;blog=16719208&amp;post=71&amp;subd=richardszalay&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.richardszalay.com/2011/06/11/practical-support-for-light-dark-themes-on-windows-phone-7/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7eaba3dd7c0fdce655ab50f001f23cc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">richardszalay</media:title>
		</media:content>

		<media:content url="http://richardszalay.files.wordpress.com/2011/06/thememanagementdark.jpg" medium="image" />

		<media:content url="http://richardszalay.files.wordpress.com/2011/06/thememanagementlight.jpg" medium="image" />

		<media:content url="http://richardszalay.files.wordpress.com/2011/06/thememanagementcider.jpg" medium="image" />

		<media:content url="http://richardszalay.files.wordpress.com/2011/06/thememanagementblendlight.jpg" medium="image" />
	</item>
		<item>
		<title>Creating a strongly typed reactive wrapper to INotifyPropertyChanged</title>
		<link>http://blog.richardszalay.com/2010/10/14/201010creating-strongly-typed-reactive-html/</link>
		<comments>http://blog.richardszalay.com/2010/10/14/201010creating-strongly-typed-reactive-html/#comments</comments>
		<pubDate>Thu, 14 Oct 2010 12:42:00 +0000</pubDate>
		<dc:creator>Richard Szalay</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Rx]]></category>

		<guid isPermaLink="false">http://richardszalay.wordpress.com/2010/10/14/creating-a-strongly-typed-reactive-wrapper-to-inotifypropertychanged</guid>
		<description><![CDATA[Practical Ugliness INotifyPropertyChanged is a great, built-in, way for property change notification to work in the WPF/Silverlight world. Attempting to use it from staticly typed code, however, gets messy: Things get even worse when we try to make this reactive: &#8230; <a href="http://blog.richardszalay.com/2010/10/14/201010creating-strongly-typed-reactive-html/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.richardszalay.com&amp;blog=16719208&amp;post=5&amp;subd=richardszalay&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>Practical Ugliness</h3>
<p><code>INotifyPropertyChanged</code> is a great, built-in, way for property change notification to work in the WPF/Silverlight world. Attempting to use it from staticly typed code, however, gets messy:</p>
<p><pre class="brush: csharp;">
SomeViewModel viewModel;

viewModel.PropertyChanged += (s,e) =&gt;
    {
        if (e.PropertyName == &quot;TheProperty&quot;)
            GetToWork(viewModel.TheProperty);
    };
</pre></p>
<p>Things get even worse when we try to make this reactive:</p>
<p><pre class="brush: csharp;">
var propertyChangedEvents = Observable.FromEvent(
    h =&gt; new PropertyChangedEventHandler(h),
    h =&gt; viewModel.PropertyChanged += h,
    h =&gt; viewModel.PropertyChanged -= h);

propertyChangedEvents
    .Where(x =&gt; x.PropertyName == &quot;TheProperty&quot;)
    .Select(x =&gt; viewModel.TheProperty)
    .Subscribe(GetToWork);
</pre></p>
<h3>An Expressive Solution</h3>
<p>The extension method below allows you to specify the property you want to watch using an <code>Expression&lt;Func&gt;</code>, keeping things nice for the compiler:</p>
<p><strong>Edit: Updated once it was tested (and simplified)</strong></p>
<p><pre class="brush: csharp;">
public static class NotifyPropertyChangeReactiveExtensions
{
    // Returns the values of property (an Expression) as they change, 
    // starting with the current value
    public static IObservable&lt;TValue&gt; GetPropertyValues&lt;TSource, TValue&gt;(
        this TSource source, Expression&lt;Func&lt;TSource, TValue&gt;&gt; property)
        where TSource : INotifyPropertyChanged
    {
        MemberExpression memberExpression = property.Body as MemberExpression;

        if (memberExpression == null)
        {
            throw new ArgumentException(
                &quot;property must directly access a property of the source&quot;);
        }

        string propertyName = memberExpression.Member.Name;

        Func&lt;TSource, TValue&gt; accessor = property.Compile();

        return source.GetPropertyChangedEvents()
            .Where(x =&gt; x.EventArgs.PropertyName == propertyName)
            .Select(x =&gt; accessor(source))
            .StartWith(accessor(source));
    }

    // This is a wrapper around FromEvent(PropertyChanged)
    public static IObservable&lt;IEvent&lt;PropertyChangedEventArgs&gt;&gt;
        GetPropertyChangedEvents(this INotifyPropertyChanged source)
    {
        return Observable.FromEvent&lt;PropertyChangedEventHandler,
            PropertyChangedEventArgs&gt;(
            h =&gt; new PropertyChangedEventHandler(h),
            h =&gt; source.PropertyChanged += h,
            h =&gt; source.PropertyChanged -= h);
    }
}
</pre></p>
<p><code>GetPropertyValues</code> returns an <code>IObservable</code> of the values of the property as they change, starting with the current value.</p>
<p>You can then use it like so:<br />
<pre class="brush: csharp;">
viewModel.GetPropertyChangeValues(x =&gt; x.TheProperty)
    .Subscribe(GetToWork);
</pre></p>
<p>I hope this method can be as useful to you as it has been to me.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/richardszalay.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/richardszalay.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/richardszalay.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/richardszalay.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/richardszalay.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/richardszalay.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/richardszalay.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/richardszalay.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/richardszalay.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/richardszalay.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/richardszalay.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/richardszalay.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/richardszalay.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/richardszalay.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.richardszalay.com&amp;blog=16719208&amp;post=5&amp;subd=richardszalay&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.richardszalay.com/2010/10/14/201010creating-strongly-typed-reactive-html/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7eaba3dd7c0fdce655ab50f001f23cc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">richardszalay</media:title>
		</media:content>
	</item>
		<item>
		<title>Error installing Windows Phone 7 Series SDK</title>
		<link>http://blog.richardszalay.com/2010/03/15/error-installing-windows-phone-7-series-sdk/</link>
		<comments>http://blog.richardszalay.com/2010/03/15/error-installing-windows-phone-7-series-sdk/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 21:14:00 +0000</pubDate>
		<dc:creator>Richard Szalay</dc:creator>
				<category><![CDATA[windows-phone problem workaround]]></category>

		<guid isPermaLink="false">http://richardszalay.wordpress.com/2010/03/15/error-installing-windows-phone-7-series-sdk</guid>
		<description><![CDATA[Now that Windows Phone 7 Series has been opened up a little, I was quick to download the SDK CTP. Unfortunately, I had some problems installing it (possibly caused by the recently uninstalled VS 2010 beta 2 on my machine). &#8230; <a href="http://blog.richardszalay.com/2010/03/15/error-installing-windows-phone-7-series-sdk/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.richardszalay.com&amp;blog=16719208&amp;post=6&amp;subd=richardszalay&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Now that Windows Phone 7 Series has been opened up a little, I was quick to download the SDK CTP. Unfortunately, I had some problems installing it (possibly caused by the recently uninstalled VS 2010 beta 2 on my machine).</p>
<p>
<a href="http://richardszalay.files.wordpress.com/2010/03/windows-phone-error.png"><img src="http://richardszalay.files.wordpress.com/2010/03/windows-phone-error.png?w=300" border="0" /></a></p>
<p>The installation would go fine until it tried to install Silverlight 4, at which time the installation stopped and gave me the error message below. (Also of note, that helpful &#8220;View Log&#8221; link just took me to the Microsoft homepage)</p>
<p>I had already uninstalled all things Visual Studio and .NET 4, so I snooped a little further and uninstalled all Silverlight tools and runtimes. I even tried installing the <a href="http://silverlight.net/getstarted/silverlight-4/">Silverlight 4 RC developer runtime</a> manually in an attempt to get past it as a dependency of the installer. This didn&#8217;t work either, hitting me with a random error number (1622) and a link to a <a href="http://www.microsoft.com/getsilverlight/resources/help.aspx?errorID=1622">Microsoft page</a> reiterating the error number and an odd message about writing to a temp folder.</p>
<p>In the end, I came up with a workaround to using the Silverlight installer exe. I&#8217;ll document it here for anyone else who comes across the same problem:</p>
<ol>
<li>Download the <a href="http://go.microsoft.com/fwlink/?LinkID=167220">Silverlight 4 RC Developer Runtime</a></li>
<li>Extract the exe to a temp folder using 7zip (or a 7z-supporting application)</li>
<li>Run <strong>silverlight.msi</strong></li>
<li>Extract <strong>Silverlight.msp</strong> from silverlight.7z and run it</li>
<li>Run <strong>silverlightdev.msp</strong></li>
<li>Re-run the Windows Phone 7 SDK setup and let it continue the installation</li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/richardszalay.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/richardszalay.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/richardszalay.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/richardszalay.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/richardszalay.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/richardszalay.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/richardszalay.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/richardszalay.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/richardszalay.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/richardszalay.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/richardszalay.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/richardszalay.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/richardszalay.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/richardszalay.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.richardszalay.com&amp;blog=16719208&amp;post=6&amp;subd=richardszalay&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.richardszalay.com/2010/03/15/error-installing-windows-phone-7-series-sdk/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7eaba3dd7c0fdce655ab50f001f23cc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">richardszalay</media:title>
		</media:content>

		<media:content url="http://richardszalay.files.wordpress.com/2010/03/windows-phone-error.png?w=300" medium="image" />
	</item>
		<item>
		<title>Massive SUO file causes Visual Studio to hang when doing pretty much anything</title>
		<link>http://blog.richardszalay.com/2010/01/25/massive-suo-file-causes-visual-studio-to-hang-when-doing-pretty-much-anything/</link>
		<comments>http://blog.richardszalay.com/2010/01/25/massive-suo-file-causes-visual-studio-to-hang-when-doing-pretty-much-anything/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 10:44:00 +0000</pubDate>
		<dc:creator>Richard Szalay</dc:creator>
				<category><![CDATA[Visual Studio.NET]]></category>

		<guid isPermaLink="false">http://richardszalay.wordpress.com/2010/01/25/massive-suo-file-causes-visual-studio-to-hang-when-doing-pretty-much-anything</guid>
		<description><![CDATA[I&#8217;ve been dealing with horribly slow performance from Visual Studio 2008 (SP1) for a few weeks now. We&#8217;re talking seriously slow performance. Like 30-40 seconds of unresponsiveness to save the solution; 20-30 seconds of unresponsiveness after compilation if there were &#8230; <a href="http://blog.richardszalay.com/2010/01/25/massive-suo-file-causes-visual-studio-to-hang-when-doing-pretty-much-anything/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.richardszalay.com&amp;blog=16719208&amp;post=7&amp;subd=richardszalay&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been dealing with horribly slow performance from Visual Studio 2008 (SP1) for a few weeks now. We&#8217;re talking seriously slow performance. Like 30-40 seconds of unresponsiveness to save the solution; 20-30 seconds of unresponsiveness after compilation if there were any errors.</p>
<p>Today, after taking a few memory dumps to send to Microsoft, I set out to look for network references (an idea from a workmate). I didn&#8217;t find any (nor did I expect to), but I did find a <strong>250MB</strong> (!) SUO (Solution User Options) file.</p>
<p>I have no idea how the SUO file got so large, but deleting completly fixed the problem. Visual Studio has returned to it&#8217;s usual speediness. I do regret, though, not making a copy of the SUO to send to Microsoft. Next time, perhaps.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/richardszalay.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/richardszalay.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/richardszalay.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/richardszalay.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/richardszalay.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/richardszalay.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/richardszalay.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/richardszalay.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/richardszalay.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/richardszalay.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/richardszalay.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/richardszalay.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/richardszalay.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/richardszalay.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.richardszalay.com&amp;blog=16719208&amp;post=7&amp;subd=richardszalay&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.richardszalay.com/2010/01/25/massive-suo-file-causes-visual-studio-to-hang-when-doing-pretty-much-anything/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7eaba3dd7c0fdce655ab50f001f23cc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">richardszalay</media:title>
		</media:content>
	</item>
		<item>
		<title>Executing Powershell from CruiseControl.NET on 64-bit Windows</title>
		<link>http://blog.richardszalay.com/2009/10/22/executing-powershell-from-cruisecontrol-net-on-64-bit-windows/</link>
		<comments>http://blog.richardszalay.com/2009/10/22/executing-powershell-from-cruisecontrol-net-on-64-bit-windows/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 13:50:00 +0000</pubDate>
		<dc:creator>Richard Szalay</dc:creator>
				<category><![CDATA[64-bit]]></category>
		<category><![CDATA[cruisecontrol.net]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://richardszalay.wordpress.com/2009/10/22/executing-powershell-from-cruisecontrol-net-on-64-bit-windows</guid>
		<description><![CDATA[If you try to execute a Powershell script from a CruiseControl.NET build on a 64-bit OS, you&#8217;ll get the following error: File ~filename~.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see &#8220;get-help about_signing&#8221; &#8230; <a href="http://blog.richardszalay.com/2009/10/22/executing-powershell-from-cruisecontrol-net-on-64-bit-windows/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.richardszalay.com&amp;blog=16719208&amp;post=8&amp;subd=richardszalay&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you try to execute a Powershell script from a CruiseControl.NET build on a 64-bit OS, you&#8217;ll get the following error:</p>
<blockquote><p>File ~filename~.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see &#8220;get-help about_signing&#8221; for more details.</p></blockquote>
<p>If you google around, you&#8217;ll be told to execute <strong>Set-ExecutionPolicy</strong>. Unfortunately, on 64-bit, that won&#8217;t fix your problem.</p>
<p>The issue is that CruiseControl.NET is 32-bit and the default powershell on 64-bit Windows is 64-bit. When a 32-bit process accesses SOFTWARE registry keys, the request gets redirected to <strong>HKLM\Software\Wow6432Node</strong>. This results in powershell looking for the wrong key and thus getting the default value.</p>
<p>To work around the problem, execute the following at an elevated command prompt:</p>
<blockquote><p><strong>%windir%\SysWOW64\WindowsPowerShell\v1.0\powershell.exe &#8220;Set-ExecutionPolicy RemoteSigned&#8221;</strong></p></blockquote>
<p>In finding this solution it prompted me to realise that, in 64-bit Windows, <strong>c:\windows\system32</strong> is 64-bit and <strong>c:\windows\SysWOW64</strong> is 32-bit. And then my head exploded.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/richardszalay.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/richardszalay.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/richardszalay.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/richardszalay.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/richardszalay.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/richardszalay.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/richardszalay.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/richardszalay.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/richardszalay.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/richardszalay.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/richardszalay.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/richardszalay.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/richardszalay.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/richardszalay.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.richardszalay.com&amp;blog=16719208&amp;post=8&amp;subd=richardszalay&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.richardszalay.com/2009/10/22/executing-powershell-from-cruisecontrol-net-on-64-bit-windows/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7eaba3dd7c0fdce655ab50f001f23cc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">richardszalay</media:title>
		</media:content>
	</item>
		<item>
		<title>Hosts File Manager extension for IIS 7</title>
		<link>http://blog.richardszalay.com/2009/08/30/hosts-file-manager-extension-for-iis-7/</link>
		<comments>http://blog.richardszalay.com/2009/08/30/hosts-file-manager-extension-for-iis-7/#comments</comments>
		<pubDate>Sun, 30 Aug 2009 17:15:00 +0000</pubDate>
		<dc:creator>Richard Szalay</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://richardszalay.wordpress.com/2009/08/30/hosts-file-manager-extension-for-iis-7</guid>
		<description><![CDATA[I&#8217;ve just released the first version of my new side project, the Hosts File Manager extension for IIS 7. The extension does pretty much what it says on the can, providing a user interface to edit the local hosts file &#8230; <a href="http://blog.richardszalay.com/2009/08/30/hosts-file-manager-extension-for-iis-7/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.richardszalay.com&amp;blog=16719208&amp;post=12&amp;subd=richardszalay&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just released the first version of my new side project, the Hosts File Manager extension for IIS 7. The extension does pretty much what it says on the can, providing a user interface to edit the local hosts file from within IIS Manager. Running from within IIS gives me a few other benefits, too, like auto-elevation and providing me easy access to local website information.</p>
<p>For now, there&#8217;s only a global view (accessible from the default &#8220;server&#8221; view in IIS Manager), but I have more features planned for future releases. You can read about these on the <a href="http://iishosts.codeplex.com/">Codeplex project page</a>.</p>
<p>To download it, head over the <a href="http://iishosts.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=32195">Downloads page on Codeplex</a>. I&#8217;ve released both x86 and x64 versions, but all my testing has been done with the x64 installer (since I&#8217;m running 64-bit Win7). Please log any x86 or Vista issues with the <a href="http://iishosts.codeplex.com/WorkItem/List.aspx">Issue Tracker</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/richardszalay.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/richardszalay.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/richardszalay.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/richardszalay.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/richardszalay.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/richardszalay.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/richardszalay.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/richardszalay.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/richardszalay.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/richardszalay.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/richardszalay.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/richardszalay.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/richardszalay.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/richardszalay.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.richardszalay.com&amp;blog=16719208&amp;post=12&amp;subd=richardszalay&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.richardszalay.com/2009/08/30/hosts-file-manager-extension-for-iis-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7eaba3dd7c0fdce655ab50f001f23cc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">richardszalay</media:title>
		</media:content>
	</item>
		<item>
		<title>Debugging IIS 7 extensions in Windows 7</title>
		<link>http://blog.richardszalay.com/2009/08/27/debugging-iis-7-extensions-in-windows-7/</link>
		<comments>http://blog.richardszalay.com/2009/08/27/debugging-iis-7-extensions-in-windows-7/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 07:07:00 +0000</pubDate>
		<dc:creator>Richard Szalay</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://richardszalay.wordpress.com/2009/08/27/debugging-iis-7-extensions-in-windows-7</guid>
		<description><![CDATA[I came across some curious behavior when trying to debug an IIS extension that I&#8217;m working on. When I went to select &#8220;InetMgr.exe&#8221; as the startup program, it wasn&#8217;t there. I checked the folder using Windows Explorer and, sure enough, &#8230; <a href="http://blog.richardszalay.com/2009/08/27/debugging-iis-7-extensions-in-windows-7/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.richardszalay.com&amp;blog=16719208&amp;post=13&amp;subd=richardszalay&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I came across some curious behavior when trying to debug an IIS extension that I&#8217;m working on. When I went to select &#8220;InetMgr.exe&#8221; as the startup program, it wasn&#8217;t there. I checked the folder using Windows Explorer and, sure enough, there it was. Even entering the path manually resulted in &#8220;The external program cannot be found&#8221;.</p>
<p>So, what was the problem? Well, as far as I can tell, it appears that because InetMgr.exe is an auto-elevated process it is only accessible to other auto-elevated processes. This is quite possibly a post RC solution to the <a href="http://www.istartedsomething.com/20090130/uac-security-flaw-windows-7-beta-proof/">flaw in UAC</a> found during the betas, though I&#8217;m just speculating.</p>
<p>Luckily, with a bit of experimenting, I was able to find a solution. By enabling remote debugging (&#8220;Use remote machine&#8221;) and setting the value to localhost, I was able to circumvent whatever was blocking the call. See the below screenshot for clarification.</p>
<p style="text-align:center;"><img src="http://richardszalay.files.wordpress.com/2009/08/iis-start-action-inetmgr.png?w=300" border="0" /><br /><strong>Debug settings for InetMgr.exe</strong></p>
<p>I am now happily debugging my extension without hassles.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/richardszalay.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/richardszalay.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/richardszalay.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/richardszalay.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/richardszalay.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/richardszalay.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/richardszalay.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/richardszalay.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/richardszalay.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/richardszalay.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/richardszalay.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/richardszalay.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/richardszalay.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/richardszalay.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.richardszalay.com&amp;blog=16719208&amp;post=13&amp;subd=richardszalay&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.richardszalay.com/2009/08/27/debugging-iis-7-extensions-in-windows-7/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7eaba3dd7c0fdce655ab50f001f23cc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">richardszalay</media:title>
		</media:content>

		<media:content url="http://richardszalay.files.wordpress.com/2009/08/iis-start-action-inetmgr.png?w=300" medium="image" />
	</item>
		<item>
		<title>Enable net.pipes in IIS 7 on Windows 7 Professional</title>
		<link>http://blog.richardszalay.com/2009/08/24/enable-net-pipes-in-iis-7-on-windows-7-professional/</link>
		<comments>http://blog.richardszalay.com/2009/08/24/enable-net-pipes-in-iis-7-on-windows-7-professional/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 09:38:00 +0000</pubDate>
		<dc:creator>Richard Szalay</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://richardszalay.wordpress.com/2009/08/24/enable-net-pipes-in-iis-7-on-windows-7-professional</guid>
		<description><![CDATA[I recently went to configure a net pipes service in Windows 7 (Professional 64-bit) and found that it wasn&#8217;t available. I quickly proceeded to &#8220;Turn Windows features on or off&#8221;, but couldn&#8217;t find it there either. I eventually found the &#8230; <a href="http://blog.richardszalay.com/2009/08/24/enable-net-pipes-in-iis-7-on-windows-7-professional/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.richardszalay.com&amp;blog=16719208&amp;post=14&amp;subd=richardszalay&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-decoration:line-through;">I recently went to configure a net pipes service in Windows 7 (Professional 64-bit) and found that it wasn&#8217;t available. I quickly proceeded to &#8220;Turn Windows features on or off&#8221;, but couldn&#8217;t find it there either. I eventually found the answer in the Microsoft article <a href="http://msdn.microsoft.com/en-us/library/ms789006.aspx">WAS Activation Architecture</a> and have simplified the steps below:</p>
<ol>
<li style="text-decoration:line-through;">Open %windir%\system32\inetsrv\config\applicationHost.config with (elevated) notepad</li>
<li style="text-decoration:line-through;">Find the  element</li>
<li style="text-decoration:line-through;">Add a new  element with a name attribute of &#8220;net.pipe&#8221;</li>
</ol>
<p style="text-decoration:line-through;">The final element should look like this (assuming you have no other listener adapters enabled):</p>
<pre style="text-decoration:line-through;">
</pre>
<p><strong>Edit:</strong> While the above solution enabled net.pipe in the bindings dialog in IIS, it didn&#8217;t actually enable net pipes in IIS. I did, however, find the correct way of enabling them:</p>
<p>Simply install &#8220;Windows Communication Foundation Non-HTTP Activation&#8221; from the &#8220;Microsoft .NET 3.5.1&#8243; section in the &#8220;Turn Windows features on or off&#8221; dialog.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/richardszalay.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/richardszalay.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/richardszalay.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/richardszalay.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/richardszalay.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/richardszalay.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/richardszalay.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/richardszalay.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/richardszalay.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/richardszalay.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/richardszalay.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/richardszalay.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/richardszalay.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/richardszalay.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.richardszalay.com&amp;blog=16719208&amp;post=14&amp;subd=richardszalay&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.richardszalay.com/2009/08/24/enable-net-pipes-in-iis-7-on-windows-7-professional/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7eaba3dd7c0fdce655ab50f001f23cc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">richardszalay</media:title>
		</media:content>
	</item>
	</channel>
</rss>
