<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7203370983485193018</id><updated>2026-05-29T22:10:45.084+02:00</updated><category term="wix"/><category term="Caliburn.Micro"/><category term="Project Template"/><category term="Service Installer"/><category term="Stable Dependencies Principle"/><category term="VSIX"/><category term="assembly"/><category term="mvvm"/><category term="nDepend"/><category term="version number"/><category term="visual studio 11"/><category term="web service installer"/><category term="windows phone 7"/><category term="wpf"/><title type='text'>Olav&#39;s thoughts on coding</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://oncoding.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7203370983485193018/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://oncoding.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17693565125055146738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7203370983485193018.post-4804166983567632904</id><published>2012-06-24T19:30:00.003+02:00</published><updated>2012-06-24T23:02:51.130+02:00</updated><title type='text'>Unit testing with NCrunch</title><content type='html'>Sometimes when I start using a new tool I find myself wondering why haven&#39;t I done this a long time ago, or simply OMG this is just awesome.&lt;br /&gt;
After I have been using NCrunch for the last couple of weeks this is exactly how I have felt, what a great addon.&lt;br /&gt;
If you are writing unit tests (which you should do) you simply have to try NCrunch, it is a wonderful addon for Visual Studio. It works for all resonably recent versions of Visual Studio from 2008 through 2012 RC.&lt;br /&gt;
&lt;br /&gt;
The Visual Studio 2012 RC Test Explorer has improved the built in features of Visual Studio, but I much prefer the automatic execution of my tests that NCrunch provides and direct feedback on state of my tests right in the code as I write or modify the code. It is simply wonderful to almost instantly get feedback if I break something when working on a piece of code.&lt;br /&gt;
&lt;br /&gt;
Best of all, it is still free so there&#39;s really no reason not to give it a spin and see if it works for you too.&lt;br /&gt;
&lt;br /&gt;
It can be downloaded from &lt;a href=&quot;http://www.ncrunch.net/&quot; target=&quot;_blank&quot;&gt;http://www.ncrunch.net/&lt;/a&gt; and there&#39;s both a tutorial video there and some pretty decent documentation. &lt;br /&gt;
&lt;br /&gt;
Anyway here are my notes on how I have been using NCrunch this far.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Contents:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://oncoding.blogspot.no/2012/06/unit-testing-with-ncrunch.html#installing&quot;&gt;Installing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://oncoding.blogspot.no/2012/06/unit-testing-with-ncrunch.html#writing-code&quot;&gt;Writing code with NCrunch enabled &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://oncoding.blogspot.no/2012/06/unit-testing-with-ncrunch.html#integration-testing&quot;&gt;Integration testing &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://oncoding.blogspot.no/2012/06/unit-testing-with-ncrunch.html#configuration&quot;&gt;Configuration&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;








Installing &lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=7203370983485193018&quot; name=&quot;installing&quot;&gt;&lt;/a&gt; &lt;/h2&gt;
After you have downloaded and run the installer you should start visual studio and open a solution that you will try NCrunch on.&lt;br /&gt;
You will now have a &#39;NCrunch&#39; menu on your menu bar. You should open this a select &#39;Enable NCrunch&#39; to start the configuration of NCrunch.&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-uRFe6_cmmkI/T-cG_2bALAI/AAAAAAAAOyA/a6lbRkIrmPM/s1600/enabling+ncrunch.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;252&quot; src=&quot;http://2.bp.blogspot.com/-uRFe6_cmmkI/T-cG_2bALAI/AAAAAAAAOyA/a6lbRkIrmPM/s640/enabling+ncrunch.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Enable NCrunch&lt;/td&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
This will start a wizard that asks you to choose what settings you want to use when running NCrunch. Most of the default settings seems to be just and fine and you can always change them later using the Configuration entry of the NCrunch menu.&lt;br /&gt;
&lt;br /&gt;
I set Max number of threads used for NCrunch to two, depends of course on how powerful your CPU is, but seems to work OK for me.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://2.bp.blogspot.com/-98JodvBbY2I/T-cG53IZR9I/AAAAAAAAOxA/pvnWbEJE7d8/s1600/Max+Processing+Threads.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;270&quot; src=&quot;http://2.bp.blogspot.com/-98JodvBbY2I/T-cG53IZR9I/AAAAAAAAOxA/pvnWbEJE7d8/s320/Max+Processing+Threads.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I like fast and on the solutions I have been working on memory hasn&#39;t been an issue on the hardware I have been using, but again this will depend on the size of your solution and your hardware.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://2.bp.blogspot.com/-vmZB2epusyc/T-cG39jNE5I/AAAAAAAAOwM/NSl9ZhOcXOs/s1600/Engine+Optimisation.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;270&quot; src=&quot;http://2.bp.blogspot.com/-vmZB2epusyc/T-cG39jNE5I/AAAAAAAAOwM/NSl9ZhOcXOs/s320/Engine+Optimisation.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
I have been using dark visual studio 2010 themes lately and I think I prefer the dark Visual Studio 2012 theme. This means I have to remember to change the &quot;lines with no coverage&quot; from black to a light grey colour or else I will have difficulties seeing lines that aren&#39;t covered.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://1.bp.blogspot.com/-HJq10uwAEe8/T-cG3b0MBxI/AAAAAAAAOwA/bB69nHiURuo/s1600/Coverage+Marker+Colours.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;270&quot; src=&quot;http://1.bp.blogspot.com/-HJq10uwAEe8/T-cG3b0MBxI/AAAAAAAAOwA/bB69nHiURuo/s320/Coverage+Marker+Colours.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
I have played safe with respect to parallel test execution, maybe it is not necessary, but NCrunch has performed fast enough for my solutions this far and well, maybe I will go parallel when I get more experience with NCrunch and larger solutions.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://3.bp.blogspot.com/-hM1qk4Q2jzE/T-cG_QHM_hI/AAAAAAAAOx4/JS_jyWX_vZU/s1600/Parallel+Test+Execution.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;271&quot; src=&quot;http://3.bp.blogspot.com/-hM1qk4Q2jzE/T-cG_QHM_hI/AAAAAAAAOx4/JS_jyWX_vZU/s320/Parallel+Test+Execution.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
I prefer to run all my tests so I chose the first option.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://4.bp.blogspot.com/-4Cf2orlwy3U/T-cG3i0aWqI/AAAAAAAAOwI/3eseReM-SBQ/s1600/Engine+Execution+Mode.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;271&quot; src=&quot;http://4.bp.blogspot.com/-4Cf2orlwy3U/T-cG3i0aWqI/AAAAAAAAOwI/3eseReM-SBQ/s320/Engine+Execution+Mode.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Starting with all tests has been the best option for me this far. I want to run most tests anyway.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://4.bp.blogspot.com/-oNwjP9Dzt28/T-cG5ttIXzI/AAAAAAAAOw8/Y86xd7E9Llc/s1600/Ignored+Tests.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;272&quot; src=&quot;http://4.bp.blogspot.com/-oNwjP9Dzt28/T-cG5ttIXzI/AAAAAAAAOw8/Y86xd7E9Llc/s320/Ignored+Tests.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;








Writing code with NCrunch enabled &lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=7203370983485193018&quot; name=&quot;writing-code&quot;&gt;&lt;/a&gt; &lt;/h2&gt;
In the image below we can see how untested code will look once NCrunch is installed. In this example we have a Robot class that has a single method. The only thing my robot can do is to say hello to a person.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://2.bp.blogspot.com/-7Suf5eAzxqs/T-cG4TWmkFI/AAAAAAAAOwk/o3OQ5A_OMdw/s1600/Hello+no+coverage.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;188&quot; src=&quot;http://2.bp.blogspot.com/-7Suf5eAzxqs/T-cG4TWmkFI/AAAAAAAAOwk/o3OQ5A_OMdw/s640/Hello+no+coverage.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Notice the white dots on the left hand side. They tell us that these three lines aren&#39;t covered by any unit tests.&lt;br /&gt;
Lets make a unit test for the SayHello method. We start out by making the simplest test possible, we just instantiate a robot and call it with null and see what happens.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://4.bp.blogspot.com/-tHya-Ydmmm4/T-cG5b8lIwI/AAAAAAAAOw0/uB8aImMsqF4/s1600/Hello+test+1.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;195&quot; src=&quot;http://4.bp.blogspot.com/-tHya-Ydmmm4/T-cG5b8lIwI/AAAAAAAAOw0/uB8aImMsqF4/s640/Hello+test+1.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
The dots to the left of the test turns red, and there&#39;s a red cross over the SayHello call on the robot.&lt;br /&gt;
If we hover the mouse over the red cross a tooltip will tell us that the method we are testing throws a null reference exception. Clearly the method doesn&#39;t work with a null parameter, nor does it validate its parameter. Lets fix that.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://2.bp.blogspot.com/-wbIQCAjqE3w/T-cG_LktjyI/AAAAAAAAOxw/cfJaLUm7O4s/s1600/Hello+param+validation.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;98&quot; src=&quot;http://2.bp.blogspot.com/-wbIQCAjqE3w/T-cG_LktjyI/AAAAAAAAOxw/cfJaLUm7O4s/s640/Hello+param+validation.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
We now have added parameter checking, but we still have a red cross indicating that there is a test not expecting to see this exception. Lets go back to the test and fix.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://3.bp.blogspot.com/-MVuk3is4fdc/T-cG4AM_CWI/AAAAAAAAOwY/oXOFJ6l6Rys/s1600/Hello+Exception+Test.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;176&quot; src=&quot;http://3.bp.blogspot.com/-MVuk3is4fdc/T-cG4AM_CWI/AAAAAAAAOwY/oXOFJ6l6Rys/s640/Hello+Exception+Test.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
We add an ExpectedException attribute to the test, and we are green.&amp;nbsp; Switching back to the SayHello method we observer that we still aren&#39;t testing all of the method. Only the first two lines are executed by our current test. &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://1.bp.blogspot.com/-oyMsETgdvb8/T-cG4847TvI/AAAAAAAAOwo/XWkqpn0NI8g/s1600/Hello+param+validation+with+test.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;100&quot; src=&quot;http://1.bp.blogspot.com/-oyMsETgdvb8/T-cG4847TvI/AAAAAAAAOwo/XWkqpn0NI8g/s640/Hello+param+validation+with+test.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
We need to add another test. Lets test the method by passing in a person named Olav and Assert that the robot will respond with the string &quot;Hello Olav&quot;. We quickly notice that the test still fails. If we hover the mouse over the red cross we can see the error message. The really cool part of this is that the test runner is fully automatic. We don&#39;t have to build and we don&#39;t even have to save our changes to see that the test is still not quite passing. Fix the expected text or the method so that the expectation and the method implementation match and we will go green again.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://4.bp.blogspot.com/-vb6Af_SDYA0/T-c-1NoYzFI/AAAAAAAAPjA/DgUGLOwzqJs/s1600/Hello+Olav+Error.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;176&quot; src=&quot;http://4.bp.blogspot.com/-vb6Af_SDYA0/T-c-1NoYzFI/AAAAAAAAPjA/DgUGLOwzqJs/s640/Hello+Olav+Error.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Note also how we are constantly switching back and forth between the method we are testing and the tests. Since we aren&#39;t even building our code this switching back and forth can go real quick once we get into the rythm of it and it promotes a more TDD like approach to write tests, even if we aren&#39;t starting with the tests. Of course you can do real TDD as well, but for those of us who haven&#39;t yet fully adopted that way of coding, well this may bring us closer to it.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;




&amp;nbsp;Integration testing&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=7203370983485193018&quot; name=&quot;integration-testing&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
It is often useful to write tests that aren&#39;t true unit tests. E.g. we may want to test that our database access code is working. This means that we have tests that are dependent on external systems such as a database.&lt;br /&gt;
These tests may not be possible to run on our build server.&lt;br /&gt;
&lt;br /&gt;
Suppose we implement a Save method on the robot which saves the state of the robot to some database (the save method should probably not be on robot in a real system, but for simplicity lets just assume that it is). We want to test this functionality, but database dependent tests often take longer to run so we don&#39;t want to run it all the time.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://4.bp.blogspot.com/-oBzo34rm_0I/T-cG9M-CUuI/AAAAAAAAOxg/weEOauBH0DU/s1600/Robot+Save+Test.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;97&quot; src=&quot;http://4.bp.blogspot.com/-oBzo34rm_0I/T-cG9M-CUuI/AAAAAAAAOxg/weEOauBH0DU/s320/Robot+Save+Test.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
One way to control which tests should be run on the build server is to use TestCategory attributes on the test methods. We can mark all our real unit tests with the category Unittest and the integration tests with IntegrationTest as show below.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://3.bp.blogspot.com/-eU5cLAuP29w/T-cG_gUygWI/AAAAAAAAOyE/GZLibt4e358/s1600/Test+category+attributes.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;250&quot; src=&quot;http://3.bp.blogspot.com/-eU5cLAuP29w/T-cG_gUygWI/AAAAAAAAOyE/GZLibt4e358/s320/Test+category+attributes.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
We can then configure our TFS build server to only run tests that have the TestCategory UnitTest. Fortunately we can can configure the NCrunch test runner to do exactly the same by setting the Engine Mode. The engine mode configuration is accessed from the NCrunch menu as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://4.bp.blogspot.com/-tkuHU6AM6i4/T-cG3cBQULI/AAAAAAAAOwE/nIX13Zl0DNQ/s1600/Customise+Engine+Modes.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;147&quot; src=&quot;http://4.bp.blogspot.com/-tkuHU6AM6i4/T-cG3cBQULI/AAAAAAAAOwE/nIX13Zl0DNQ/s320/Customise+Engine+Modes.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Click &#39;Add Engine Mode&#39; and name the new Engine mode. Then select HasCategory UnitTest as shown below, then click OK.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://1.bp.blogspot.com/-UTzXNnL0y48/T-cG2_mKAZI/AAAAAAAAOv0/5ZEXyo6cH4s/s1600/Add+Customised+Engine+Mode.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;http://1.bp.blogspot.com/-UTzXNnL0y48/T-cG2_mKAZI/AAAAAAAAOv0/5ZEXyo6cH4s/s320/Add+Customised+Engine+Mode.PNG&quot; width=&quot;301&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
To activate the new mode, select it from the NCrunch Set Engine Mode menu&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://1.bp.blogspot.com/-1O1cGbOuskU/T-cG92r1a4I/AAAAAAAAOxs/KfYxx-yQFpU/s1600/Select+the+new+engine+mode.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;103&quot; src=&quot;http://1.bp.blogspot.com/-1O1cGbOuskU/T-cG92r1a4I/AAAAAAAAOxs/KfYxx-yQFpU/s320/Select+the+new+engine+mode.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
You will then be notified by this message shown in the right hand bottom corner of visual studio that NCrunch is switching engine mode. &lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://2.bp.blogspot.com/-VdLxo-kgcxI/T-cG-zuhj3I/AAAAAAAAOx8/6Ll7YUbAEUQ/s1600/Switching+engine+mode.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://2.bp.blogspot.com/-VdLxo-kgcxI/T-cG-zuhj3I/AAAAAAAAOx8/6Ll7YUbAEUQ/s1600/Switching+engine+mode.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Now NCrunch will only run tests that are decorated with the UnitTest TestCategory attribute.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;




Configuration&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=7203370983485193018&quot; name=&quot;configuration&quot;&gt;&lt;/a&gt; &lt;/h2&gt;
NCrunch is very configurable. The configuration settings can be found using the NCrunch menu.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://3.bp.blogspot.com/-w17k5mAN6iY/T-cG24IeF5I/AAAAAAAAOv8/4TbWepPBGsE/s1600/Configuration.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;http://3.bp.blogspot.com/-w17k5mAN6iY/T-cG24IeF5I/AAAAAAAAOv8/4TbWepPBGsE/s320/Configuration.PNG&quot; width=&quot;293&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
There are three levels of configuration. All solutions which applies to all solution, then there are Solution wide settings and finally project wide settings.&lt;br /&gt;
The dot colours are set at the topmost level, &#39;All solutions&#39;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://4.bp.blogspot.com/-TAHW1lVsMqc/T-cG6zF11WI/AAAAAAAAOxM/rXlq-VxSESA/s1600/Project+configuration+settings.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;310&quot; src=&quot;http://4.bp.blogspot.com/-TAHW1lVsMqc/T-cG6zF11WI/AAAAAAAAOxM/rXlq-VxSESA/s320/Project+configuration+settings.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Mostly the default settings work just fine, but for some projects I have had to change &#39;Copy referenced assemblies to workspace&#39;, setting &#39;Use build configuration&#39; to debug or change &#39;Use CPU architecture&#39; to x64 to fix projects that NCrunch fails to build. The reason that NCrunch sometimes fails to build a project is that it is using MSBuild to build the project rather than visual studio. &lt;br /&gt;
&lt;br /&gt;
That&#39;s the most basic features of NCrunch. There are a few more interesting features such as Metrics and Risk/Progress Bar, but those will have to wait until a future post.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://oncoding.blogspot.com/feeds/4804166983567632904/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://oncoding.blogspot.com/2012/06/unit-testing-with-ncrunch.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7203370983485193018/posts/default/4804166983567632904'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7203370983485193018/posts/default/4804166983567632904'/><link rel='alternate' type='text/html' href='http://oncoding.blogspot.com/2012/06/unit-testing-with-ncrunch.html' title='Unit testing with NCrunch'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17693565125055146738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-uRFe6_cmmkI/T-cG_2bALAI/AAAAAAAAOyA/a6lbRkIrmPM/s72-c/enabling+ncrunch.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7203370983485193018.post-4629671982171774754</id><published>2012-04-15T17:15:00.001+02:00</published><updated>2012-04-17T10:00:35.828+02:00</updated><title type='text'>Visual Studio 11 Project Template Wizards, no GAC&#39;ing</title><content type='html'>Not long ago I posted about how to create a &lt;a href=&quot;http://oncoding.blogspot.com/2012/04/creating-wix-windows-service-installer.html&quot;&gt;Project template for a Windows Service installer using Wix&lt;/a&gt;. In my humble opinion the project template made the task of creating a WIX setup project for a Windows Service easier. However, although easier there was still a need to do some manual editing of XML files.&lt;br /&gt;
&lt;br /&gt;
Today I will show how we can extend a project template with a wizard as shown below and thus completely remove the required XML editing.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgC3P9RKQkSI4zl2t5ZPTGxFp9teXng9gw_JgAcKRHwcHajS5StDEq2rtP-K4gtRjBkmAf6ztGx-jifTIiA9xxQ97hzlHN4RkvXppZUauKh7AyFy7kzPDCVN8bpWHpuQMchq1VYUcF9fNY/s1600/Wizard+Dialog.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgC3P9RKQkSI4zl2t5ZPTGxFp9teXng9gw_JgAcKRHwcHajS5StDEq2rtP-K4gtRjBkmAf6ztGx-jifTIiA9xxQ97hzlHN4RkvXppZUauKh7AyFy7kzPDCVN8bpWHpuQMchq1VYUcF9fNY/s320/Wizard+Dialog.PNG&quot; width=&quot;288&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
The Microsoft documentation can lead the unwary to&amp;nbsp;believe&amp;nbsp;that wizards in project templates require assemblies to be GAC&#39;ed which isn&#39;t supported by VSIX files. Don&#39;t worry, a real wizard doesn&#39;t need mundane tools such as a GAC.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;



&lt;/h4&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdyoS0Amks-ThAH78gWPX8o_wcPNXRzBQmrqSO_M1B3IWf9E0zrZDUClZ2YW7P1JcBVWEEYorQcHLC6eeIeRHgndSy0zEWNZToiL4EEZF_8d3pruUTllPyGKXT_TL_L7RVigxR71RvxQk/s1600/Wizard.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdyoS0Amks-ThAH78gWPX8o_wcPNXRzBQmrqSO_M1B3IWf9E0zrZDUClZ2YW7P1JcBVWEEYorQcHLC6eeIeRHgndSy0zEWNZToiL4EEZF_8d3pruUTllPyGKXT_TL_L7RVigxR71RvxQk/s320/Wizard.PNG&quot; width=&quot;307&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Image based on original by&amp;nbsp;&lt;a href=&quot;http://www.flickr.com/people/jdhancock/&quot;&gt;jdhancock&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h3&gt;



The Wizard&lt;/h3&gt;
The MSDN article&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms185301(v=vs.110).aspx&quot;&gt;&amp;nbsp;How to: Use Wizards with Project Templates&lt;/a&gt;&amp;nbsp;describes some of the steps required to implement a project template wizard, but as we will see, don&#39;t believe all that MSDN tell you.&lt;br /&gt;
&lt;br /&gt;
The first step is to create a Class Library assembly. This assembly should contain a class that implements the&amp;nbsp;&lt;i&gt;IWizard&lt;/i&gt;&amp;nbsp;interface that is defined in the Microsoft.TemplateWizard namespace in the&amp;nbsp;Microsoft.VisualStudio.TemplateWizardInterface assembly, and&amp;nbsp;the GUI of your wizard.&lt;br /&gt;
&lt;br /&gt;
For our Project Template the only method that we actually need to implement from the IWizard&amp;nbsp;interface is the &lt;i&gt;RunStarted&lt;/i&gt;&amp;nbsp;method. All the others we will implement as empty methods.&lt;br /&gt;
&lt;br /&gt;
The&amp;nbsp;&lt;i&gt;RunStarted&lt;/i&gt;&amp;nbsp;method is called when you create a new project and this is the time that we will ask you what you want to put in your Project.wxs XML file. You will be presented with a simple dialog box where you are asked to fill in a form. Your answers will be used to create the WIX XML without you having to even open that XML file.&lt;br /&gt;
Here is what the method looks like when we have added the code to create the form and added the user response to the replacementsDictionary.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt; public void&lt;/span&gt; RunStarted(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; automationObject,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #45818e;&quot;&gt;Dictionary&lt;/span&gt;&amp;lt;string, string&amp;gt; replacementsDictionary,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #45818e;&quot;&gt;WizardRunKind &lt;/span&gt;runKind, object[] customParams)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Display a form to the user. The form collects&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // input for the custom message.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;var &lt;/span&gt;inputForm = &lt;span style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;&lt;span style=&quot;color: #45818e;&quot;&gt;UserInputForm&lt;/span&gt;(GetProjects(automationObject &lt;span style=&quot;color: blue;&quot;&gt;as&lt;/span&gt; &lt;span style=&quot;color: #45818e;&quot;&gt;DTE2&lt;/span&gt;));&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; inputForm.ShowDialog();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;var &lt;/span&gt;projectInfo = &lt;span style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;&lt;span style=&quot;color: #45818e;&quot;&gt;ProjectInfo&lt;/span&gt;(inputForm.Project);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Add custom parameters.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; replacementsDictionary.Add(&lt;span style=&quot;color: #660000;&quot;&gt;&quot;$manufacturer$&quot;&lt;/span&gt;, inputForm.Manufacturer);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; replacementsDictionary.Add(&lt;span style=&quot;color: #660000;&quot;&gt;&quot;$serviceExeName$&quot;&lt;/span&gt;, projectInfo.ServiceExeName);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; replacementsDictionary.Add(&lt;span style=&quot;color: #660000;&quot;&gt;&quot;$servicePath$&quot;&lt;/span&gt;, projectInfo.ServicePath);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; replacementsDictionary.Add(&lt;span style=&quot;color: #660000;&quot;&gt;&quot;$serviceName$&quot;&lt;/span&gt;, inputForm.ServiceName);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; replacementsDictionary.Add(&lt;span style=&quot;color: #660000;&quot;&gt;&quot;$productName$&quot;&lt;/span&gt;, inputForm.ServiceName);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; replacementsDictionary.Add(&lt;span style=&quot;color: #660000;&quot;&gt;&quot;$displayName$&quot;&lt;/span&gt;, inputForm.DisplayName);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; replacementsDictionary.Add(&lt;span style=&quot;color: #660000;&quot;&gt;&quot;$description$&quot;&lt;/span&gt;, inputForm.ServiceDescription);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; replacementsDictionary.Add(&lt;span style=&quot;color: #660000;&quot;&gt;&quot;$serviceControlName$&quot;&lt;/span&gt;, inputForm.ServiceControlName);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;catch &lt;/span&gt;(&lt;span style=&quot;color: #45818e;&quot;&gt;Exception &lt;/span&gt;ex)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #45818e;&quot;&gt;MessageBox&lt;/span&gt;.Show(ex.ToString());&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;private &lt;/span&gt;&lt;span style=&quot;color: #45818e;&quot;&gt;IEnumerable&amp;lt;Project&amp;gt;&lt;/span&gt; GetProjects(&lt;span style=&quot;color: #45818e;&quot;&gt;DTE2&lt;/span&gt; dte)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (dte == &lt;span style=&quot;color: blue;&quot;&gt;null&lt;/span&gt;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DisplayMessage(&lt;span style=&quot;color: #660000;&quot;&gt;&quot;Failed to access the Visual Studios DTE object, can&#39;t get projects&quot;&lt;/span&gt;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;return new&lt;/span&gt; &lt;span style=&quot;color: #45818e;&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #45818e;&quot;&gt;Project&lt;/span&gt;&amp;gt;();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;var&lt;/span&gt; solution = dte.Solution &lt;span style=&quot;color: blue;&quot;&gt;as&lt;/span&gt; &lt;span style=&quot;color: #45818e;&quot;&gt;Solution2&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;if &lt;/span&gt;(solution == &lt;span style=&quot;color: blue;&quot;&gt;null&lt;/span&gt;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DisplayMessage(&lt;span style=&quot;color: #660000;&quot;&gt;&quot;Failed to access the Solution of Visual Studios DTE object, can&#39;t get projects&quot;&lt;/span&gt;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;return new &lt;/span&gt;&lt;span style=&quot;color: #45818e;&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #45818e;&quot;&gt;Project&lt;/span&gt;&amp;gt;();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;return &lt;/span&gt;solution.Projects.Cast&amp;lt;&lt;span style=&quot;color: #45818e;&quot;&gt;Project&lt;/span&gt;&amp;gt;();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
The replacementsDictionary is used to replace all the occurences of the given keys with the given values from the form.&lt;br /&gt;
The GetProjects method gets the list of existing projects in the current solution. This means that we can select the Windows Service project that we want to create are installer for from the existing projects in the solution. The implementation assumes a simple solution structure, if you are using something different you may have to adjust the resulting the path in the Product.wxs file to fit your solution.&lt;br /&gt;
&lt;br /&gt;
The UI I have used is a regular Windows Form, but you should be able to use a WPF based UI as well.&lt;br /&gt;
&lt;br /&gt;
The MSDN documentation says we need to sign the Wizard assembly, but it seems to work just fine without signing, and as we are not going to install the Wizard assembly into the GAC I don&#39;t see why we need to have a strong named assembly, so I have skipped that part.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;


Adding the Wizard To the Template&lt;/h4&gt;
The MSDN article&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms185301(v=vs.110).aspx&quot;&gt;&amp;nbsp;How to: Use Wizards with Project Templates&lt;/a&gt;&amp;nbsp;states:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
The assembly that implements IWizard must be signed with a strong name and installed into the global assembly cache.&lt;/blockquote&gt;
This would be a real bummer if it was true, as VSIX doesn&#39;t support installing assemblies into the GAC and I try to avoid GAC&#39;ing assemblies if I can since I think it often makes things more complicated than need be.&lt;br /&gt;
What to do when MSDN says: &quot;No, you can&#39;t&quot;? Then we of course turn the speakers volume on our laptop and play the theme song of the great&amp;nbsp;British&amp;nbsp;TV show&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Bob_the_Builder&quot;&gt;Bob the Builder&lt;/a&gt;&amp;nbsp;on &lt;a href=&quot;http://open.spotify.com/track/4Qh15ryVjlpce23xPio2Cy&quot;&gt;Spotify&lt;/a&gt;, and listen to the Bob and his friends singing &quot;Can we fix it? Yes we can!&quot; while googling for a more positive answer than the MSDN one.&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7FpagG0ohtdSNSqn3kXYQJQAKrWgQHUqGked3U4UHiAQZXr5nX-BBBSao49T0cYZR2SM2cIniCyYiyEjLi6dWDB8A-HGTAMsBDTETnQjUHsNcfB5eclPxufBXI3NrnIb6-aIa2jawiXc/s1600/Bob+the+builder.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7FpagG0ohtdSNSqn3kXYQJQAKrWgQHUqGked3U4UHiAQZXr5nX-BBBSao49T0cYZR2SM2cIniCyYiyEjLi6dWDB8A-HGTAMsBDTETnQjUHsNcfB5eclPxufBXI3NrnIb6-aIa2jawiXc/s320/Bob+the+builder.PNG&quot; width=&quot;213&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Bob the Builder image based on original by&amp;nbsp;&lt;a href=&quot;http://www.flickr.com/people/jdhancock/&quot;&gt;jdhancock&lt;/a&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
However I had some troubles finding a lot of information, except posts on various forums by Microsoft support employees repeating the same message, you have to put it in the GAC or in the IDE probing path (a folder in the Visual Studio installation). Luckily it turns out its quite easy to do it.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The first step is to go to the Assets tab of the vsixmanifest designer and add a reference to wizard assembly:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0b7JnqA41tBJ-AgdKafaI5hiRKHIovNiXSLjv5812b1671s7PIBxiW0pdB85e9fAhoKGk5512b-OVIGEtllf3tf2A7Owco3mgH_BPt58B0dgiMh5ULiPYJuIG5dYTSWhZ-i_C2ODWDgs/s1600/Add+Assembly+Asset.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;348&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0b7JnqA41tBJ-AgdKafaI5hiRKHIovNiXSLjv5812b1671s7PIBxiW0pdB85e9fAhoKGk5512b-OVIGEtllf3tf2A7Owco3mgH_BPt58B0dgiMh5ULiPYJuIG5dYTSWhZ-i_C2ODWDgs/s640/Add+Assembly+Asset.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
The next step is to edit the VSIX template which is inside the Project Template that we added when creating the VSIX project.&lt;br /&gt;
One way of doing it is to locate the project template zip file and open it in 7-zip, and select the .vstemplate file there and choose Edit.&lt;br /&gt;
The .vstemplate is an XML file and should look similar to this when we have edited it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;lt;VSTemplate Version=&quot;3.0.0&quot; xmlns=&quot;http://schemas.microsoft.com/developer/vstemplate/2005&quot; Type=&quot;Project&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;lt;TemplateData&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;Name&amp;gt;Wix 3.6 Windows Service Setup Project&amp;lt;/Name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;Description&amp;gt;Template to create a windows service setup project&amp;lt;/Description&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;ProjectType&amp;gt;WiX&amp;lt;/ProjectType&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;ProjectSubType&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/ProjectSubType&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;SortOrder&amp;gt;1000&amp;lt;/SortOrder&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;CreateNewFolder&amp;gt;true&amp;lt;/CreateNewFolder&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;DefaultName&amp;gt;WindowsServiceSetup&amp;lt;/DefaultName&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;ProvideDefaultName&amp;gt;true&amp;lt;/ProvideDefaultName&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;LocationField&amp;gt;Enabled&amp;lt;/LocationField&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;EnableLocationBrowseButton&amp;gt;true&amp;lt;/EnableLocationBrowseButton&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;Icon&amp;gt;WixProject.ico&amp;lt;/Icon&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;lt;/TemplateData&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;lt;TemplateContent&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;Project TargetFileName=&quot;MyWindowsService.Setup.wixproj&quot; File=&quot;MyWindowsService.Setup.wixproj&quot; ReplaceParameters=&quot;true&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;ProjectItem ReplaceParameters=&quot;true&quot; TargetFileName=&quot;Product.wxs&quot;&amp;gt;Product.wxs&amp;lt;/ProjectItem&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/Project&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;lt;/TemplateContent&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: orange;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;&amp;lt;WizardExtension&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: purple; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;Assembly&amp;gt;WixWindowsServiceSetupWizard, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=null&amp;lt;/Assembly&amp;gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: purple; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;FullClassName&amp;gt;WixWindowsServiceSetupWizard.SetupWizard&amp;lt;/FullClassName&amp;gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: purple; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;lt;/WizardExtension&amp;gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;lt;/VSTemplate&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The wizard assembly is hooked into the project template by adding a WizardExtension element containing an assembly reference to the assembly containing the class that implements the IWizard interface.&lt;br /&gt;
&lt;br /&gt;
As you can see there is no PublicKeyToken (the assembly is not signed) and there is nothing in the GAC, but it seems to work anyway.&lt;br /&gt;
&lt;br /&gt;
The wizard assembly is deployed to the extensions folder below the user app data folder&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEge-HMb5aWzn8PdFuuiap1FdedcdXkCoPFms_Li7Bb_PJtosL47_5nLEKsheMmbCKGTEPmRIScDnJ6odC_nxlhv3Cwrolk79V5HSgfibrnz9m4zqyhykWvTvGC89dhyisrrtX11fMODtdA/s1600/Extension+folder.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;272&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEge-HMb5aWzn8PdFuuiap1FdedcdXkCoPFms_Li7Bb_PJtosL47_5nLEKsheMmbCKGTEPmRIScDnJ6odC_nxlhv3Cwrolk79V5HSgfibrnz9m4zqyhykWvTvGC89dhyisrrtX11fMODtdA/s640/Extension+folder.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
If we look at the extension.vsixmanifest we&#39;ll see that the assets we added in the designer above has been compiled into the following XML (and again, no signing here):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;lt;Assets&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;Asset Type=&quot;Microsoft.VisualStudio.ProjectTemplate&quot; Path=&quot;ProjectTemplates&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;Asset Type=&quot;Microsoft.VisualStudio.Assembly&quot; Path=&quot;WixWindowsServiceSetupWizard.dll&quot; AssemblyName=&quot;&lt;span style=&quot;background-color: yellow;&quot;&gt;WixWindowsServiceSetupWizard,&lt;/span&gt; Version=1.0.0.0, Culture=neutral, &lt;span style=&quot;background-color: yellow;&quot;&gt;PublicKeyToken=null&quot;&lt;/span&gt; /&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/Assets&amp;gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
I have updated the &lt;a href=&quot;http://visualstudiogallery.msdn.microsoft.com/7f35c8ce-1763-4340-b720-ab2d359009c5&quot;&gt;Wix Windows Service Setup Project Template&lt;/a&gt;&amp;nbsp;on Visual Studio Gallery with the new Wizard solution.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://windowsdevcenter.com/pub/a/windows/2007/06/06/developing-visual-studio-project-wizards.html?page=1&quot;&gt;Developing Visual Studio Project Wizards&lt;/a&gt;&amp;nbsp;is a detailed although dated article on how to create a Project Wizard.&lt;br /&gt;
&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ee710183(v=vs.110).aspx&quot;&gt;Walkthrough: Creating a Custom Action Project Item with an Item Template, Part 2&lt;/a&gt;&amp;nbsp;also has some interesting information even if it also talks about some SharePoint stuff.&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oncoding.blogspot.com/feeds/4629671982171774754/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://oncoding.blogspot.com/2012/04/visual-studio-template-wizards-without.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7203370983485193018/posts/default/4629671982171774754'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7203370983485193018/posts/default/4629671982171774754'/><link rel='alternate' type='text/html' href='http://oncoding.blogspot.com/2012/04/visual-studio-template-wizards-without.html' title='Visual Studio 11 Project Template Wizards, no GAC&#39;ing'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17693565125055146738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgC3P9RKQkSI4zl2t5ZPTGxFp9teXng9gw_JgAcKRHwcHajS5StDEq2rtP-K4gtRjBkmAf6ztGx-jifTIiA9xxQ97hzlHN4RkvXppZUauKh7AyFy7kzPDCVN8bpWHpuQMchq1VYUcF9fNY/s72-c/Wizard+Dialog.PNG" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7203370983485193018.post-7209394634399302207</id><published>2012-04-08T19:18:00.000+02:00</published><updated>2012-04-12T10:52:18.839+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="assembly"/><category scheme="http://www.blogger.com/atom/ns#" term="version number"/><title type='text'>.NET Assembly Version Numbers</title><content type='html'>Version numbers on .NET assemblies are both simple and complicated stuff. This post will explain the details of the different version numbers on an assembly and what they are used for, then I will show how we can modify all of them on an existing assembly without access to the source code from which it was originally built.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;





The 3 .Net Assembly Version Numbers&amp;nbsp;&lt;/h3&gt;
The simple story of version numbers is presented in the MSDN article &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/51ket42z(v=vs.110).aspx&quot;&gt;Assembly Versioning&lt;/a&gt;.&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;b&gt;assembly&#39;s version number&lt;/b&gt;, which, together with the assembly name and culture information, is part of the assembly&#39;s identity. This number is used by the runtime to enforce version policy and plays a key part in the type resolution process at run time.&lt;/li&gt;
&lt;li&gt;An &lt;b&gt;informational version&lt;/b&gt;, which is a string that represents additional version information included for informational purposes only.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Ok, so an assembly has two version numbers, a real version number and a descriptive text thing, right?&lt;/div&gt;
&lt;div&gt;
Actually, no, it&#39;s not that simple.&lt;/div&gt;
&lt;div&gt;
Lets build a simple dll and look at the properties of the result in the file explorer:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjbbousw8x_j-aE4XOxKd7mibQ8ksBeyQhLXBHVLyClBpeoJHxiw-7qAcP_9bGGMyIqRwodqKrjHluC5EnBwVIEu35LcMm3hg5C3hbzNxuvXvKdR1ft-9ZNIhYWGdQpGJSCARePHWHqqo/s1600/assembly+version+1.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;227&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjbbousw8x_j-aE4XOxKd7mibQ8ksBeyQhLXBHVLyClBpeoJHxiw-7qAcP_9bGGMyIqRwodqKrjHluC5EnBwVIEu35LcMm3hg5C3hbzNxuvXvKdR1ft-9ZNIhYWGdQpGJSCARePHWHqqo/s320/assembly+version+1.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
File version and Product Version? Which is which?&lt;/div&gt;
&lt;div&gt;
Lets have a look at the AssemblyInfo.cs file:&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0sErOBswCMPezc_5nvNKxRbetihXEoTl-BqmzBApwsmA7dZB0rfiw3i93OQzMN7aKMEDWro4S6ApN3WNF4zDwTktXMqQaafyr3FAUDTBbJiMYEzGyyM341MMaWTxx8tDIqp7Ow2mrV4A/s1600/assemblyInfo.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;149&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0sErOBswCMPezc_5nvNKxRbetihXEoTl-BqmzBApwsmA7dZB0rfiw3i93OQzMN7aKMEDWro4S6ApN3WNF4zDwTktXMqQaafyr3FAUDTBbJiMYEzGyyM341MMaWTxx8tDIqp7Ow2mrV4A/s320/assemblyInfo.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
The AssemblyInfo.cs has two version attributes by default. The AssemblyVersion and the AssemblyFileVersion. Lets set these two numbers to 1.1.0.0 and 2.2.0.0 as shown above and lets see what happens to the ClassLibrary1.dll properties after we build.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtv7ydouXkfi0RXc0sUh2b7850lDv3lS9DeYOQETk5P3NDpSuQtE7hTA2mb6bcJvnCQZI2I3ftpGRpvTnWzNi8wkxrshixIWTsBTm5zJN9sVX-YxxSHAFPix1k4_DCasBFNjyc48na0nM/s1600/Assembly+Version+2.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;286&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtv7ydouXkfi0RXc0sUh2b7850lDv3lS9DeYOQETk5P3NDpSuQtE7hTA2mb6bcJvnCQZI2I3ftpGRpvTnWzNi8wkxrshixIWTsBTm5zJN9sVX-YxxSHAFPix1k4_DCasBFNjyc48na0nM/s400/Assembly+Version+2.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
We can now see that the File version is changed as expected, but the AssemblyVersion number isn&#39;t shown at all, we will get to that in a minute. There&#39;s a field called Product version, which has the same value as the File version. The Product version is the same version number as Microsoft refers to as Informational version in the Assembly Versioning article. The informational version is set to the File version if not set.&lt;br /&gt;
We can set the Product Version by adding a&amp;nbsp;&lt;i&gt;AssemblyInformationalVersion &lt;/i&gt;attribute to the AssemblyInfo.cs file.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieHi7ij6z-HQn3kAv_LD9h4mDkiAUUGvtZMUZK1ofLwca1RUiKNOXut_-uZpjyfTviwOUrsYW7uH9l4E0knfiJZz5AAq7g8XdZTgjZ0xh9SqLnIrY_6TbshanE9vmwh7AvFhaEwD_y4J8/s1600/AssemblyInfo+2.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;78&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieHi7ij6z-HQn3kAv_LD9h4mDkiAUUGvtZMUZK1ofLwca1RUiKNOXut_-uZpjyfTviwOUrsYW7uH9l4E0knfiJZz5AAq7g8XdZTgjZ0xh9SqLnIrY_6TbshanE9vmwh7AvFhaEwD_y4J8/s400/AssemblyInfo+2.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
If we build again we get the result as expected.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIRLJ5I1FKM7CHJay_sZ6EgPJXrfgyMfMdj0K5nnUpLQywRbWH8r55LlEfsOhnSrFgP0B2r72nHqNFLmmp76T5mZcuXaz16clDkGywUNho5mt7TiHFsXvtxn-PYdmdm8NJqpy-d2lcr7c/s1600/Assembly+Version+3.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;224&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIRLJ5I1FKM7CHJay_sZ6EgPJXrfgyMfMdj0K5nnUpLQywRbWH8r55LlEfsOhnSrFgP0B2r72nHqNFLmmp76T5mZcuXaz16clDkGywUNho5mt7TiHFsXvtxn-PYdmdm8NJqpy-d2lcr7c/s320/Assembly+Version+3.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Now that we know how to set and check the last two version numbers, how do we check the most important one, the one that the .Net runtime uses when it determine to load the assembly or not, &lt;u&gt;the&lt;/u&gt; Assembly Version?&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Its clearly not in the dll properties dialog we can access from the Windows Explorer. We can read the assembly version&amp;nbsp;programatically&amp;nbsp;by using the following code:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;pre style=&quot;font-family: Consolas, Courier, monospace; font-size: 13px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;&quot;&gt;Version version = AssemblyName.GetAssemblyName(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;MyAssembly.exe&quot;&lt;/span&gt;).Version&lt;/pre&gt;
&lt;br /&gt;
&lt;h4&gt;





Reading Assembly Version Number using Powershell&lt;/h4&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Depending on what version you used to build the assembly and what version of Powershell you have installed you may be able to use the same method from Powershell.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
I used Visual Studio 11 and .NET framework 4.5 when testing this, thus I had to download and install &lt;a href=&quot;http://www.microsoft.com/download/en/details.aspx?id=27548&quot;&gt;Powershell 3.0&lt;/a&gt;&amp;nbsp;to check my assembly.&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
When you have the right Powershell version you can do:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;[Reflection.AssemblyName]::GetAssemblyName(&#39;full path to the assembly&#39;).Version&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Which is essentially just the same as calling it from C# code as shown above.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3qXhLYyce2BePWi8HAW7Uht6BBaVp9q8SfeXiPC37f4Hn_1o9LxG3eD6iB524c8S1QFeQ6rGcY6F-t_VI9eLX8NJGtQKoZOBF5zQAsvUyTknZY0BEHIYq-qi0dN_fjI3zC9Q7ZRoKHLI/s1600/assembly+version+powershell.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;292&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3qXhLYyce2BePWi8HAW7Uht6BBaVp9q8SfeXiPC37f4Hn_1o9LxG3eD6iB524c8S1QFeQ6rGcY6F-t_VI9eLX8NJGtQKoZOBF5zQAsvUyTknZY0BEHIYq-qi0dN_fjI3zC9Q7ZRoKHLI/s640/assembly+version+powershell.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4&gt;





Reading Assembly Version Number using a Decompiler&lt;/h4&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
If you don&#39;t have the right Powershell version then probably the easiest way to get the assembly version number is to use a tool such as &lt;a href=&quot;http://www.telerik.com/products/decompiler.aspx&quot;&gt;Telerik JustDecompile&lt;/a&gt; which also will present the assembly version.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOBrkmHIvWwQtU9fBJaUu8jlJ4LgIczQ4CLALCM57CLzkMytMAQIn_OpQIfFyrST4nkPEIqZlHnGDjnfMAqwi3t0OLKS_fCJRQJdji-YStGb9zIU7SIuFqAVShbzoxq2CmedbPMyHCJUw/s1600/assembly+version+telerik.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;283&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOBrkmHIvWwQtU9fBJaUu8jlJ4LgIczQ4CLALCM57CLzkMytMAQIn_OpQIfFyrST4nkPEIqZlHnGDjnfMAqwi3t0OLKS_fCJRQJdji-YStGb9zIU7SIuFqAVShbzoxq2CmedbPMyHCJUw/s400/assembly+version+telerik.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
For assemblies we are using in a Visual Studio solution the easiest way is of course to simply look at the properties of the referenced assembly.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjqHn4orPNUKk1YxhNNLVrHZpBh0zsZGu_QINz0T-1VjCdzdNbklmeP5-r8FxaA8q419oLiawcWw5RDyBNNGePVIpS4PITV9Ci5COS2J0ITyK1Wo_FcAkm1nhh82Zt_TdRCINz1Dz_8ak/s1600/assembly+version+visual+studio.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjqHn4orPNUKk1YxhNNLVrHZpBh0zsZGu_QINz0T-1VjCdzdNbklmeP5-r8FxaA8q419oLiawcWw5RDyBNNGePVIpS4PITV9Ci5COS2J0ITyK1Wo_FcAkm1nhh82Zt_TdRCINz1Dz_8ak/s1600/assembly+version+visual+studio.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4&gt;





Just Informational?&lt;/h4&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
So we have 3 version numbers. As mentioned the Assembly Version and Product Version are described in&amp;nbsp;the MSDN article&amp;nbsp;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/51ket42z(v=vs.110).aspx&quot;&gt;Assembly Versioning&lt;/a&gt;. The File Version and the Assembly version are documented &lt;a href=&quot;http://support.microsoft.com/kb/556041&quot;&gt;here&lt;/a&gt;.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
If we combine the information from these two articles we get:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;Assembly Version - the real deal, the number that matters&lt;/li&gt;
&lt;li&gt;File Version - a number that can be used to tell the developer what version the should have been if we had upped the assembly version number&lt;/li&gt;
&lt;li&gt;Product Version - a text string that is just informational, doesn&#39;t even have to be a number at all.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4jBQ4B39lMbGlK1ZAyZVx5yOZE4auS0NfatroRuPBPcHGnAni8bAHetNbYiJso4SBy3Nnx-57e3VQdKY-i_18eIC9lkABhKhkA-Z3nZoWN0QpK_eZmP-uAbUr6VGH9W8kp7KWUGZXFwU/s1600/Assembly+version+text.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;252&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4jBQ4B39lMbGlK1ZAyZVx5yOZE4auS0NfatroRuPBPcHGnAni8bAHetNbYiJso4SBy3Nnx-57e3VQdKY-i_18eIC9lkABhKhkA-Z3nZoWN0QpK_eZmP-uAbUr6VGH9W8kp7KWUGZXFwU/s400/Assembly+version+text.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
However it turns out that the Product Version number isn&#39;t that free form after all as one could be lead to believe reading the MSDN documentation, at least not for all types of .NET applications.&lt;br /&gt;
I think that the Windows forms application team at Microsoft have had better days at work than the day they designed the &lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;System.Windows.Forms.Application&lt;/span&gt; class. This class has features that probably would be&amp;nbsp;useful&amp;nbsp;for console applications and others, while it at the same time has functionality that only makes sense in a Windows Forms application. A few warning signs that could indicate a need for a closer look at&amp;nbsp;&lt;a href=&quot;http://www.objectmentor.com/resources/articles/srp.pdf&quot;&gt;the Single Responsibility Principle&lt;/a&gt;.&lt;br /&gt;
Anyway this class also has a dependency on the Product Version string of the assembly, and remember, this is the version string that the MSDN says the following about :&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &#39;Segoe UI&#39;, Verdana, Arial; font-size: 13px; text-align: left;&quot;&gt;&lt;i&gt;The informational version is a string that attaches additional version information to an assembly for informational purposes only; this information is &lt;u&gt;&lt;b&gt;not&lt;/b&gt;&lt;/u&gt; used at run time.&lt;/i&gt;&lt;/span&gt;&lt;/blockquote&gt;
Well this is simply not true for a Windows forms application.&lt;br /&gt;
Both the static properties &lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;UserAppDataPath&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;and &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;CommonAppDataPath&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;that are used to get path to special folders are using the string stored in the Product Version property of the entry assembly.&lt;/span&gt;&lt;br /&gt;
Which means that should you decide to put any of the following characters in the version string &#39;&lt;span style=&quot;font-family: &#39;Segoe UI&#39;, Verdana, Arial; font-size: 13px; text-align: left;&quot;&gt;/ \ * ? &amp;lt; &amp;gt; |&#39; &lt;/span&gt;&lt;span style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;of your Windows forms application assembly you may quickly end up in trouble using the Application class.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h4&gt;


&lt;/h4&gt;
&lt;h4&gt;






.NET Framework 4.5 Version Numbering&lt;/h4&gt;
Rick Strahl recently posted an &lt;a href=&quot;http://www.west-wind.com/weblog/posts/2012/Mar/13/NET-45-is-an-inplace-replacement-for-NET-40&quot;&gt;article&lt;/a&gt; about the version numbers on the .NET 4.5 assemblies, and Scot Hanselman later posted &lt;a href=&quot;http://www.hanselman.com/blog/NETVersioningAndMultiTargetingNET45IsAnInplaceUpgradeToNET40.aspx&quot;&gt;another&lt;/a&gt; which in part responded to some of Ricks findings.&lt;br /&gt;
I think the fact that these .NET Masters don&#39;t immediately agree on such a seemingly simple thing as version numbers of the assemblies should tell us something about the real simplicity of the matter.&lt;br /&gt;
Reading Hanselman&#39;s post it looks as things aren&#39;t as bad as one could think when reading Strahl&#39;s post, but I do think Microsoft could have made things easier for us. As the Product Version number isn&#39;t supposed to be used for anything, why not put the 4.5 number there?&lt;br /&gt;
Then it would have been so easy to see that this is in fact a 4.5 assembly. On the other hand, when we see what Microsoft has done in the Window&amp;nbsp;&lt;span style=&quot;background-color: white;&quot;&gt;f&lt;/span&gt;orms example just mentioned, who knows what else is dependent on that Product Version, even if it is not supposed to be in use by the .NET Framework.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Hacking assembly version numbers using ILDASM and ILASM&lt;/b&gt;&lt;br /&gt;
Quite recently I found myself in a situation where I had an application that was configured to load a plugin written by someone else. The author of the plugin had messed up the version number of the plugin he gave me and he didn&#39;t have time to fix it. The application refused to load the plugin, and I couldn&#39;t reconfigure it so I thought I just had to wait for a new plugin. Then it hit me that this version number have to be stored in the assembly somewhere and &amp;nbsp;it should be possible to change it, and in fact it is very possible to change all three version numbers of an assembly.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;


&lt;/h4&gt;
&lt;h4&gt;






Ildasm.exe&lt;/h4&gt;
&lt;div&gt;
&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/f7dy01k1(v=vs.110).aspx&quot;&gt;Ildasm&lt;/a&gt;&amp;nbsp;is the&amp;nbsp;MSIL Disassembler which can read assembly files and turn them into a somewhat human readable text file + a .res file containing assembly resources.&lt;/div&gt;
&lt;div&gt;
The cool thing is that we can edit these two files and change the version numbers, then we can re-assemble the dll using Ilasm on these to files and getting a dll file again.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
To dissamble the dll simply start the ildasm.exe &amp;lt;dll name&amp;gt;.&lt;br /&gt;
When the IL DASM application has started we can dump the contents of the assembly to two files by pressing ctrl-d and then check all boxes in the Dump options dialog that pops up.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXaNT1RhF6wmTWhOEXqGC7Tup303ZyXGa3-UWKtz8n8MqH6iWraikTqk-m9lOb4nSnuPuP1TIqasYeWnZ5O9HeT3K5w6ChmOCUzVOwniZDujttOmrH__XDyGGTCc1Z6klkE4KOjYWpfyU/s1600/Ildasm+Dump.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXaNT1RhF6wmTWhOEXqGC7Tup303ZyXGa3-UWKtz8n8MqH6iWraikTqk-m9lOb4nSnuPuP1TIqasYeWnZ5O9HeT3K5w6ChmOCUzVOwniZDujttOmrH__XDyGGTCc1Z6klkE4KOjYWpfyU/s400/Ildasm+Dump.PNG&quot; width=&quot;282&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
Name the result in the save dialog that follows and then we get two files with the extensions .il and .res.&lt;br /&gt;
Both files can be edited in Visual Studio.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;





Changing the Assembly Version&lt;/h4&gt;
&lt;/div&gt;
&lt;div&gt;
To change the assembly version we open the .il file and search for a piece of il code that starts with .assembly followed by a comment and then the assembly name.&lt;/div&gt;
&lt;div&gt;
It will look similar to this:&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
.assembly /*20000001*/ ClassLibrary1&lt;/div&gt;
&lt;div&gt;
{&lt;/div&gt;
&lt;div&gt;
....&lt;/div&gt;
&lt;div&gt;
....&lt;/div&gt;
&lt;div&gt;
.... &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; .hash algorithm 0x00008004&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&lt;span style=&quot;background-color: yellow;&quot;&gt; .ver 3:3:0:0&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
The assembly version number is changed by simply editing the string after .ver and then save the .il file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;





Changing the File version and Product version&lt;/h4&gt;
&lt;div&gt;
Both the File and Production version can be changed by editing the .res file in Visual Studio 11.&lt;/div&gt;
&lt;div&gt;
If you open the .res file it will look similar to this:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQPMMNi20a4w0isPKB1vbeRv2U7UCqALtsanJcZmYCC2oFmv17Nqt87ebD3_xJoE9CoSzm9gLMotRPeJul48ok6-1yVX8QW60O9Q78I217NhmgZLPGTuQEYdTdSXb-sY6a1fOc9j_iluY/s1600/res+file.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;197&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQPMMNi20a4w0isPKB1vbeRv2U7UCqALtsanJcZmYCC2oFmv17Nqt87ebD3_xJoE9CoSzm9gLMotRPeJul48ok6-1yVX8QW60O9Q78I217NhmgZLPGTuQEYdTdSXb-sY6a1fOc9j_iluY/s400/res+file.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
Double-click the 1 [Neutral] node to open the resource editor&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJ7TpVTa6VwCdUxY9AMFxuZiwwm4_CA2wQ6pXK7_P7Zr9ojJCebQg7qwLAto5KbjHa7t9ZFdNOZeqxgimHCpnv0TO2bAk7YfCmtZjDhztTe7ID9OWAtw8efz7DPCOKA_2Ost5_feKvKrI/s1600/Resource+editor.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJ7TpVTa6VwCdUxY9AMFxuZiwwm4_CA2wQ6pXK7_P7Zr9ojJCebQg7qwLAto5KbjHa7t9ZFdNOZeqxgimHCpnv0TO2bAk7YfCmtZjDhztTe7ID9OWAtw8efz7DPCOKA_2Ost5_feKvKrI/s400/Resource+editor.PNG&quot; width=&quot;295&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Change the Fileversion in the upper part. Notice that the PRODUCTVERSION is shown as 0.0.0.0 in the upper part because it is not a number. Edit the ProductVersion shown in the bottom to change it as text.&lt;br /&gt;
&lt;br /&gt;
Save the .res file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;





Create the modified assembly from the .il file and the .res file&lt;/h4&gt;
&lt;div&gt;
To build a new assembly from the modified .il file and the modified .res file open a Developer Command Prompt as shown:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhf5i4Uh3EhOZchyphenhyphensDgPcpNepiBKKBAjhMOU-pjEh2gXFGYPEtjBn9w94nOJlkpXd4VU_jfR6DQ4S6PrsOe1QnG3s07sf5SeURpjcX0b3VFL0sK-nWU6shf-G3rioeKzGEMYGjJIjdDoz8/s1600/ilasm.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;417&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhf5i4Uh3EhOZchyphenhyphensDgPcpNepiBKKBAjhMOU-pjEh2gXFGYPEtjBn9w94nOJlkpXd4VU_jfR6DQ4S6PrsOe1QnG3s07sf5SeURpjcX0b3VFL0sK-nWU6shf-G3rioeKzGEMYGjJIjdDoz8/s640/ilasm.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
Execute: ilasm /resource:&amp;lt;resource file&amp;gt; /dll &amp;lt;il file&amp;gt;.&lt;br /&gt;
And we have changed the version numbers of our assembly file.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://oncoding.blogspot.com/feeds/7209394634399302207/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://oncoding.blogspot.com/2012/04/net-assembly-version-numbers.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7203370983485193018/posts/default/7209394634399302207'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7203370983485193018/posts/default/7209394634399302207'/><link rel='alternate' type='text/html' href='http://oncoding.blogspot.com/2012/04/net-assembly-version-numbers.html' title='.NET Assembly Version Numbers'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17693565125055146738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjbbousw8x_j-aE4XOxKd7mibQ8ksBeyQhLXBHVLyClBpeoJHxiw-7qAcP_9bGGMyIqRwodqKrjHluC5EnBwVIEu35LcMm3hg5C3hbzNxuvXvKdR1ft-9ZNIhYWGdQpGJSCARePHWHqqo/s72-c/assembly+version+1.PNG" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7203370983485193018.post-4323832401574872767</id><published>2012-04-02T21:16:00.002+02:00</published><updated>2012-04-11T19:48:18.435+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Project Template"/><category scheme="http://www.blogger.com/atom/ns#" term="Service Installer"/><category scheme="http://www.blogger.com/atom/ns#" term="VSIX"/><category scheme="http://www.blogger.com/atom/ns#" term="wix"/><title type='text'>Creating a Wix Windows Service installer project template for Visual Studio 11</title><content type='html'>When I wrote my &lt;a href=&quot;http://oncoding.blogspot.com/2012/03/creating-web-service-installer-in.html&quot;&gt;first blog&amp;nbsp;post about creating a wix web service installer&lt;/a&gt;&amp;nbsp;I promised I would look into how to make a Visual Studio project template out of it.&lt;br /&gt;
I won&#39;t do that today. I will start out simple and create a project template for making windows service projects with Wix and Visual Studio 11.&lt;br /&gt;
Creating Wix Windows Service installers using the standard Wix Setup Project template isn&#39;t exactly rocket science, but you still need to remember what XML you have to put into your Product.wxs file.&lt;br /&gt;
I am not the kind of guy who can remember these things and I hate having to google around for such things when I just want to quickly make a very basic installer for my Windows Service. Most of the time I just want an installer that installs the thing, with no options or anything, but I am required to have an installer. As long as I can produce a MSI file that installs it, everyone is happy.&lt;br /&gt;
&lt;br /&gt;
So I want a project template that lets me say, I want my installer, and&amp;nbsp;preferably&amp;nbsp;that&#39;s it. I haven&#39;t got quite there yet, but I have a template that lets me say, I want my installer, and then it will ask me to fill in the &#39;*&#39; marked fields, which I think is a lot easier than the generic Wix Setup Project template that gives me no hint as to what I need to do to make a Windows Service Installer.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;

Creating a Visual Studio Project Template&lt;/h4&gt;
&lt;div&gt;
First you should download and install&amp;nbsp;&lt;a href=&quot;http://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;amp;id=28990&quot;&gt;Visual Studio 11 beta SDK&lt;/a&gt;.
&lt;/div&gt;
&lt;div&gt;
Microsoft provides pretty good description on how to &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/xkh1wxd8(v=vs.110).aspx&quot;&gt;How to: Create Project Templates&lt;/a&gt;&amp;nbsp;and then&amp;nbsp;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/dd885241(v=vs.110).aspx&quot;&gt;Creating Extensions By Using the VSIX Project Template&lt;/a&gt;, the latter doesn&#39;t seem to be 100% accurate at the moment, but I guess that is as expected considering it is a beta version.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I started out creating a setup project using the Wix 3.6 Setup Project template. This creates a project containing mainly a Product.wxs file.&lt;/div&gt;
&lt;div&gt;
I changed this to a generic Product.wxs file that will create a Windows Service Installer once the required fields has been filled in (the fields marked in yellow starting with &amp;lt;*Insert&amp;gt;):&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrBjLoLQL_cI1cf5Hgnz2Nw7h70ytDDHSAs6wDchwozFp_dxL0hooQWcHN-EHv1NtsAPIyt2HG_NhTH4CmWNvwZXS1-6v7X_YjSiR4oiUHKYKJEgUWl10kOwLv8hee7nthwFn_CnhBfZA/s1600/Wix+project.wxs.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;409&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrBjLoLQL_cI1cf5Hgnz2Nw7h70ytDDHSAs6wDchwozFp_dxL0hooQWcHN-EHv1NtsAPIyt2HG_NhTH4CmWNvwZXS1-6v7X_YjSiR4oiUHKYKJEgUWl10kOwLv8hee7nthwFn_CnhBfZA/s640/Wix+project.wxs.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Produc.wxs&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;When the project is as we want it, we export it as a template by going to the file menu and select &quot;Export template...&quot;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5_j5OHVO_nxaq19Dw-U4T6y6znc3Sujej8zrV3Q-KYRSFlH1u1I50U18JKywk8ucc9bN8gIUDJadTKubvv475E74ZvW1dgRWZFY-D9a0Zes6rLXY6ljMw9TT54v3WcMR_L-i7NDOWPwI/s1600/Export+Template.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;539&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5_j5OHVO_nxaq19Dw-U4T6y6znc3Sujej8zrV3Q-KYRSFlH1u1I50U18JKywk8ucc9bN8gIUDJadTKubvv475E74ZvW1dgRWZFY-D9a0Zes6rLXY6ljMw9TT54v3WcMR_L-i7NDOWPwI/s640/Export+Template.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Export Template Wizard&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Select &quot;Project template&quot; and the project you want to use for your template.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;You will now get a zip file in&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Segoe UI&#39;, Verdana, Arial;&quot;&gt;%USERPROFILE%\My Documents\Visual Studio 11\My Exported Templates\&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;This zip file can then be used when we create our vsix file.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Add new project and select a VSIX project.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinRKSyIcp0YUcWoAweYfQSM28s45P2IvZgW1HSrWpER4vuiZq-scdlqAmVDP_g7ubO9Q0ZTAZBsLUj8SCTsDqnNXoS1M8HL2iriN6cshpqhqUVyfNpJVUFz-4CEcjGmnfzoefMRGvlnCY/s1600/VSIX+project.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;441&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinRKSyIcp0YUcWoAweYfQSM28s45P2IvZgW1HSrWpER4vuiZq-scdlqAmVDP_g7ubO9Q0ZTAZBsLUj8SCTsDqnNXoS1M8HL2iriN6cshpqhqUVyfNpJVUFz-4CEcjGmnfzoefMRGvlnCY/s640/VSIX+project.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Then you will be presented with the following dialog which should be filled in something like this:&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2-kZByFEZkCB021t3rMGpCPZx6my9i0guXh_JA4cS6DyAbL0D-x-9PxH3KsAwcAIMdBOBpzI__pKvKKV0x8qdhaljPvls9Y5lO4ZzHGEMCZf4a3lm8qHSLgx4mQUAk27TSuYWJhTpx7c/s1600/vsix+metadata.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;370&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2-kZByFEZkCB021t3rMGpCPZx6my9i0guXh_JA4cS6DyAbL0D-x-9PxH3KsAwcAIMdBOBpzI__pKvKKV0x8qdhaljPvls9Y5lO4ZzHGEMCZf4a3lm8qHSLgx4mQUAk27TSuYWJhTpx7c/s640/vsix+metadata.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Then switch to Assets tab and add the zip file you built earlier.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Then hit build and you have your vsix file.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;This vsix can then be uploaded to visual studio gallery if you want, I have uploaded mine here:&amp;nbsp;&lt;a href=&quot;http://visualstudiogallery.msdn.microsoft.com/7f35c8ce-1763-4340-b720-ab2d359009c5&quot; style=&quot;text-align: center;&quot;&gt;http://visualstudiogallery.msdn.microsoft.com/7f35c8ce-1763-4340-b720-ab2d359009c5&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;The promised template for Web Service installers will follow soon....&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://oncoding.blogspot.com/feeds/4323832401574872767/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://oncoding.blogspot.com/2012/04/creating-wix-windows-service-installer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7203370983485193018/posts/default/4323832401574872767'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7203370983485193018/posts/default/4323832401574872767'/><link rel='alternate' type='text/html' href='http://oncoding.blogspot.com/2012/04/creating-wix-windows-service-installer.html' title='Creating a Wix Windows Service installer project template for Visual Studio 11'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17693565125055146738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrBjLoLQL_cI1cf5Hgnz2Nw7h70ytDDHSAs6wDchwozFp_dxL0hooQWcHN-EHv1NtsAPIyt2HG_NhTH4CmWNvwZXS1-6v7X_YjSiR4oiUHKYKJEgUWl10kOwLv8hee7nthwFn_CnhBfZA/s72-c/Wix+project.wxs.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7203370983485193018.post-6321383067867183962</id><published>2012-03-30T18:29:00.004+02:00</published><updated>2012-04-01T14:54:08.909+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="nDepend"/><category scheme="http://www.blogger.com/atom/ns#" term="Stable Dependencies Principle"/><title type='text'>The Stable Dependencies Principle (SDP) and nDepend</title><content type='html'>Latin used to be the universal academic language and this probably why Latin is still in use in classical academic disciplines such as law and medicine. Particularly in medicine, even the simplest texts appears as complete gibberish to the uninitiated.&lt;br /&gt;
Computer science on the other is a rather young academic discipline. This is probably a reason why we don&#39;t have to deal with old luggage such as learning some old language such as&amp;nbsp;Latin&amp;nbsp;to learn the field.&lt;br /&gt;
At least this was the case&amp;nbsp;until about 1994 when Robert C. Martin of Object Mentor introduced three design quality metrics in his paper &lt;a href=&quot;http://www.objectmentor.com/resources/articles/oodmetrc.pdf&quot; target=&quot;_blank&quot;&gt;OO Design Quality Metrics&lt;/a&gt;&amp;nbsp;and when doing this decided that it was time to have some Latin in computer science as well.&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Ca : Afferent Couplings : The number of classes outside this component that depend upon classes within this component&lt;/li&gt;
&lt;li&gt;Ce : Efferent Couplings : The number of classes inside this component that depend upon classes&amp;nbsp;outside this component&lt;/li&gt;
&lt;li&gt;I : Instability : (Ce ÷ (Ca+Ce)) : This metric has the range [0,1]. &amp;nbsp;I=0 &amp;nbsp;indicates a maximally&amp;nbsp;stable category. &amp;nbsp;I=1 indicates a maximally instable component.&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;i&gt;Actually in his original paper he talked about categories, referring to Grady Booch, but he has later repeated the same metrics for components&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;
















Is the ferry coming or is it leaving?&lt;/h3&gt;
Instability is regular english, but &quot;Afferent and Efferent Couplings&quot;? I can easily remember that its about incoming and outgoing couplings, but I suppose incoming and outgoing would have been to simple.&lt;br /&gt;
If you try to google them you will see that the most common use of afferent and efferent are as medical terms. Wikipedia defines afferent as: &quot;&lt;b style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19px;&quot;&gt;Afferent&lt;/b&gt;&lt;span style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19px;&quot;&gt;&amp;nbsp;is an&amp;nbsp;&lt;/span&gt;&lt;a class=&quot;mw-redirect&quot; href=&quot;http://en.wikipedia.org/wiki/Anatomical&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; font-family: sans-serif; font-size: 13px; line-height: 19px; text-decoration: none;&quot; title=&quot;Anatomical&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;anatomical&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19px;&quot;&gt;&amp;nbsp;term&quot; &lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: sans-serif; line-height: 19px;&quot;&gt;and&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19px;&quot;&gt; &quot;&lt;/span&gt;&lt;b style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19px;&quot;&gt;Efferent&lt;/b&gt;&lt;span style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19px;&quot;&gt;&amp;nbsp;is an&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Anatomy&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: none; background-origin: initial; font-family: sans-serif; font-size: 13px; line-height: 19px; text-decoration: none;&quot; title=&quot;Anatomy&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;anatomical&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19px;&quot;&gt;&amp;nbsp;term&quot;. &lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: white; line-height: 19px;&quot;&gt;S&lt;/span&gt;&lt;span style=&quot;background-color: white; line-height: 19px;&quot;&gt;ame story at &lt;a href=&quot;http://dictionary.reference.com/browse/afferent?s=t&quot; target=&quot;_blank&quot;&gt;dictionary.reference.com&lt;/a&gt;,&amp;nbsp;no references to classes and dependencies, just medicine and anatomy.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
Well as I said, doctors are used to this Latin business, I am not, but I try to remember which is which by trying to remember the little Latin I do know and what these two words are composed of.&lt;br /&gt;
Afferent is ad- + ferre and efferent is ex- + ferre, which means roughly something along the lines of &quot;carry to&quot; and &quot;carry away from&quot;. There obviously is some rule in latin that ad- before an f, becomes af-, and ex- before an f becomes ef-.&lt;br /&gt;
The origins of the word ferry is also ferre.&lt;br /&gt;
So we only have to remember that Af- is Ad-, and then we have to know that Ad means towards.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
















Ad-ferre - the ferry is coming&lt;/h3&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXX_nBSMFGu2AKyqmJOCrqnmwRmoT2bk2jw5QvMr5azjT8pLWhmk5Rwz2FvwBJJfWs2mAx0PETIp9N7FOPLU-9eHm6QdTQaYY6XJ56GE8UfN6Wo-euUQvMotGiYPhs0MmgvGc-Wfvn9gs/s1600/ferry+coming.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;211&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXX_nBSMFGu2AKyqmJOCrqnmwRmoT2bk2jw5QvMr5azjT8pLWhmk5Rwz2FvwBJJfWs2mAx0PETIp9N7FOPLU-9eHm6QdTQaYY6XJ56GE8UfN6Wo-euUQvMotGiYPhs0MmgvGc-Wfvn9gs/s320/ferry+coming.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8hG0_IBSCHwApUq6yk0QCM6s3ICxYzP-vlUPMydbTI53xySEyrkZ5OZts_BhwzBor0dNcqwe_pctMgT6MXuoUAsCqlRkK_RAPkDTrRnLuW4tRD1iDNn8uCE-92Gy4CTD0Ph9IgFKoGxc/s1600/afferent.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8hG0_IBSCHwApUq6yk0QCM6s3ICxYzP-vlUPMydbTI53xySEyrkZ5OZts_BhwzBor0dNcqwe_pctMgT6MXuoUAsCqlRkK_RAPkDTrRnLuW4tRD1iDNn8uCE-92Gy4CTD0Ph9IgFKoGxc/s320/afferent.png&quot; width=&quot;317&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
We have afferent coupling when the direction of the dependencies is going inwards, or towards our component.&lt;/div&gt;
&lt;br /&gt;
&lt;h3&gt;
















Ex-ferre - the ferry is leaving, &lt;b&gt;&lt;u&gt;ex&lt;/u&gt;&lt;/b&gt;iting the port&lt;/h3&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ7XTSbgHW1snMKe5bc_M8GctqUvSyNfgj-dwW4WFgWz_MxYAq5VQzHV4Ao_pi5MXDhYwdWmCjmhoMBUn1moAgA4PaNxMWPdSNayjv1AsjtDtf-yXBcoyP7O5TrERmS5jyHL0CQvfVgyA/s1600/ferry.leaving.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;213&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ7XTSbgHW1snMKe5bc_M8GctqUvSyNfgj-dwW4WFgWz_MxYAq5VQzHV4Ao_pi5MXDhYwdWmCjmhoMBUn1moAgA4PaNxMWPdSNayjv1AsjtDtf-yXBcoyP7O5TrERmS5jyHL0CQvfVgyA/s320/ferry.leaving.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
If we also can remember that Ef- really is Ex-,&amp;nbsp;and Ex- mean &quot;out of&quot;, we have got it. I always think of Exodus or Exit when trying to remember the meaning of Ex.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;text-align: left;&quot;&gt;We have efferent couplings when the direction of the dependencies is going away from our component. When we are depending on something.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;

















The Main Sequence and the Stable-Abstraction Principle (SAP)&lt;/h3&gt;
&lt;div&gt;
So now that we remember what Ce, Ca and I means we can go on to the next step and look into what we can do once we know how to calculate the Instability of a component and what it means.&lt;/div&gt;
&lt;div&gt;
Well actually I have only mentioned that the Instability is related to afferent and efferent couplings, but the general idea is that this Instability number tells us something about how hard it is to change the component.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This is not to say that every component should be hard nor that all should be easy to change.&lt;/div&gt;
&lt;div&gt;
Martin writes in his 1994 paper about the main sequence, and he later refines this into the Stable-Abstraction Principle which states:&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;i&gt;A component should be as abstract at it is stable&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Although possible it is not practical to count and calculate these numbers as we are writing our code. Fortunately tools such as nDepend exist to do this job for us.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
nDepend can be &lt;a href=&quot;http://www.ndepend.com/NDependDownload.aspx&quot;&gt;downloaded&lt;/a&gt; free of charge for use in Open Source projects and trial version is available for commercial use.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
To check where your code is with respect to the Stable-Abstraction Principle and a lot of other metrics, download nDepend and start it. Then go File-&amp;gt;New Project&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiK-6KX60PVVzk-6vNMlvYbp_IGtg_APF_HPaH-coTk9PbFMcAqAfLuIMBIHg_CJwLO0eZKllCrqHYxLASqEk7NHgie76pHj2V5hRlpCR3q_rQZT3UodWlTwwd9Sa0fQWH-ffxrwB9qLC0/s1600/ndepend+new+project.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;121&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiK-6KX60PVVzk-6vNMlvYbp_IGtg_APF_HPaH-coTk9PbFMcAqAfLuIMBIHg_CJwLO0eZKllCrqHYxLASqEk7NHgie76pHj2V5hRlpCR3q_rQZT3UodWlTwwd9Sa0fQWH-ffxrwB9qLC0/s320/ndepend+new+project.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Then add the assemblies you want to analyze, the easiest option is to simply select a Visual Studio solution and nDepend will locate the assemblies for you.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhycDnnbIp-NW7bECnQl-zEg87hyphenhyphen0GqWTOzm8dEJILVWwnfYs7mKytCFPCdG2f1LXy_uAM38qWlf3fH1QD4MjQoDC5eJ0fPElnqLIKAXD9YP2lzVEfj6AVIAVetK74WzpOQspEGjjiSO1Q/s1600/ndepend+open+solution.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;109&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhycDnnbIp-NW7bECnQl-zEg87hyphenhyphen0GqWTOzm8dEJILVWwnfYs7mKytCFPCdG2f1LXy_uAM38qWlf3fH1QD4MjQoDC5eJ0fPElnqLIKAXD9YP2lzVEfj6AVIAVetK74WzpOQspEGjjiSO1Q/s320/ndepend+open+solution.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
After you have selected the assemblies, simply hit F5 and nDepend will generate a detailed report for you which among a lot of details contains a diagram which is called &quot;Assemblies Abstractness vs. Instability&quot; which is exactly the same as Martins main sequence diagrams.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAx7-D37R9yJcivQczPt2Lu9LXIS49XVnD_5ffhIVHbOk9UK_JX2AB9bJNLb0m9yRttSc-o0vsE8O0jtKv9Uf2i4o29Jx61aikOia8D21PVa-NXGMKbY83dbT4s0SxaZIxkeyv2LQ1k0g/s1600/abstractness+vs+instability.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;572&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAx7-D37R9yJcivQczPt2Lu9LXIS49XVnD_5ffhIVHbOk9UK_JX2AB9bJNLb0m9yRttSc-o0vsE8O0jtKv9Uf2i4o29Jx61aikOia8D21PVa-NXGMKbY83dbT4s0SxaZIxkeyv2LQ1k0g/s640/abstractness+vs+instability.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h3&gt;

















The Stable Dependencies Principle (SDP)&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In a later article on&amp;nbsp;&lt;a href=&quot;http://www.objectmentor.com/resources/articles/stability.pdf&quot;&gt;Stability&lt;/a&gt;&amp;nbsp;Martin introduces the Stable Dependencies Principle:&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
THE DEPENDENCIES BETWEEN PACKAGES IN A DESIGN SHOULD&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
BE IN THE DIRECTION OF THE STABILITY OF THE PACKAGES. A&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
PACKAGE SHOULD ONLY DEPEND UPON PACKAGES THAT ARE&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
MORE STABLE THAT IT IS.&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In other words the components we depend on should be harder to change than the component we are working on. We want to reduce the&amp;nbsp;likelihood of needing to change our component because one of our dependencies change.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
So we should check our code for this as well, this is supposed to be something that nDepend will tell us directly out-of-the-box, at least this is what &lt;a href=&quot;http://www.ndepend.com/GettingStarted.aspx&quot;&gt;the nDepend documentation&lt;/a&gt;&amp;nbsp;says, but I haven&#39;t been able to find it.&lt;br /&gt;
Anyway there are ways that we can tailor the information that nDepend does provide exactly as we want.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
nDepend provides us with a query language called CQL that we can use to get information about our code. It is in a syntax that&amp;nbsp;bears some resemblance to SQL, but just don&#39;t be fooled into believing it is SQL, it can do a lot, but not nearly as much as you can do with data and SQL.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
If the standard report doesn&#39;t tell you what you are looking for, there are a lot of other pre-made queries you can run and you can write your own.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
To get a list of the Instability values (I) of all your assemblies you can run the following CQL:&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: green; font-family: Consolas; font-size: 9pt;&quot;&gt;// &amp;lt;Name&amp;gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: green; font-family: Consolas; font-size: 9pt;&quot;&gt;Olavs Instability of
assemblies&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: green; font-family: Consolas; font-size: 9pt;&quot;&gt;&amp;lt;/Name&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9pt;&quot;&gt;WARN&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Consolas; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9pt;&quot;&gt;IF&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Consolas; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #000064; font-family: Consolas; font-size: 9pt;&quot;&gt;Count&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Consolas; font-size: 9pt;&quot;&gt; &amp;gt; &lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; font-family: Consolas; font-size: 9pt;&quot;&gt;0&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Consolas; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9pt;&quot;&gt;IN&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Consolas; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Consolas; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9pt;&quot;&gt;ASSEMBLIES&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Consolas; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9pt;&quot;&gt;ORDER&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Consolas; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9pt;&quot;&gt;BY&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Consolas; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #000064; font-family: Consolas; font-size: 9pt;&quot;&gt;Instability&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Consolas; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9pt;&quot;&gt;ASC&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
What we can make use of is that nDepend will output a number of XML files when it is run and we can run it from the command.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
So when we have made a nDepend project, added the solution (assemblies) and added the above CQL query, then nDepend will produce XML files that we can use to do a Stable Dependencies Principle check ourselves.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
To run from the command line:&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Start a command prompt in the folder where nDepend is installed and execute: nDepend.Console.exe &amp;lt;path to the ndepend project file&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgm5KV6YLqDqwN-cqGvrkLCyf1TyUn7xAm25Ho6QRUFvOJzpuiZt5KvgA9bFItHI56uUiDO06N0Gaebt32ozjHfJtrFtkSJPuPOO9GWSadjB2y8qk5MYrxXWo4diZdwGfakfrdKjB0e94k/s1600/ndepend+command+prompt.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;126&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgm5KV6YLqDqwN-cqGvrkLCyf1TyUn7xAm25Ho6QRUFvOJzpuiZt5KvgA9bFItHI56uUiDO06N0Gaebt32ozjHfJtrFtkSJPuPOO9GWSadjB2y8qk5MYrxXWo4diZdwGfakfrdKjB0e94k/s640/ndepend+command+prompt.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
The XML output files will be in a folder called NDependOut in the same folder as the nDepend project file.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
The two we are interested in are AssembliesDependencies.xml and CQLResult.xml:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4BbTBI_KkQGd1K4WkmacfDo51OZFNKjNgryYpG35nAURCXpDmd1gDBPaE4eI3vtmhx64M0koCjgJhZfdpC4m1ey7zAY1v-mpzHVFTcQSCS8FYKcKDWUvz6dz8f6r0CQDfWZ7bPCLVCr4/s1600/ndepend+xml+files.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;498&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4BbTBI_KkQGd1K4WkmacfDo51OZFNKjNgryYpG35nAURCXpDmd1gDBPaE4eI3vtmhx64M0koCjgJhZfdpC4m1ey7zAY1v-mpzHVFTcQSCS8FYKcKDWUvz6dz8f6r0CQDfWZ7bPCLVCr4/s640/ndepend+xml+files.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
The AssembliesDependencies.xml lists for each assembly the assemblies the assembly depends on and all the assemblies that depends on the assembly.&lt;br /&gt;
This is an example of a part of an AssembliesDependencies.xml file:&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;lt;Dependencies_For Assembly=&quot;MyProject.UI v1.0.0.0&quot;&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;lt;DependsOn&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DependsOn_Name&amp;gt;mscorlib v4.0.0.0&amp;lt;/DependsOn_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DependsOn_Name&amp;gt;System.Web v4.0.0.0&amp;lt;/DependsOn_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DependsOn_Name&amp;gt;System v4.0.0.0&amp;lt;/DependsOn_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DependsOn_Name&amp;gt;MyProject.Domain v1.0.0.0&amp;lt;/DependsOn_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DependsOn_Name&amp;gt;MyProject.Service.DataContracts v1.0.0.0&amp;lt;/DependsOn_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DependsOn_Name&amp;gt;System.Web.Abstractions v4.0.0.0&amp;lt;/DependsOn_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DependsOn_Name&amp;gt;System.ServiceModel v4.0.0.0&amp;lt;/DependsOn_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DependsOn_Name&amp;gt;System.Configuration v4.0.0.0&amp;lt;/DependsOn_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DependsOn_Name&amp;gt;MyProject.Mapping v1.0.0.0&amp;lt;/DependsOn_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DependsOn_Name&amp;gt;MyProject.Services.DataContracts v1.0.0.0&amp;lt;/DependsOn_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DependsOn_Name&amp;gt;MyProject.Preview.Model v1.0.0.0&amp;lt;/DependsOn_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DependsOn_Name&amp;gt;System.Core v4.0.0.0&amp;lt;/DependsOn_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DependsOn_Name&amp;gt;MyProject.Services.ServiceContracts v1.0.0.0&amp;lt;/DependsOn_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DependsOn_Name&amp;gt;System.Web.Extensions v4.0.0.0&amp;lt;/DependsOn_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/DependsOn&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;lt;ReferencedBy&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;ReferencedBy_Name&amp;gt;MyProject.Web v1.0.0.0&amp;lt;/ReferencedBy_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;ReferencedBy_Name&amp;gt;MyProject.CalculationService v1.0.0.0&amp;lt;/ReferencedBy_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/ReferencedBy&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;lt;/Dependencies_For&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;lt;Dependencies_For Assembly=&quot;MyProject.Web v1.0.0.0&quot;&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;lt;DependsOn&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DependsOn_Name&amp;gt;MyProject.UI v1.0.0.0&amp;lt;/DependsOn_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DependsOn_Name&amp;gt;MyProject.Domain v1.0.0.0&amp;lt;/DependsOn_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DependsOn_Name&amp;gt;MyProject.Mapping v1.0.0.0&amp;lt;/DependsOn_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DependsOn_Name&amp;gt;System.Web v4.0.0.0&amp;lt;/DependsOn_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DependsOn_Name&amp;gt;mscorlib v4.0.0.0&amp;lt;/DependsOn_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DependsOn_Name&amp;gt;System v4.0.0.0&amp;lt;/DependsOn_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DependsOn_Name&amp;gt;MyProject.Service.DataContracts v1.0.0.0&amp;lt;/DependsOn_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DependsOn_Name&amp;gt;System.Web.Extensions v4.0.0.0&amp;lt;/DependsOn_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DependsOn_Name&amp;gt;System.Core v4.0.0.0&amp;lt;/DependsOn_Name&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;DependsOn_Name&amp;gt;System.ServiceModel v4.0.0.0&amp;lt;/DependsOn_Name&amp;gt;&amp;nbsp;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
The other file that we are interested in is the CQLResult.xml file. If you remember that we added a query for the Instabilities of assemblies and that we named it: &quot;Olavs Instabilities.....&quot;. The result of this query will now appear in the CQLResult.xml file. There will be a lot of other results as well, but we can search for our query &amp;nbsp;by the name we gave it in the comment of the query.&lt;br /&gt;
This is an example of the &quot;Olavs Instabilities of assemblies&quot; section:&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;Query Status=&quot;Warn&quot; Name=&quot;Olavs Instability of assemblies&quot; NbNodeMatched=&quot;33&quot; NbNodeTested=&quot;33&quot; SelectionViewFileName=&quot;SelectionView_-266889740.png&quot; KindOfNode=&quot; assemblies&quot;&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;QueryHtml&amp;gt;&amp;amp;lt;font color=&#39;#008000&#39;&amp;amp;gt;//&amp;amp;amp;#0160;&amp;amp;amp;lt;Name&amp;amp;amp;gt;&amp;amp;lt;/font&amp;amp;gt;&amp;amp;lt;b style=&quot;color:#008000;background-color:#E6FFE6&quot;&amp;amp;gt;Olavs&amp;amp;amp;#0160;Instability&amp;amp;amp;#0160;of&amp;amp;amp;#0160;assemblies&amp;amp;lt;/b&amp;amp;gt;&amp;amp;lt;font color=&#39;#008000&#39;&amp;amp;gt;&amp;amp;amp;lt;/Name&amp;amp;amp;gt;&amp;amp;lt;br/&amp;amp;gt;&amp;amp;lt;/font&amp;amp;gt;&amp;amp;lt;font color=&#39;#0000FF&#39;&amp;amp;gt;WARN&amp;amp;lt;/font&amp;amp;gt;&amp;amp;amp;#0160;&amp;amp;lt;font color=&#39;#0000FF&#39;&amp;amp;gt;IF&amp;amp;lt;/font&amp;amp;gt;&amp;amp;amp;#0160;&amp;amp;lt;font color=&#39;#000064&#39;&amp;amp;gt;Count&amp;amp;lt;/font&amp;amp;gt;&amp;amp;amp;#0160;&amp;amp;lt;font color=&#39;#000000&#39;&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;lt;/font&amp;amp;gt;&amp;amp;amp;#0160;&amp;amp;lt;b style=&quot;color:#000000;background-color:#FFFF99&quot;&amp;amp;gt;0&amp;amp;lt;/b&amp;amp;gt;&amp;amp;amp;#0160;&amp;amp;lt;font color=&#39;#0000FF&#39;&amp;amp;gt;IN&amp;amp;lt;/font&amp;amp;gt;&amp;amp;amp;#0160;&amp;amp;lt;font color=&#39;#0000FF&#39;&amp;amp;gt;SELECT&amp;amp;lt;/font&amp;amp;gt;&amp;amp;amp;#0160;&amp;amp;lt;font color=&#39;#0000FF&#39;&amp;amp;gt;ASSEMBLIES&amp;amp;lt;/font&amp;amp;gt;&amp;amp;amp;#0160;&amp;amp;lt;font color=&#39;#0000FF&#39;&amp;amp;gt;ORDER&amp;amp;lt;/font&amp;amp;gt;&amp;amp;amp;#0160;&amp;amp;lt;font color=&#39;#0000FF&#39;&amp;amp;gt;BY&amp;amp;lt;/font&amp;amp;gt;&amp;amp;amp;#0160;&amp;amp;lt;font color=&#39;#000064&#39;&amp;amp;gt;Instability&amp;amp;lt;/font&amp;amp;gt;&amp;amp;amp;#0160;&amp;amp;lt;font color=&#39;#0000FF&#39;&amp;amp;gt;ASC&amp;amp;lt;/font&amp;amp;gt;&amp;lt;/QueryHtml&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Columns&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Column&amp;gt;assemblies&amp;lt;/Column&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Column&amp;gt;Instability&amp;lt;/Column&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/Columns&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Rows&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Row Name=&quot;System.ServiceModel&quot; FullName=&quot;System.ServiceModel&quot;&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Val&amp;gt;N/A&amp;lt;/Val&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/Row&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Row Name=&quot;System.Web.Abstractions&quot; FullName=&quot;System.Web.Abstractions&quot;&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Val&amp;gt;N/A&amp;lt;/Val&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/Row&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Row Name=&quot;MyProject.Domain&quot; FullName=&quot;MyProjectDK.DealerPortal.Domain&quot;&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Val&amp;gt;0.21081&amp;lt;/Val&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/Row&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Row Name=&quot;MyProject.CalculationService.Data&quot; FullName=&quot;MyProjectDK.DealerPortal.CalculationService.Data&quot;&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Val&amp;gt;0.66667&amp;lt;/Val&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/Row&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Row Name=&quot;MyProject.Mapping&quot; FullName=&quot;MyProjectDK.DealerPortal.Mapping&quot;&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Val&amp;gt;0.71875&amp;lt;/Val&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/Row&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Row Name=&quot;MyProject.Service.DataContracts&quot; FullName=&quot;MyProjectDK.DealerPortal.Service.DataContracts&quot;&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Val&amp;gt;0.78723&amp;lt;/Val&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/Row&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Row Name=&quot;MyProject.UI&quot; FullName=&quot;MyProjectDK.DealerPortal.UI&quot;&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Val&amp;gt;0.7907&amp;lt;/Val&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/Row&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Row Name=&quot;MyProject.Repositories&quot; FullName=&quot;MyProjectDK.DealerPortal.Repositories&quot;&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Val&amp;gt;0.96296&amp;lt;/Val&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/Row&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Row Name=&quot;MyProject.Preview.Model&quot; FullName=&quot;MyProjectDK.DealerPortal.Preview.Model&quot;&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Val&amp;gt;0.96907&amp;lt;/Val&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/Row&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
So now we have two lists (xml files), the first one has all the dependency information for the assemblies and the second has the calculated Instability values for each of the assemblies.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Now we only have to combine these two lists to check if we have any assemblies that breaks the Stable dependencies principle.&lt;/div&gt;
&lt;div&gt;
I have written a small console application that will do just this. The source code for it is available at&amp;nbsp;&lt;span style=&quot;color: #1f497d; font-family: Calibri, sans-serif; font-size: 11pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif; font-size: 12pt;&quot;&gt;&lt;a href=&quot;https://spdchecker.codeplex.com/&quot;&gt;https://spdchecker.codeplex.com/&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
The application is exuted from a command prompt as this:&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SPDChecker &amp;lt;path to CQLResult.xml&amp;gt; &amp;lt;path to AssembliesDependencies.xml&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
And the result looks something like this:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwViUWgbsD8RETSXI24c-5pdIXsOrR5TrIu1U-6Vs-djcRa1scY0w0U1Y1So__B9aiWdNbaoPwMpi8336CI68pX_lzrkYffEqflCn3xwd5iesFIzJl_gP_IdGt9fmYcSNKzHvLC7LRVK0/s1600/SPDChecker.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;236&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwViUWgbsD8RETSXI24c-5pdIXsOrR5TrIu1U-6Vs-djcRa1scY0w0U1Y1So__B9aiWdNbaoPwMpi8336CI68pX_lzrkYffEqflCn3xwd5iesFIzJl_gP_IdGt9fmYcSNKzHvLC7LRVK0/s640/SPDChecker.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Should you try it and should it find something in your assemblies, please be advised that even if my warning text may indicate that this is a major crisis, remember what Robert C. Martin himself wrote about his metrics:&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;i&gt;However, a metric is not a god; it is merely a measurement against an arbitrary standard. &amp;nbsp;It is certainly possible that the standard chosen in this paper is appropriate&amp;nbsp;&lt;/i&gt;&lt;i&gt;only for certain applications and is not appropriate for others. &amp;nbsp;It may also be that there are&amp;nbsp;&lt;/i&gt;&lt;i&gt;far better metrics that can be used to measure the quality of a design.&lt;/i&gt;&amp;nbsp;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;i&gt;Thus, I would deeply regret it if anybody suddenly decided that all their designs must&amp;nbsp;&lt;/i&gt;&lt;i&gt;unconditionally be conformant to “The Martin Metrics”. &amp;nbsp;I hope that designers will experiment with them, ﬁnd out what is good and what is bad about them, and then communicate&amp;nbsp;&lt;/i&gt;&lt;i&gt;their ﬁndings to the rest of us.&lt;/i&gt;&lt;/blockquote&gt;
I agree 100% with Mr. Martin on this.&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;a href=&quot;http://en.wiktionary.org/wiki/ad-&quot; target=&quot;_blank&quot;&gt;ad-&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://en.wiktionary.org/wiki/ex-&quot;&gt;ex-&lt;/a&gt;
&lt;br /&gt;
&lt;a href=&quot;http://en.wiktionary.org/wiki/efferent&quot;&gt;efferent&lt;/a&gt;
&lt;br /&gt;
&lt;a href=&quot;http://en.wiktionary.org/wiki/afferent&quot;&gt;afferent&lt;/a&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.objectmentor.com/resources/articles/stability.pdf&quot;&gt;http://www.objectmentor.com/resources/articles/stability.pdf&lt;/a&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.objectmentor.com/resources/articles/oodmetrc.pdf&quot;&gt;http://www.objectmentor.com/resources/articles/oodmetrc.pdf&lt;/a&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.ndepend.com/NDependDownload.aspx&quot;&gt;http://www.ndepend.com/NDependDownload.aspx&lt;/a&gt;
&lt;br /&gt;
There is also a very good explanation of these two principles&amp;nbsp;(SDP/SAP)&amp;nbsp;in Robert C. Martins book: &quot;Agile Principles, Patterns and Practices in C#&quot;, Prentice Hall, pages 426-435&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://oncoding.blogspot.com/feeds/6321383067867183962/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://oncoding.blogspot.com/2012/03/stable-dependencies-principle-sdp-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7203370983485193018/posts/default/6321383067867183962'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7203370983485193018/posts/default/6321383067867183962'/><link rel='alternate' type='text/html' href='http://oncoding.blogspot.com/2012/03/stable-dependencies-principle-sdp-and.html' title='The Stable Dependencies Principle (SDP) and nDepend'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17693565125055146738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXX_nBSMFGu2AKyqmJOCrqnmwRmoT2bk2jw5QvMr5azjT8pLWhmk5Rwz2FvwBJJfWs2mAx0PETIp9N7FOPLU-9eHm6QdTQaYY6XJ56GE8UfN6Wo-euUQvMotGiYPhs0MmgvGc-Wfvn9gs/s72-c/ferry+coming.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7203370983485193018.post-9110806841965654693</id><published>2012-03-27T19:03:00.001+02:00</published><updated>2012-03-29T14:42:50.175+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Caliburn.Micro"/><category scheme="http://www.blogger.com/atom/ns#" term="mvvm"/><category scheme="http://www.blogger.com/atom/ns#" term="windows phone 7"/><category scheme="http://www.blogger.com/atom/ns#" term="wpf"/><title type='text'>Binding the View and ViewModel in a Windows Phone 7 app</title><content type='html'>I have wanted to start developing apps for Windows Phone 7 for a long time, but never gotten around to actually do it. So when a former colleague of mine started a blog series about &lt;a href=&quot;http://www.novanet.no/blog/yngve-bakken-nilsen/dates/2012/3/wp7-boilerplate/&quot; target=&quot;_blank&quot;&gt;Creating a reusable base for WP7 apps&lt;/a&gt;&amp;nbsp;on his company blog I thought this was a great opportunity to get started. The author, Yngve Bakken Nilsen is one of the best web-developers I have ever worked with, so my expectations to this series are high.&lt;br /&gt;
&lt;br /&gt;
Navigation between pages and binding of the view and viewmodel are central topics of the first two posts.&lt;br /&gt;
Yngve proposes to use attributes containing paths to the View on the ViewModel objects to bind the View and ViewModel. He implements methods using reflection and these attributes to look up the View given a ViewModel. Even though Yngve says in his post that &quot;some good&#39;ol reflection (it&#39;s not as scary as you might think)&quot;, I can&#39;t help it, I always get a bit uneasy when I see reflection and attributes containing magic strings that are used to find types. If I can avoid it I prefer to do so, and this is what this post is about.&lt;br /&gt;
&lt;i&gt;Are there other ways to bind the View and the ViewModel while still keeping things nice and simple?&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;






Initial architecture&lt;/h4&gt;
Yngve builds and initial architecture as shown in the diagram below:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwlTgmbyrzwUhCR6fd_IcSBwnWIAB7yTdjp5jvBjF6GTJeizU6rMmYml7JPX2jH2bVzl9I5ZdEi7h5eFWBXcZRsR0IGBgKkj85tjL6nASLWhxaGp0xl1QxQuKNAfapmPoGIla3km1Vd8U/s1600/Windows+Phone+7+Class+Diagram.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;398&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwlTgmbyrzwUhCR6fd_IcSBwnWIAB7yTdjp5jvBjF6GTJeizU6rMmYml7JPX2jH2bVzl9I5ZdEi7h5eFWBXcZRsR0IGBgKkj85tjL6nASLWhxaGp0xl1QxQuKNAfapmPoGIla3km1Vd8U/s640/Windows+Phone+7+Class+Diagram.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
The App object contains a MasterViewModel object that acts as a master object keeping track of the CurrentViewModel and the CurrentPage object.&lt;br /&gt;
&lt;br /&gt;
The architecture is based on an assumption that each ViewModel will have one-to-one relationship with the &amp;nbsp;View.&lt;br /&gt;
Having only one ViewModel per View is all fine and dandy to me, but I can see that there may be scenarios where we would like to have more than one View share the same ViewModel.&lt;br /&gt;
&lt;a href=&quot;http://csharperimage.jeremylikness.com/2010/04/model-view-viewmodel-mvvm-explained.html&quot; target=&quot;_blank&quot;&gt;Jeremy Likness in his post Model-View-ViewModel (MVVM) Explained&lt;/a&gt;&amp;nbsp;mentions that multiple views on a single ViewModel could be&amp;nbsp;beneficial&amp;nbsp;if we are to implement a wizard. A single view-model shared between the wizard pages could be nice, but for the sake of simplicity I can live with 1-to-1.&lt;br /&gt;
&lt;br /&gt;
Jeremy Likness also discuss the two ways to drive the creation and discovery process. One can opt to do as Yngve has done, go from the ViewModel to the View, this is referred to as ViewModel first.&lt;br /&gt;
&lt;br /&gt;
Going the other direction is called, you may have guessed it already, View first.&lt;br /&gt;
&lt;h4&gt;






The simple alternative&lt;/h4&gt;
&lt;div&gt;
The MasterViewModel shown above has a method Goto&amp;lt;T&amp;gt; that the View will call when it wants to navigate to a different page.&lt;/div&gt;
&lt;div&gt;
E.g. in the MainPage we will have a click handler as this:&lt;/div&gt;
&lt;div&gt;
&lt;div class=&quot;line alt1&quot; style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: white; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: #42464b; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace; font-size: 13px; height: auto !important; left: auto !important; line-height: 14px; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;table style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;tbody style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;content&quot; style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-color: initial !important; border-left-style: none !important; border-left-width: initial !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;&quot;&gt;&lt;code class=&quot;keyword&quot; style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;private&lt;/code&gt;&amp;nbsp;&lt;code class=&quot;keyword&quot; style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;void&lt;/code&gt;&amp;nbsp;&lt;code class=&quot;plain&quot; style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;GoToSubpage_Click(&lt;/code&gt;&lt;code class=&quot;keyword&quot; style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;object&lt;/code&gt;&amp;nbsp;&lt;code class=&quot;plain&quot; style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;sender, RoutedEventArgs e)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot; style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: white; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: #42464b; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace; font-size: 13px; height: auto !important; left: auto !important; line-height: 14px; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;table style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;tbody style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;content&quot; style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-color: initial !important; border-left-style: none !important; border-left-width: initial !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;&quot;&gt;&lt;code class=&quot;plain&quot; style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;{&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot; style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: white; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: #42464b; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace; font-size: 13px; height: auto !important; left: auto !important; line-height: 14px; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;table style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;tbody style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;content&quot; style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-color: initial !important; border-left-style: none !important; border-left-width: initial !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;&quot;&gt;&lt;code class=&quot;spaces&quot; style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: #c0c1c3; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot; style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;App.ViewModel.Goto&amp;lt;SubPageViewModel&amp;gt;();&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot; style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: white; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: #42464b; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace; font-size: 13px; height: auto !important; left: auto !important; line-height: 14px; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;table style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;tbody style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;content&quot; style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-color: initial !important; border-left-style: none !important; border-left-width: initial !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: top !important; width: auto !important;&quot;&gt;&lt;code class=&quot;plain&quot; style=&quot;background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-image: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
Which will then navigate from the MainPage to the SubPage.&lt;br /&gt;
The goto method will find the Uri to navigate to by looking at the attribute that should be used to decorate the ViewModel class. When it has located the Uri it will use the NavigationService on the View to navigate to the Uri.&lt;br /&gt;
Then after the navigation has been done and the View has changed, we handle the navigated event where we see the new Uri and from the Uri we locate the matching ViewModel and set this in the view by settings its DataContext to the new ViewModel.&lt;br /&gt;
&lt;br /&gt;
A simple alternative to this is to bind the ViewModel directly to the view. If the View knows what ViewModel it should bind to it can set the DataContext in its constructor.&lt;br /&gt;
&lt;br /&gt;
Simply modifying MainPage.xaml.cs like this:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; font-family: Consolas;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;partial&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;MainPage&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;PhoneApplicationPage&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: green;&quot;&gt;//&amp;nbsp;Constructor&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;MainPage()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;InitializeComponent();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DataContext&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&amp;nbsp;ViewModels.Pages.&lt;span style=&quot;color: #2b91af;&quot;&gt;MainPageViewModel&lt;/span&gt;();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&amp;nbsp;GoToSubpage_Click(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt;&amp;nbsp;sender,&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;RoutedEventArgs&lt;/span&gt;&amp;nbsp;e)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NavigationService.Navigate(&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;Uri&lt;/span&gt;(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;/SubPage.xaml&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;UriKind&lt;/span&gt;.Relative));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
And SubPage as this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; font-family: Consolas;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;partial&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;SubPage&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;PhoneApplicationPage&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;SubPage()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;InitializeComponent();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DataContext&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&amp;nbsp;ViewModels.Pages.&lt;span style=&quot;color: #2b91af;&quot;&gt;SubPageViewModel&lt;/span&gt;();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&amp;nbsp;GoToMainPage_Click(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt;&amp;nbsp;sender,&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;RoutedEventArgs&lt;/span&gt;&amp;nbsp;e)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NavigationService.Navigate(&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;Uri&lt;/span&gt;(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;/MainPage.xaml&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;UriKind&lt;/span&gt;.Relative));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Makes the need for both reflection and attributes go away. When we navigate to SubPage.xaml the View (SubPage) is automatically instantiated and the constructor of the SubPage class is called which will set the DataContext. The equivalent happens when we navigate from the SubPage to the MainPage.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKqrc6wU4dsL705BxcKXkXWAK_2bdW0cooOAYEePOWAV0ppOEtF1q0z_lxg6-ET8ZyvD1GpE3XbAIEtwefF229yDBOJ5V_v8Onbi06JTXtV5AN3VysVC0BuCM5IfoHYrV36KJuPuuJuXM/s1600/Windows+Phone+7+Class+Diagram+2.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKqrc6wU4dsL705BxcKXkXWAK_2bdW0cooOAYEePOWAV0ppOEtF1q0z_lxg6-ET8ZyvD1GpE3XbAIEtwefF229yDBOJ5V_v8Onbi06JTXtV5AN3VysVC0BuCM5IfoHYrV36KJuPuuJuXM/s400/Windows+Phone+7+Class+Diagram+2.PNG&quot; width=&quot;275&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
As can be seen from the diagram above we have replaced the more subtle dependency that we had from the ViewModel to the View with a more direct and obvious dependency from the View to the ViewModel.&lt;br /&gt;
This is more similar to the dependencies in the&amp;nbsp;&lt;a href=&quot;http://martinfowler.com/eaaDev/PresentationModel.html&quot; target=&quot;_blank&quot;&gt;Presentation Model&lt;/a&gt;&amp;nbsp;pattern by Fowler. &lt;a href=&quot;http://en.wikipedia.org/wiki/Model_View_ViewModel&quot; target=&quot;_blank&quot;&gt;MVVM is a specialization of the Presentation Model design pattern&lt;/a&gt;.&lt;br /&gt;
Although I am more happy to have a dependency in this direction, and to have done away with the reflection and the attributes, I am not to happy about the View constructing the ViewModel.&lt;br /&gt;
Nor am I too happy about the ViewModel being created every time we navigate to the page, it means that all ViewModel state is lost every time we navigate away from the page and back.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;






DataTemplates&lt;/h4&gt;
&lt;div&gt;
While googling the internet for alternative solutions I saw people mentioning that they would do things similar to this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;phone:PhoneApplicationPage.Resources&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;pages:MainPageViewModel&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;x:Key&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;ViewModel&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;phone:PhoneApplicationPage.Resources&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;
 
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;!--&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;LayoutRoot&amp;nbsp;is&amp;nbsp;the&amp;nbsp;root&amp;nbsp;grid&amp;nbsp;where&amp;nbsp;all&amp;nbsp;page&amp;nbsp;content&amp;nbsp;is&amp;nbsp;placed&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;--&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;Grid&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;x:Name&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;LayoutRoot&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;Background&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;Transparent&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;views:MainPage&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;DataContext&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;{Binding&amp;nbsp;Source={StaticResource&amp;nbsp;ViewModel}}&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
This is supposed to bind the View and the ViewModel, but I soon figured out that this simply isn&#39;t an option for me as it would not be very different from the &quot;Simple alternative&quot; I just presented. Same drawbacks as already mentioned in previous discussion above that the ViewModel can&#39;t have constructor parameters. It is still the view constructing the viewmodel and still a very hard binding from the View to the ViewModel.&lt;br /&gt;
Finally I couldn&#39;t make it work, adding the above xaml would cause errors, and since I didn&#39;t like the solution anyway I didn&#39;t bother to try figure out what was wrong.&lt;/div&gt;
&lt;h4&gt;






MEF&lt;/h4&gt;
&lt;div&gt;
Managed Extensibility Framework could provide some of the functionality that I am looking for, but sadly it seems to not be supported for Windows Phone 7 because of missing features in the base class libraries available for Windows Phone 7 applications. Damon Payne has made an unofficial&amp;nbsp;&lt;a href=&quot;http://www.damonpayne.com/post/2010/06/25/MEF-for-Windows-Phone-7.aspx&quot; target=&quot;_blank&quot;&gt;MEF-for-Windows-Phone-7&lt;/a&gt;, but I suppose for those of us who aren&#39;t black belt Windows Phone 7 hackers yet, there may be other options that will make the learning curve a bit easier.&lt;/div&gt;
&lt;h4&gt;






UltraLight&lt;/h4&gt;
&lt;div&gt;
Jeremy Likness has published the&amp;nbsp;&lt;a href=&quot;http://ultralightmvvm.codeplex.com/&quot; target=&quot;_blank&quot;&gt;Ultra Light MVVM for Windows Phone 7&lt;/a&gt;&amp;nbsp;micro framework.&lt;br /&gt;
It does View-first binding of the View and the ViewModel in addition to a number of other features.&lt;br /&gt;
It implements the binding using a &quot;homegrown&quot; servicelocator, which will be called from the View constructor.&lt;br /&gt;
&lt;br /&gt;
To use UltraLight we need to download and build the 8 classes and 6 interfaces that are the Ultra Light framework.&lt;br /&gt;
&lt;br /&gt;
The views now should look as this:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Consolas;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;   &lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;partial&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;MainPage&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;PhoneApplicationPage&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: green;&quot;&gt;//&amp;nbsp;Constructor&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;MainPage()&lt;/span&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Consolas;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;InitializeComponent();&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Consolas;&quot;&gt;&lt;span style=&quot;background-color: white; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; font-size: x-small;&quot;&gt;BindToViewModel&amp;lt;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #2b91af; font-size: x-small;&quot;&gt;IMainPageViewModel&lt;/span&gt;&lt;span style=&quot;background-color: white; font-size: x-small;&quot;&gt;&amp;gt;(LayoutRoot);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Consolas;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&lt;/span&gt;&lt;/pre&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&amp;nbsp;GoToSubpage_Click(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt;&amp;nbsp;sender,&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;RoutedEventArgs&lt;/span&gt;&amp;nbsp;e)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NavigationService.Navigate(&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;Uri&lt;/span&gt;(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;/SubPage.xaml&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;UriKind&lt;/span&gt;.Relative));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Consolas;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;partial&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;SubPage&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;PhoneApplicationPage&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;SubPage()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;InitializeComponent();&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Consolas;&quot;&gt;&lt;span style=&quot;background-color: white; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; font-size: x-small;&quot;&gt;BindToViewModel&amp;lt;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #2b91af; font-size: x-small;&quot;&gt;ISubPageViewModel&lt;/span&gt;&lt;span style=&quot;background-color: white; font-size: x-small;&quot;&gt;&amp;gt;(LayoutRoot);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Consolas;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&amp;nbsp;GoToMainPage_Click(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt;&amp;nbsp;sender,&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;RoutedEventArgs&lt;/span&gt;&amp;nbsp;e)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NavigationService.Navigate(&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;Uri&lt;/span&gt;(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;/MainPage.xaml&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;UriKind&lt;/span&gt;.Relative));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
The BindToViewModel method is an extension method that&amp;nbsp;among&amp;nbsp;other things will find the ViewModel class implementing the specified ViewModel interface and then attach this to the View by setting the DataContext property of the LayoutRoot object to the located ViewModel object.&lt;br /&gt;
&lt;br /&gt;
For this to work the map between ViewModel interfaces and the ViewModel classes must be registered. This will be done in the application launched event handler of the App object:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; font-family: Consolas;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&amp;nbsp;_RegisterViewModels()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;UltraLightLocator&lt;/span&gt;.Register&amp;lt;&lt;span style=&quot;color: #2b91af;&quot;&gt;IMainPageViewModel&lt;/span&gt;&amp;gt;(&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;MainPageViewModel&lt;/span&gt;());
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;UltraLightLocator&lt;/span&gt;.Register&amp;lt;&lt;span style=&quot;color: #2b91af;&quot;&gt;ISubPageViewModel&lt;/span&gt;&amp;gt;(&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;SubPageViewModel&lt;/span&gt;());
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: green;&quot;&gt;//&amp;nbsp;Code&amp;nbsp;to&amp;nbsp;execute&amp;nbsp;when&amp;nbsp;the&amp;nbsp;application&amp;nbsp;is&amp;nbsp;launching&amp;nbsp;(eg,&amp;nbsp;from&amp;nbsp;Start)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: green;&quot;&gt;//&amp;nbsp;This&amp;nbsp;code&amp;nbsp;will&amp;nbsp;not&amp;nbsp;execute&amp;nbsp;when&amp;nbsp;the&amp;nbsp;application&amp;nbsp;is&amp;nbsp;reactivated&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&amp;nbsp;Application_Launching(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt;&amp;nbsp;sender,&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;LaunchingEventArgs&lt;/span&gt;&amp;nbsp;e)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_RegisterViewModels();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; font-family: Consolas;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; font-family: Consolas;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
The final requirement is that all the ViewModel classes must implement an interface and they have to inherit from the framework class called&amp;nbsp;&lt;i&gt;BaseViewModel&lt;/i&gt;. The&amp;nbsp;&lt;i&gt;BaseViewModel&lt;/i&gt;&amp;nbsp;class has an abstract property called ApplicationBindings which we also are required to implement.&lt;br /&gt;
Haven&#39;t figured out exactly why this is, but I may be using the framework wrong on this point.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; font-family: Consolas;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;For&amp;nbsp;pages,&amp;nbsp;the&amp;nbsp;list&amp;nbsp;of&amp;nbsp;commands&amp;nbsp;to&amp;nbsp;bind&amp;nbsp;to&amp;nbsp;application&amp;nbsp;bar&amp;nbsp;buttons&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;override&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #2b91af;&quot;&gt;IActionCommand&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt;&amp;gt;&amp;gt;&amp;nbsp;ApplicationBindings
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;get&lt;/span&gt;&amp;nbsp;{&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;IActionCommand&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt;&amp;gt;[0];&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
In my opinion the Ultra Light framework looks promising as a starting point for doing Windows Phone 7 development. It&#39;s not too big or complex while still providing what seems to be a number of&amp;nbsp;useful&amp;nbsp;features.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;





Caliburn.Micro&lt;/h4&gt;
&lt;div&gt;
Caliburn.Micro is a small framework that can be used for both WPF, Silverlight and Windows Phone 7 applications. Caliburn.Micro is a bit larger than Ultra Light, about 50 classes, but I believe it has more functionality. It comes with full source, which will by default be a part of your project. It is&amp;nbsp;distributed&amp;nbsp;under the MIT license. &amp;nbsp;It is built by Rob Eisenberg who presented a lot of the principles that Caliburn.Micro is based on in his talk&amp;nbsp;&lt;a href=&quot;http://channel9.msdn.com/Events/MIX/MIX10/EX15&quot; target=&quot;_blank&quot;&gt;Build Your Own MVVM Framework&lt;/a&gt;&amp;nbsp;at MIX10.&lt;br /&gt;
I have watched the MIX10 video, but I haven&#39;t got much time to play with this framework yet, but so far it seems to be pure awesomeness!&lt;br /&gt;
&lt;br /&gt;
To create a caliburn.micro WP7 app we must first download the zip file containing three folders&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkpLoRsNiCxu8_LSRtdwMgzCiAd0Nycq4qj8sP8C9S3hQIJJhl1zsYWUon79jt3JDTk8M6DJ_qcv97ZeRb0fB2DjFw1CxQFx2zZLGuVEZGU8a3QBa9WpmvHrXzqJJPyWrQ77IjoAnuXiw/s1600/caliburn+folders.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkpLoRsNiCxu8_LSRtdwMgzCiAd0Nycq4qj8sP8C9S3hQIJJhl1zsYWUon79jt3JDTk8M6DJ_qcv97ZeRb0fB2DjFw1CxQFx2zZLGuVEZGU8a3QBa9WpmvHrXzqJJPyWrQ77IjoAnuXiw/s1600/caliburn+folders.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
In the templates folder you will find the three project templates zip files, one for each of the supported platforms. There&#39;s also a readme.txt file there describing exactly what you need to do.&lt;br /&gt;
After you have copied the&amp;nbsp;Caliburn_Micro_WP7.zip to the right folder you can fire up Visual Studio and you should now have a new project type available, select this and you will get a project with all the required files and you are good to go.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Look mum, no code behind!&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGWqnvZpMWq6S2IaDnVLbj687_B9jyix904tTl4Q-3_a1cOP_2XU-vIHdDQVJuDD50sFUaSivKK4YEpT5swN7wxaCLSVrj2PknbU6werTNsZXfLiiPrfOIYavhv09O-ykcc3QMzoSocXM/s1600/Caliburn+solution.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGWqnvZpMWq6S2IaDnVLbj687_B9jyix904tTl4Q-3_a1cOP_2XU-vIHdDQVJuDD50sFUaSivKK4YEpT5swN7wxaCLSVrj2PknbU6werTNsZXfLiiPrfOIYavhv09O-ykcc3QMzoSocXM/s1600/Caliburn+solution.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
In the figure above you can see my complete Visual Studio Solution that implements the same application as Yngve did in his blog posts. If you look at the the two views, MainPage.xaml and SubPage.xaml, you will notice that there is no code-behind. There&#39;s nothing special in the xaml file either, same as we have had in the previous examples.&lt;br /&gt;
All the code is in the ViewModel class&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 13px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;MainPageViewModel&lt;/span&gt;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;INavigationService&lt;/span&gt;&amp;nbsp;NavigationService&amp;nbsp;{&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;get&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;set&lt;/span&gt;;&amp;nbsp;}
 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;MainPageViewModel(&lt;span style=&quot;color: #2b91af;&quot;&gt;INavigationService&lt;/span&gt;&amp;nbsp;navigationService)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Title&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Kick&amp;nbsp;Ass&quot;&lt;/span&gt;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NavigationService&amp;nbsp;=&amp;nbsp;navigationService;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt;&amp;nbsp;Title&amp;nbsp;{&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;get&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;set&lt;/span&gt;;&amp;nbsp;}
 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&amp;nbsp;GoToSubpage()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NavigationService.Navigate(&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;Uri&lt;/span&gt;(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;/SubPage.xaml&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;UriKind&lt;/span&gt;.Relative));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/pre&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 13px;&quot;&gt;&lt;/pre&gt;
&lt;br /&gt;
The ViewModel can be wired up with a NavigationService if we want to do navigation as shown above.&lt;br /&gt;
&lt;br /&gt;
There is also a automatically generated file called AppBootstrapper. This is where we need to register our ViewModel classes. So for our little demo app that has two pages which we can navigate between we just need to register our two ViewModel classes and we are done.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQjWOCU3gwkDqc2UzCV8FcUdRG-RQ9OnLSYsJyNOHjopXV3KIarubD383Nd_FFVQ9tCrwGTX4gxq5sDSWgs4F2uTfPnur-7rOYDdtLjeadjbUrSZjm86dqYFGfxWdkWLTrbqsIyX6SZvU/s1600/Caliburn+AppBootstrapper.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;132&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQjWOCU3gwkDqc2UzCV8FcUdRG-RQ9OnLSYsJyNOHjopXV3KIarubD383Nd_FFVQ9tCrwGTX4gxq5sDSWgs4F2uTfPnur-7rOYDdtLjeadjbUrSZjm86dqYFGfxWdkWLTrbqsIyX6SZvU/s640/Caliburn+AppBootstrapper.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
There are no reference in the ViewModel to the View. I haven&#39;t dived enough into the details to explain exactly how the binding of the View and ViewModel works, but it is based on convention, and it simply works.&lt;br /&gt;
It of course has to be based on some sort of reflection, but I don&#39;t have to introduce any clutter like attributes or anything into my classes. Further it is driven by very natural conventions. I name the classes as I think I should do anyways and that&#39;s it. The ViewModel class is named ending with &quot;ViewModel&quot;, which now tells both me and Calliburn that this is the ViewModel for the View that has the same name, except the ViewModel postfix. Furthermore, the Caliburn.Micro comes with a default IoC container, but the framework is configurable. If I somewhere down the line decides that I don&#39;t like the default container, I can plug in a different one.&lt;br /&gt;
&lt;br /&gt;
The programming by convention is really used all over this framework, and to me this looks as having been done with great success.&lt;br /&gt;
If you look again at the MainPageViewModel above you will notice the GoToSubpage() method.&lt;br /&gt;
Then look at this snippet from the MainPage.xaml.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEht3VZ30Ff0HrtyKQuAD8TiiNUZ6uGSi_1nzu7RDapMk8LMgfeZLxUm4ZPocQ43ww6c94QyyWpakjeb9SPRpTTYTFubHEKyvoxZL0kvcxmch3EOVSCCEUJ3tSxnrJcfYaTBeQkk_PilEjM/s1600/Caliburn+Event+handling+.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;85&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEht3VZ30Ff0HrtyKQuAD8TiiNUZ6uGSi_1nzu7RDapMk8LMgfeZLxUm4ZPocQ43ww6c94QyyWpakjeb9SPRpTTYTFubHEKyvoxZL0kvcxmch3EOVSCCEUJ3tSxnrJcfYaTBeQkk_PilEjM/s400/Caliburn+Event+handling+.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
As you will notice, the button has the same name as the method in the ViewModel. That is all we need to do. When the user clicks this button, the GoToSubpage method in the ViewModel will be called and we can navigate to the next page, or whatever we want to do when the user clicks our button. Awesome!&lt;br /&gt;
&lt;br /&gt;
The Caliburn.Micro is ViewModel-first, but it still can have multiple view for a single ViewModel. There&#39;s an eplanation of how they do it at the Caliburn.Micro codeplex site in the section&amp;nbsp;&lt;a href=&quot;http://caliburnmicro.codeplex.com/wikipage?title=Screens%2c%20Conductors%20and%20Composition&amp;amp;referringTitle=Documentation&quot; target=&quot;_blank&quot;&gt;Multiple Views over the Same ViewModel&lt;/a&gt;.&lt;br /&gt;
If you want to read more on Caliburn there&#39;s quite a lot more on the codeplex site for Caliburn.Micro&amp;nbsp;&lt;a href=&quot;http://caliburnmicro.codeplex.com/documentation&quot; target=&quot;_blank&quot;&gt;Caliburn documentation&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
A list of links to stuff I have read when researching this post:&lt;br /&gt;
&lt;a href=&quot;http://www.wintellect.com/CS/blogs/jlikness/archive/tags/ultra+light/default.aspx&quot;&gt;http://www.wintellect.com/CS/blogs/jlikness/archive/tags/ultra+light/default.aspx&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://csharperimage.jeremylikness.com/2011/02/windows-phone-7-tombstoning-with-mvvm.html&quot;&gt;http://csharperimage.jeremylikness.com/2011/02/windows-phone-7-tombstoning-with-mvvm.html&lt;/a&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://ultralightmvvm.codeplex.com/releases/61655/download/211741&quot;&gt;http://ultralightmvvm.codeplex.com/releases/61655/download/211741&lt;/a&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://csharperimage.jeremylikness.com/2010/04/model-view-viewmodel-mvvm-explained.html&quot;&gt;http://csharperimage.jeremylikness.com/2010/04/model-view-viewmodel-mvvm-explained.html&lt;/a&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://blogs.msdn.com/b/johngossman/archive/2005/10/08/478683.aspx&quot;&gt;http://blogs.msdn.com/b/johngossman/archive/2005/10/08/478683.aspx&lt;/a&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://msdn.microsoft.com/en-us/magazine/dd419663.aspx&quot;&gt;http://msdn.microsoft.com/en-us/magazine/dd419663.aspx&lt;/a&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://blogs.msdn.com/b/davihard/archive/2010/05/10/repost-mvvm-providing-the-association-of-view-to-viewmodel.aspx&quot;&gt;http://blogs.msdn.com/b/davihard/archive/2010/05/10/repost-mvvm-providing-the-association-of-view-to-viewmodel.aspx&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
And I haven&#39;t forgotten about the Wix project template, its coming, I just had to check out WP7 first :-)&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oncoding.blogspot.com/feeds/9110806841965654693/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://oncoding.blogspot.com/2012/03/binding-view-and-model-in-windows-phone.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7203370983485193018/posts/default/9110806841965654693'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7203370983485193018/posts/default/9110806841965654693'/><link rel='alternate' type='text/html' href='http://oncoding.blogspot.com/2012/03/binding-view-and-model-in-windows-phone.html' title='Binding the View and ViewModel in a Windows Phone 7 app'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17693565125055146738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwlTgmbyrzwUhCR6fd_IcSBwnWIAB7yTdjp5jvBjF6GTJeizU6rMmYml7JPX2jH2bVzl9I5ZdEi7h5eFWBXcZRsR0IGBgKkj85tjL6nASLWhxaGp0xl1QxQuKNAfapmPoGIla3km1Vd8U/s72-c/Windows+Phone+7+Class+Diagram.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7203370983485193018.post-200431728718573225</id><published>2012-03-21T20:47:00.001+01:00</published><updated>2012-03-27T19:04:34.006+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="visual studio 11"/><category scheme="http://www.blogger.com/atom/ns#" term="web service installer"/><category scheme="http://www.blogger.com/atom/ns#" term="wix"/><title type='text'>Creating a web service installer in Visual Studio 11 using WIX</title><content type='html'>So you have decided that you want to start using Visual Studio 11 and maybe you like me, did not pay that much attention when Microsoft said that &lt;a href=&quot;http://blogs.msdn.com/b/buckh/archive/2011/03/17/visual-studio-setup-projects-vdproj-will-not-ship-with-future-versions-of-vs.aspx&quot; target=&quot;_blank&quot;&gt;visual studio setup projects vdproj will not ship with future versions of vs&lt;/a&gt;.&lt;br /&gt;
So what to do now with your setup projects that you have been used to, and relied on for your setup needs?&lt;br /&gt;
I am not saying that visual studio setup projects were a great technology, but they did the job, to some degree at least. You could very easily make an installer that did the job, particularly if your installation requirements were pretty simple, which I found they almost always were.&lt;br /&gt;
More often than not, the requirements basically was that the installer project should be built by the build server and versioned, stored in a repository and install the application to a web site or a folder depending on the type of project.&lt;br /&gt;
&lt;br /&gt;
Well, what now, if you start Visual Studio 11 and select File-&amp;gt;New Project you will quickly see that the only option left out of the box is InstallShield Limited Edition.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_8TkVNFBXOCTZktxl9qaS7khP7fH3R0eRBrARYeAvUjXHMD1xwJGdbGtJ7fRU4TECgEmmLef3T-YRVp7sGSmvbBzPfMuQra0-r3snxHZwj3kaUvqg1VMvsp8uWYh9VIPTPeMYb782eQU/s1600/New+Project.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;316&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_8TkVNFBXOCTZktxl9qaS7khP7fH3R0eRBrARYeAvUjXHMD1xwJGdbGtJ7fRU4TECgEmmLef3T-YRVp7sGSmvbBzPfMuQra0-r3snxHZwj3kaUvqg1VMvsp8uWYh9VIPTPeMYb782eQU/s640/New+Project.PNG&quot; style=&quot;cursor: move;&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Personally I don&#39;t care too much for InstallShield and I have a feeling that starting using the Limited Edition would very soon prove to be too limited, even for simple stuff.&lt;br /&gt;
Wix is another option. It does not come out-of-the-box, but it is Open Source and can quickly be downloaded and installed.&lt;br /&gt;
I wish I also could say that you can quickly make an installer with it, but I am afraid I can&#39;t. When I set out to create my first Wix installer for a web service project I soon discovered that this was no easy task.&lt;br /&gt;
None of the Wix project templates that comes with the Wix installation will create an installer for a web service without heavy modification.&lt;br /&gt;
Wix is yet another example of a extremely poorly documented Open Source project. There&#39;s a lot of articles out there on the net, but I could not find any that were complete or without bugs, so I found myself spending a lot of time trying to figure out how to make this supposedly simple installer work.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the hope of possibly saving others some of this pain I have made this write up which hopefully will be of some use to others.&lt;br /&gt;
&lt;br /&gt;
To use wix with Visual Studio you currently need to download one of the weekly releases from&amp;nbsp;&lt;a href=&quot;http://wixtoolset.org/releases&quot;&gt;http://wixtoolset.org/releases&lt;/a&gt;, I started with v3.6.2712.0, but newer version will of course also be fine.&lt;br /&gt;
&lt;br /&gt;
Installing it is as easy as clicking Install in their nice Metro style installer app&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJhsc-ulP2DF1lN539elY8n95U5pd-ABWFFOQR4hKPNlwuTaQJViEOzXbtg3B2TaeKiqBR9a7BnoaZvc6tyH8yYb8AbFsxlNun6R7fLotwCLoUrKSuj81EzAZN2i2D_ViRSLbW47qA2Ns/s1600/Wix.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;315&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJhsc-ulP2DF1lN539elY8n95U5pd-ABWFFOQR4hKPNlwuTaQJViEOzXbtg3B2TaeKiqBR9a7BnoaZvc6tyH8yYb8AbFsxlNun6R7fLotwCLoUrKSuj81EzAZN2i2D_ViRSLbW47qA2Ns/s320/Wix.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Then you are ready to start your Wix project. Select File-&amp;gt;New Project and you should now see a new project category called Windows Installer XML with 4 project templates.&lt;br /&gt;
Select &quot;Setup Project&quot;, enter Project Name and path to the folder were you want your project folder to be.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYJq9-o_Hxu_AR1NNMm4p2mQy-JCfnyLQmq22NoeD_fulCKJJfAk0bdErFdIonfst2zlJkmz_o3Bcd50ZYUYnP85u1w3H_aXMeaZ__CfjLSRQR232KVEZpK_fOxjmdHvK_YZReHlbnJBM/s1600/New+Wix+Project.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;328&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYJq9-o_Hxu_AR1NNMm4p2mQy-JCfnyLQmq22NoeD_fulCKJJfAk0bdErFdIonfst2zlJkmz_o3Bcd50ZYUYnP85u1w3H_aXMeaZ__CfjLSRQR232KVEZpK_fOxjmdHvK_YZReHlbnJBM/s640/New+Wix+Project.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
In your new project, locate the References node, and add a reference to the Web service project that you want to create an installer for.&lt;br /&gt;
&lt;br /&gt;
Select the new reference and look at properties for this.&lt;br /&gt;
Change Project Output Groups to None as shown below:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEip_y0PLVOnnVpTUSgL7jjQdh9NbmVZgQz0kyGf42zVEA68HkaTaIjvNAGIB7JwSsU-y_w_zS67ZGkyotULKkA7J7ZJrDBHa-MRoiIbJPVDXuSvvRk9K1huzRmiuffao8dV96EymOAwWW0/s1600/Project+Reference.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;250&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEip_y0PLVOnnVpTUSgL7jjQdh9NbmVZgQz0kyGf42zVEA68HkaTaIjvNAGIB7JwSsU-y_w_zS67ZGkyotULKkA7J7ZJrDBHa-MRoiIbJPVDXuSvvRk9K1huzRmiuffao8dV96EymOAwWW0/s320/Project+Reference.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
Then we need to do a little manual editing of the project file.&lt;/div&gt;
&lt;div&gt;
To do this we need to first unload the project, right click the wix setup project and select &quot;Unload Project&quot;.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMLnw3XyM6Ms1ifCD8QTR-lFK31JOrsXs25Nb6eGG2qJ3V4Cv0arOGAhuq6zFN8Qs-C8Clm64LvH9vkUx7x4m0RepBg4YYvgs9mYSQt7sQxadfvNHbcjJQQB4CqpbP02b8c5t9gLN5634/s1600/Unload+project.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMLnw3XyM6Ms1ifCD8QTR-lFK31JOrsXs25Nb6eGG2qJ3V4Cv0arOGAhuq6zFN8Qs-C8Clm64LvH9vkUx7x4m0RepBg4YYvgs9mYSQt7sQxadfvNHbcjJQQB4CqpbP02b8c5t9gLN5634/s320/Unload+project.png&quot; width=&quot;253&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
Locate the Build configurations defined for your project, this would by default be Debug|x86 and Release/x86. Make sure that a constant named WebServiceProjectDir is added to all configurations. WebServiceProjectDir should define the path to the directory where your web service project is located.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
When you are done it should look like this:&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSsy9xTbdwvjrYVQK4SYt1VZILY_pLZyqYZY5PKbUPRnjoiZ7tMogPSTrEHPUWJbYJHM7s87cfs3Gr_t8zjH7VXvZQ7v1PN0v32rZYj92T3vuXjicq6M2c9PyARvzHhzjjf8DcyXxVi40/s1600/Define+Constants.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;260&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSsy9xTbdwvjrYVQK4SYt1VZILY_pLZyqYZY5PKbUPRnjoiZ7tMogPSTrEHPUWJbYJHM7s87cfs3Gr_t8zjH7VXvZQ7v1PN0v32rZYj92T3vuXjicq6M2c9PyARvzHhzjjf8DcyXxVi40/s640/Define+Constants.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
Then locate the ProjectReference you just added before starting the manual edit of the project file and add a WebProject tag as shown below.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJMaUXtXsDEzh7dLVowI4-fBLNJPDH6tVieSUbLWNndHL2933MnXtWXfEiuUpeHS9AVDKhrIWGf9auzEcrm4c8It5US6zzKm-gHpz6kz9Y2FTeWOgOulnre0b7K9tiOHOXcDHoa48rugs/s1600/Web+Project+True.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;274&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJMaUXtXsDEzh7dLVowI4-fBLNJPDH6tVieSUbLWNndHL2933MnXtWXfEiuUpeHS9AVDKhrIWGf9auzEcrm4c8It5US6zzKm-gHpz6kz9Y2FTeWOgOulnre0b7K9tiOHOXcDHoa48rugs/s640/Web+Project+True.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
Then add the following magic at the end of the file:&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #666666; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;lt;Target Name=&quot;BeforeBuild&quot;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #666666; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;MSBuild Projects=&quot;%(ProjectReference.FullPath)&quot; Targets=&quot;Package&quot; Properties=&quot;Configuration=$(Configuration);Platform=AnyCPU&quot; Condition=&quot;&#39;%(ProjectReference.WebProject)&#39;==&#39;True&#39;&quot; /&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #666666; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;PropertyGroup&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #666666; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;LinkerBaseInputPaths&amp;gt;%(ProjectReference.RootDir)%(ProjectReference.Directory)obj\$(Configuration)\Package\PackageTmp\&amp;lt;/LinkerBaseInputPaths&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #666666; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/PropertyGroup&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #666666; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;HeatDirectory OutputFile=&quot;%(ProjectReference.Filename).wxs&quot; Directory=&quot;%(ProjectReference.RootDir)%(ProjectReference.Directory)obj\$(Configuration)\Package\PackageTmp\&quot; DirectoryRefId=&quot;INSTALLFOLDER&quot; ComponentGroupName=&quot;%(ProjectReference.Filename)_Project&quot; AutogenerateGuids=&quot;true&quot; SuppressCom=&quot;true&quot; SuppressFragments=&quot;true&quot; SuppressRegistry=&quot;true&quot; SuppressRootDirectory=&quot;true&quot; ToolPath=&quot;$(WixToolPath)&quot; PreprocessorVariable=&quot;var.WebServiceProjectDir&quot; Condition=&quot;&#39;%(ProjectReference.WebProject)&#39;==&#39;True&#39;&quot; /&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #666666; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;lt;/Target&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
And you are done with this file, yay!!!&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
Close the file and select &quot;Reload Project&quot;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvcROEEYW-AzentXEhvWzVIrooLokH0cLEcW84Lhdwgn_jKLKUhjJWW5AmaaCV3scBYZJC7DNiyf0fRtADQKczttrXBxPGMkgWZcfjlG08KSXykocynVOGG2rI1KZU61mM6r7rj63Jdm0/s1600/Reload+Project.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;106&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvcROEEYW-AzentXEhvWzVIrooLokH0cLEcW84Lhdwgn_jKLKUhjJWW5AmaaCV3scBYZJC7DNiyf0fRtADQKczttrXBxPGMkgWZcfjlG08KSXykocynVOGG2rI1KZU61mM6r7rj63Jdm0/s400/Reload+Project.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
Then we just need to add a number of Wix XML files to our Wix Setup Project. The XML files contains some weird arcane incantations that will make Wix produce an installer when the project is built.&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;English.wxl &amp;nbsp;: A kind of text resources file. Used to have all text strings in one place. You need to edit this to match your needs.&lt;/li&gt;
&lt;li&gt;InstallationAddressDlg.wxs : Contains wix mumbo jumbo, you need to make two changes here&lt;/li&gt;
&lt;li&gt;Conditions.wxi a file that contains a few checks that we want to run so see if we can install&lt;/li&gt;
&lt;li&gt;MyUI.wxs :&amp;nbsp;Contains wix mumbo jumbo, no need to change&lt;/li&gt;
&lt;li&gt;Settings.wxi :&amp;nbsp;Contains wix mumbo jumbo, no need to change&lt;/li&gt;
&lt;li&gt;WebSites.wxi:&amp;nbsp;Contains wix mumbo jumbo, no need to change&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
I have put all these files up on code.google.com here:&amp;nbsp;&lt;a href=&quot;http://code.google.com/p/on-coding-blogg-files/downloads/detail?name=Wix%20Web%20Service%20Setup%20Project%20files.zip&amp;amp;can=2&amp;amp;q=&quot; target=&quot;_blank&quot;&gt;Wix files&lt;/a&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
You also want to replace the default Product.wxs with the one I have uploaded.&lt;/div&gt;
&lt;div&gt;
Then you need to do some modifications to English.wxl to match your setup.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The zip file contains an assembly called&amp;nbsp;CustomActions.IIS.CA.dll in addition to the mentioned wix files. This assembly is needed to list the websites and virtual directories of your IIS server, which is required to know where to install the web service.&lt;/div&gt;
&lt;div&gt;
You can save this assembly anywhere on your disk, but you will need to modify&amp;nbsp;InstallationAddressDlg.wxs so that it points to this assembly.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIWUmTIOjUib3hYhFsiSGy2TXpLUxgRelJ3_wW6Ay7jOWYfOmFwUv-JS11H5dmzJ6LjzIJZC5ee0UNJd2t6HH6q34pYMrTgLOKf0DXR9wl7SZgZugg8r6QwgZqt5bk4F-LpRw3QbWeCYI/s1600/InstallationAddressDlg.wxs.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;185&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIWUmTIOjUib3hYhFsiSGy2TXpLUxgRelJ3_wW6Ay7jOWYfOmFwUv-JS11H5dmzJ6LjzIJZC5ee0UNJd2t6HH6q34pYMrTgLOKf0DXR9wl7SZgZugg8r6QwgZqt5bk4F-LpRw3QbWeCYI/s400/InstallationAddressDlg.wxs.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
And that&#39;s it. You should now be able to build your setup project and it should produce a MSI file that will install your web service.&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
I will try to make a project template out of all this, and if I can make it work my next post will be about how to make a custom wix project template.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
For those who want more details you can read the following which I used when creating my installer:&lt;br /&gt;
&lt;br /&gt;
Blogs I have read and based my files on includes:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://marcostuder.blogspot.com/&quot;&gt;http://marcostuder.blogspot.com/&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://blogs.planetsoftware.com.au/paul/archive/2011/02/20/creating-a-web-application-installer-with-wix-3.5-and-visual.aspx&quot;&gt;http://blogs.planetsoftware.com.au/paul/archive/2011/02/20/creating-a-web-application-installer-with-wix-3.5-and-visual.aspx&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.cmcrossroads.com/cm-basics/12907-installing-a-web-application-to-an-existing-iis-website-using-wix3&quot;&gt;http://www.cmcrossroads.com/cm-basics/12907-installing-a-web-application-to-an-existing-iis-website-using-wix3&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://blogs.technet.com/b/alexshev/archive/2008/02/21/from-msi-to-wix-part-5-custom-actions.aspx&quot;&gt;http://blogs.technet.com/b/alexshev/archive/2008/02/21/from-msi-to-wix-part-5-custom-actions.aspx&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://blog.torresdal.net/2008/10/24/WiXAndDTFUsingACustomActionToListAvailableWebSitesOnIIS.aspx&quot;&gt;http://blog.torresdal.net/2008/10/24/WiXAndDTFUsingACustomActionToListAvailableWebSitesOnIIS.aspx&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://lostechies.com/gabrielschenker/2010/05/18/wix-and-custom-actions/&quot;&gt;http://lostechies.com/gabrielschenker/2010/05/18/wix-and-custom-actions/&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oncoding.blogspot.com/feeds/200431728718573225/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://oncoding.blogspot.com/2012/03/creating-web-service-installer-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7203370983485193018/posts/default/200431728718573225'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7203370983485193018/posts/default/200431728718573225'/><link rel='alternate' type='text/html' href='http://oncoding.blogspot.com/2012/03/creating-web-service-installer-in.html' title='Creating a web service installer in Visual Studio 11 using WIX'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/17693565125055146738</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_8TkVNFBXOCTZktxl9qaS7khP7fH3R0eRBrARYeAvUjXHMD1xwJGdbGtJ7fRU4TECgEmmLef3T-YRVp7sGSmvbBzPfMuQra0-r3snxHZwj3kaUvqg1VMvsp8uWYh9VIPTPeMYb782eQU/s72-c/New+Project.PNG" height="72" width="72"/><thr:total>0</thr:total></entry></feed>