<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://devlicious.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Derik Whittaker</title><subtitle type="html">Thoughts on Software Development, .Net, OOP, Design Patterns and all things cool
&lt;br /&gt;&lt;br /&gt;
&lt;div class="altnetgeekcode"&gt;&lt;a href="http://www.hanselman.com/altnetgeekcode/default.aspx?q=IOC(SM):MOC(RM):TDD(NU):SCC(Svn):ORM(L2S):XPP(-):XPP(+):DDD(T+)"&gt;IOC(SM):MOC(RM):TDD(NU):SCC(Svn):ORM(L2S):XPP(-):XPP(+):DDD(T+)&lt;/a&gt;&lt;/div&gt;</subtitle><id>http://devlicious.com/blogs/derik_whittaker/atom.aspx</id><link rel="alternate" type="text/html" href="http://devlicious.com/blogs/derik_whittaker/default.aspx" /><link rel="self" type="application/atom+xml" href="http://devlicious.com/blogs/derik_whittaker/atom.aspx" /><generator uri="http://communityserver.org" version="3.0.20416.853">Community Server</generator><updated>2008-11-29T10:19:43Z</updated><entry><title>Did corporate IT depts not get the memo disk space is cheap?</title><link rel="alternate" type="text/html" href="http://devlicious.com/blogs/derik_whittaker/archive/2009/01/06/did-corporate-it-depts-not-get-the-memo-disk-space-is-cheap.aspx" /><id>http://devlicious.com/blogs/derik_whittaker/archive/2009/01/06/did-corporate-it-depts-not-get-the-memo-disk-space-is-cheap.aspx</id><published>2009-01-06T12:48:51Z</published><updated>2009-01-06T12:48:51Z</updated><content type="html">&lt;p&gt;Does anyone else have this issue at work.&amp;#160; I have 75mb worth of emails within my corporate exchange account and I get emails about 1-2 times a week telling me I am over my limit.&amp;#160; WHY.&amp;#160; &lt;/p&gt;  &lt;p&gt;Has corporate IT departments not got the memo that drive space is DIRT CHEAP.&amp;#160; I mean this is not the 90’s.&amp;#160; I can go out and by a few TB’s of drive space for the price of a nice steak dinner.&amp;#160; I am almost to the point where I am going to buy a damn drive my self and walk it down to our IT dept and ask them to install it (ok, since I am a remote worker i guess i will have to send it to them, but you get the point).&lt;/p&gt;  &lt;p&gt;Anyway, I am done with my little mini-rant.&amp;#160; besides, i have found that if i do not acknowledge the emails they go away (or at least get deleted).&lt;/p&gt;  &lt;p&gt;Till next time,&lt;/p&gt;&lt;img src="http://devlicious.com/aggbug.aspx?PostID=43623" width="1" height="1"&gt;</content><author><name>Dwhittaker</name><uri>http://devlicious.com/members/Dwhittaker.aspx</uri></author><category term="Humor" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/Humor/default.aspx" /></entry><entry><title>Teaching someone to test using an Isolation Framework</title><link rel="alternate" type="text/html" href="http://devlicious.com/blogs/derik_whittaker/archive/2008/12/30/teaching-someone-to-test-using-an-isolation-framework.aspx" /><id>http://devlicious.com/blogs/derik_whittaker/archive/2008/12/30/teaching-someone-to-test-using-an-isolation-framework.aspx</id><published>2008-12-30T17:21:12Z</published><updated>2008-12-30T17:21:12Z</updated><content type="html">&lt;p&gt;Part of my job at work is to teach and mentor other developers on our team.&amp;nbsp; Right now I am in the process of teaching two of our developers how to create unit tests (notice I did NOT say integration tests because most anyone can do those).&amp;nbsp; We are also learning how to create our tests by utilizing an Isolation Framework (aka mocking framework).&lt;/p&gt; &lt;p&gt;I am really excited for this opportunity because I firmly believe that you create better software when you do it by creating tests to prove your code works.&amp;nbsp; I am also excited because both of the developer buy into the idea of testing and are extremely eager to learn how to to better test their code.&lt;/p&gt; &lt;p&gt;Because we had a few days of downtime because of the Christmas holiday before our 1st sprint on our project we thought it would be a good time to do some pairing (guess it would be better called tri-pairing).&amp;nbsp; Our plan of attack was to start to flush out some of the features in our system but do it in a total TDD manor.&amp;nbsp; We were also going to be utilizing the Rhino Mock Isolation framework in our tests.&lt;/p&gt; &lt;p&gt;So over the next 2 days we spent about 12 hours or so working building out our code.&amp;nbsp; Over this time we actually were able to create an complete end to end &amp;#39;version&amp;#39; (I say version because we did not fill in all the functionality of the code but were able to get all the major pieces stubbed out) which allowed us to flush out many, many more business requirement and build a simple, yet flexible code base.&lt;/p&gt; &lt;p&gt;I hope both of my co-workers learned a ton from this exercise, I know I did.&amp;nbsp; This was the first time where I had actually spent any significant amount of time teaching someone who was new to testing how to do so.&amp;nbsp; Sure I had spent an hour here or an hour there, but nothing like this.&amp;nbsp; &lt;/p&gt; &lt;p&gt;What I really wanted to share with everyone is what I learned form this experience.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Slowdown, slowdown, slowdown&lt;br /&gt;&lt;/strong&gt;The first thing you should do when teaching something how to do anything is SLOWDOWN.&amp;nbsp; You have to remember that if you are talking/teaching to someone who is new to this they have to not only try to process the information so they can understand it, they also have to try to remember it.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Make NO assumptions, teach as if they know nothing&lt;br /&gt;&lt;/strong&gt;This one was the most important thing I learned.&amp;nbsp; You cannot make assumptions on anything.&amp;nbsp; Anytime you say anything make sure you fully explain it.&amp;nbsp; If you use an acronym EXPLAIN IT.&amp;nbsp; Any time you mention a buzz word EXPLAIN IT.&amp;nbsp; Plan and simple EXPLAIN EVERYTHING&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Have them drive&lt;br /&gt;&lt;/strong&gt;During the teaching part it is critical that you have then code, have them tell you what to do.&amp;nbsp; It is ok for you to &amp;#39;lead&amp;#39; them in the right direction, but you must not always drive.&amp;nbsp; This will really help to drive home the concepts.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Provide examples both with and without the Isolation framework&lt;br /&gt;&lt;/strong&gt;In our case because I was trying to teach them testing using an Isolation framework it really helped when I would create a test (aka integration) with no mocks and then re-create it with mocks.&amp;nbsp; Doing this really helped to explain to them how using the Isolation framework removed dependencies.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Don&amp;#39;t let them skate by&lt;br /&gt;&lt;/strong&gt;Don&amp;#39;t let them simply nod their head as if they understand.&amp;nbsp; Make sure you keep asking them if there is anything you can clear up or explain better.&amp;nbsp; At first they are going to simply say no, they are good.&amp;nbsp; But as you keep asking and start having them drive they WILL start to ask more questions, I promise.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Turn off any coding tools such as ReSharper (or the likes) and do NOT use shortcuts&lt;br /&gt;&lt;/strong&gt;This may have been the biggest issue for us at first.&amp;nbsp; I am pretty good with ReSharper (if I can toot my own horn here) and I was coding with it as I would do if I were by myself.&amp;nbsp; On more than one occasion the would look at me cross-eyed and ask &amp;#39;what the hell just happened&amp;#39;.&amp;nbsp; Finally I simply stopped using it for the first day.&amp;nbsp; On the second day I went back to using R#, but I turned on &lt;a href="http://weblogs.asp.net/rosherove/archive/2007/06/03/train-to-be-a-keyboard-master-with-keyboard-jedi.aspx"&gt;Keyboard Jedi&lt;/a&gt; so they could see what was going on.&amp;nbsp; Even though I turned on Keyboard Jedi, I tried my best to make sure to explain what just happened when used R#.&lt;/p&gt; &lt;p&gt;Anyway, I have rambled on long enough and I think I have pretty much gotten my thoughts out there.&amp;nbsp; I really enjoyed working with these guys and I am looking forward to doing so again when we get back from break.&lt;/p&gt; &lt;p&gt;Hope this helps, &lt;/p&gt; &lt;p&gt;Till next time,&lt;/p&gt;&lt;img src="http://devlicious.com/aggbug.aspx?PostID=43560" width="1" height="1"&gt;</content><author><name>Dwhittaker</name><uri>http://devlicious.com/members/Dwhittaker.aspx</uri></author><category term="Agile" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/Agile/default.aspx" /><category term="TDD" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/TDD/default.aspx" /><category term="Rhino Mocks" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/Rhino+Mocks/default.aspx" /><category term="Opinion" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/Opinion/default.aspx" /><category term="HowTo" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/HowTo/default.aspx" /></entry><entry><title>Challenge everything, accept nothing at face value, only then will we learn</title><link rel="alternate" type="text/html" href="http://devlicious.com/blogs/derik_whittaker/archive/2008/12/24/challenge-everything-accept-nothing-at-face-value-only-then-will-we-learn.aspx" /><id>http://devlicious.com/blogs/derik_whittaker/archive/2008/12/24/challenge-everything-accept-nothing-at-face-value-only-then-will-we-learn.aspx</id><published>2008-12-24T16:54:05Z</published><updated>2008-12-24T16:54:05Z</updated><content type="html">&lt;p&gt;Today I posted a comment to one of my other blog posts that read:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;I forgot about the blue bible of DDD.&amp;nbsp; Since Eric said it, it must be gospel.&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;This comment was in response to another comment about the &lt;a href="http://www.amazon.com/Domain-Driven-Design-Tackling-Complexity-Software/dp/0321125215/ref=pd_bbs_sr_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1230137592&amp;amp;sr=8-1"&gt;Eric Evans DDD&lt;/a&gt; book.&amp;nbsp; I know that my comment was a bit harsh and will be taken way out of context by many.&amp;nbsp; Sadly the ones that take it out of context will do so by defending the DDD book.&amp;nbsp; Even though my comment was directly about that book, the spirit of it has nothing to do with that book or any other book, blog, etc.&amp;nbsp; In fact I buy into the majority of the concepts in the book and actually like the book for its content.&lt;/p&gt; &lt;p&gt;The point I was trying to make (yes I did a very, very poor job of it) was that simply reading something does not make it gospel.&amp;nbsp; In order to fully understand something and to be able to do it correctly we need to think, reflect and challenge the thoughts.&amp;nbsp; I see too many people who simply read something and then do it, or read something and think it must be true in ALL cases. &lt;/p&gt; &lt;p&gt;Every situation is different and every situation needs to be treated as unique and be thought about as such.&lt;/p&gt; &lt;p&gt;We as a profession are learning at a great pace and our thoughts on what is good design or the right way is also changing very rapidly.&amp;nbsp; In order for us to continue to grow we need to accept nothing as is and challenge everything.&amp;nbsp; If after we have challenged it we still find it to be true, then we have succeeded.&lt;/p&gt; &lt;p&gt;The moral this post is this.&amp;nbsp; Read something, think about it, reflect on it.&amp;nbsp; If you understand and agree the intent of the content and it make sense for you in your situation then implement it.&amp;nbsp; If it does not make sense the find a better solution.&lt;/p&gt; &lt;p&gt;Till next time,&lt;/p&gt;&lt;img src="http://devlicious.com/aggbug.aspx?PostID=43516" width="1" height="1"&gt;</content><author><name>Dwhittaker</name><uri>http://devlicious.com/members/Dwhittaker.aspx</uri></author><category term="Opinion" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/Opinion/default.aspx" /></entry><entry><title>An Apple success (in my book) with the iPhone and iTunes</title><link rel="alternate" type="text/html" href="http://devlicious.com/blogs/derik_whittaker/archive/2008/12/23/an-apple-success-in-my-book-with-the-iphone-and-itunes.aspx" /><id>http://devlicious.com/blogs/derik_whittaker/archive/2008/12/23/an-apple-success-in-my-book-with-the-iphone-and-itunes.aspx</id><published>2008-12-24T02:07:54Z</published><updated>2008-12-24T02:07:54Z</updated><content type="html">&lt;p&gt;Today my iPhone took a crap.&amp;nbsp; I am not real sure what the issue was but all I know is it went to a white screen and I could not do anything about it.&lt;/p&gt; &lt;p&gt;I was hoping that simply plugging it into the PC would solve the issue, but it did not.&amp;nbsp; Because I did not know what to do and I did not want to screw around with it I figured I would do a reset to factory.&amp;nbsp; I was completely prepared to lose all my data as it was mostly just apps and emails (hey, it is a phone after all) and I was pretty sure my contacts would be restored.&lt;/p&gt; &lt;p&gt;What I was surprised to see what that after a restore via iTunes all my prior apps, contacts and music/data were put back.&amp;nbsp; What really shocked me was that all my settings for each app were put back as well.&lt;/p&gt; &lt;p&gt;I have to say that in my book this was a success.&amp;nbsp; Apple did something right here.&amp;nbsp; Nice job Jobs&amp;#39;&lt;/p&gt; &lt;p&gt;Till next time,&lt;/p&gt;&lt;img src="http://devlicious.com/aggbug.aspx?PostID=43501" width="1" height="1"&gt;</content><author><name>Dwhittaker</name><uri>http://devlicious.com/members/Dwhittaker.aspx</uri></author><category term="Opinion" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/Opinion/default.aspx" /></entry><entry><title>Now referring to Interfaces as Contracts in code and conversation</title><link rel="alternate" type="text/html" href="http://devlicious.com/blogs/derik_whittaker/archive/2008/12/23/now-referring-to-interfaces-as-contracts-in-code-and-conversation.aspx" /><id>http://devlicious.com/blogs/derik_whittaker/archive/2008/12/23/now-referring-to-interfaces-as-contracts-in-code-and-conversation.aspx</id><published>2008-12-23T20:05:44Z</published><updated>2008-12-23T20:05:44Z</updated><content type="html">&lt;p&gt;I am just throwing this out there and am looking for feedback.&lt;/p&gt; &lt;p&gt;The other day when I was setting up the structure for a project at work I went to create a folder called interfaces (this is an API style project and this was going to hold all the public interfaces for the project), but I stopped.&lt;/p&gt; &lt;p&gt;As I sat there trying to figure out why I had stopped it dawned on me that I no longer liked the name interface(s) when talking about code.&amp;nbsp; I really like the term Contract.&amp;nbsp; The more I thought about it the more I really started to like it.&lt;/p&gt; &lt;p&gt;To me the term contract conveys more meaning to the next developer then the term interface.&amp;nbsp; By using the contract I am making a statement to everyone else that I am putting thought into this and this is EXACTLY what I want to expose to you, nothing more, nothing less.&lt;/p&gt; &lt;p&gt;I think going forward I am going to start referring to my interface (IFoo) as contracts and only use the work interface when creating the actual code.&lt;/p&gt; &lt;p&gt;Thoughts, Feedback?&lt;/p&gt; &lt;p&gt;Till next time,&lt;/p&gt; &lt;p&gt;[--- Remember to check out &lt;a href="http://www.dimecasts.net"&gt;www.dimecasts.net&lt;/a&gt; ---]&lt;/p&gt;&lt;img src="http://devlicious.com/aggbug.aspx?PostID=43493" width="1" height="1"&gt;</content><author><name>Dwhittaker</name><uri>http://devlicious.com/members/Dwhittaker.aspx</uri></author></entry><entry><title>ReSharper 4.5 coming out soon</title><link rel="alternate" type="text/html" href="http://devlicious.com/blogs/derik_whittaker/archive/2008/12/21/resharper-4-5-coming-out-soon.aspx" /><id>http://devlicious.com/blogs/derik_whittaker/archive/2008/12/21/resharper-4-5-coming-out-soon.aspx</id><published>2008-12-21T19:56:30Z</published><updated>2008-12-21T19:56:30Z</updated><content type="html">&lt;p&gt;Looks like everyone&amp;#39;s favorite productivity tool for .net development is getting a upgrade.&lt;/p&gt; &lt;p&gt;I got an email the other day from JetBrains saying that v4.5 should be out in Q1 of 2009 and that public beta&amp;#39;s should be ready by end of this year.&lt;/p&gt; &lt;p&gt;Highlights of &lt;a href="http://www.jetbrains.com/resharper/?rs-newsletter"&gt;ReSharper&lt;/a&gt; 4.5 include: &lt;/p&gt; &lt;ul&gt; &lt;li&gt;Solution-Wide Analysis. In addition to the current abilities to detect errors in your entire solution, ReSharper 4.5 enables you to identify unused code, excessive access rights, overly specific types and such on.  &lt;li&gt;Better Visual Basic support: our cross-language refactorings and editing experience enhancements will better support VB code &lt;li&gt;New refactorings &lt;li&gt;Enhanced setup for naming conventions, which will be supported by all ReSharper features  &lt;li&gt;Multiple new productivity enhancements&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;I know I am going to grab the beta when it comes out.&lt;/p&gt; &lt;p&gt;Till next time,&lt;/p&gt;&lt;img src="http://devlicious.com/aggbug.aspx?PostID=43471" width="1" height="1"&gt;</content><author><name>Dwhittaker</name><uri>http://devlicious.com/members/Dwhittaker.aspx</uri></author><category term="Development Tools" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/Development+Tools/default.aspx" /><category term="ReSharper" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/ReSharper/default.aspx" /></entry><entry><title>Adding MSTest results (.trx) files to your TeamCity build results</title><link rel="alternate" type="text/html" href="http://devlicious.com/blogs/derik_whittaker/archive/2008/12/20/adding-mstest-results-trx-files-to-your-teamcity-build-results.aspx" /><id>http://devlicious.com/blogs/derik_whittaker/archive/2008/12/20/adding-mstest-results-trx-files-to-your-teamcity-build-results.aspx</id><published>2008-12-20T15:39:58Z</published><updated>2008-12-20T15:39:58Z</updated><content type="html">&lt;p&gt;As I am building out our CI environment with &lt;a href="http://www.jetbrains.com/teamcity/index.html"&gt;TeamCity&lt;/a&gt; (man, this is a great product) I finally had to tackle something that I have been putting off for the past few weeks.&amp;#160; Adding the tests results to TeamCity from our various components which use MSTest.&amp;#160; I have already added NUnit results, as that is done for you out of the box with TeamCity.&amp;#160; Now before you ask ‘Why are you using both MSTest and NUnit’?&amp;#160; We simple.&amp;#160; Most our older tests are done with MSTest (god, I really, really hate MSTests – More here) and most our newer (less than 6 months old) code is in NUnit.&lt;/p&gt;  &lt;p&gt;I really thought that adding MSTests would be a pain, but as it turned out it was not.&amp;#160; I searched Jetbrains knowledge base and found this &lt;a href="http://www.jetbrains.net/confluence/display/TCD4/MSTest+Support"&gt;posting&lt;/a&gt; which talked about what&amp;#160; you needed to do to add MSTest results to your build.&lt;/p&gt;  &lt;p&gt;Basically you only need to add this line to your build (assuming NAnt here) file.&lt;/p&gt;  &lt;pre&gt;##teamcity[importData id=&amp;#39;mstest&amp;#39; file=&amp;#39;&amp;lt;path to .trx file&amp;gt;&amp;#39;]&lt;/pre&gt;

&lt;p&gt;When I say add it, I simply mean doing a echo of this information.&amp;#160; This is possible because TeamCity watches the standard output stream for various commands, and this is one of the commands you can use.&lt;/p&gt;

&lt;p&gt;Here is how I added this to my build file:&lt;/p&gt;

&lt;p&gt;&amp;lt;target name=&amp;quot;tests.run.HL7&amp;quot; &amp;gt; 
  &lt;br /&gt;&amp;#160; &amp;lt;property name=&amp;quot;test.resultFile.name&amp;quot; value=&amp;quot;${tests.output.dir}/testResults.trx&amp;quot; /&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;if test=&amp;quot;${file::exists(test.resultFile.name)}&amp;quot;&amp;gt; 

  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;echo message=&amp;quot;Deleting old test run file ${test.resultFile.name}&amp;quot; /&amp;gt; 

  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;delete file=&amp;quot;${test.resultFile.name}&amp;quot; /&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;/if&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;exec program=&amp;quot;MSTest.exe&amp;quot; 

  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; commandline=&amp;quot;/testcontainer:${build.dir}${communication.tests.file} /testcontainer:${build.dir}${httpImportService.tests.file} /testcontainer:${build.dir}${messagesCore.tests.file} /testcontainer:${build.dir}${messageHandler.tests.file} /resultsfile:${tests.output.dir}/testResults.trx&amp;quot; 

  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; basedir=&amp;quot;C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE&amp;quot; 

  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; failonerror=&amp;quot;false&amp;quot; 

  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /&amp;gt; &lt;/p&gt;

&lt;p&gt;&amp;#160; &amp;lt;!--- This is the needed line for TeamCity --&amp;gt; 
  &lt;br /&gt;&amp;#160; &amp;lt;echo message=&amp;quot;##teamcity[importData id=&amp;#39;mstest&amp;#39; file=&amp;#39;…path to output….\Output_AutomatedBuild\Output_UnitTests\testResults.trx&amp;#39;]&amp;quot; /&amp;gt; 

  &lt;br /&gt;&amp;lt;/target&amp;gt;&lt;/p&gt;

&lt;p&gt;As you can see this is real easy.&amp;#160; Once you have this in your build file simply re-run your build in TeamCity and check your build results.&amp;#160; If you did every thing correct you should have a ‘Test’ tab.&amp;#160; If something went wrong check your output logs as it should tell you what blew up.&lt;/p&gt;

&lt;p&gt;Hope this helps someone.&lt;/p&gt;

&lt;p&gt;Till next time,&lt;/p&gt;

&lt;p&gt;[--- Check out &lt;a href="http://www.Dimecasts.net"&gt;www.Dimecasts.net&lt;/a&gt; ---]&lt;/p&gt;&lt;img src="http://devlicious.com/aggbug.aspx?PostID=43463" width="1" height="1"&gt;</content><author><name>Dwhittaker</name><uri>http://devlicious.com/members/Dwhittaker.aspx</uri></author><category term="Development Tools TeamCity" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/Development+Tools+TeamCity/default.aspx" /></entry><entry><title>StructureMap and Loaded Plugins Gotcha</title><link rel="alternate" type="text/html" href="http://devlicious.com/blogs/derik_whittaker/archive/2008/12/18/structuremap-and-loaded-plugins-gotcha.aspx" /><id>http://devlicious.com/blogs/derik_whittaker/archive/2008/12/18/structuremap-and-loaded-plugins-gotcha.aspx</id><published>2008-12-19T02:33:14Z</published><updated>2008-12-19T02:33:14Z</updated><content type="html">&lt;p&gt;One of the really great things about the latest release of StructureMap is that I do not need to register objects by default if they follow a standard convention (i.e. if I want to register a controller called ‘AuthorController’ and accessed via ‘AuthorController’ I do not need to do anything, SM is smart enough to map this for me).&amp;#160; However, as great as this is, there is one slight issue (may be a bug, do not know need to follow up with Jeremy).&lt;/p&gt;  &lt;p&gt;In the Dimecasts codebase I put the logic to register routes for each controller into each controller.&amp;#160; I then at startup time I loop though all the controllers and register each route.&lt;/p&gt;  &lt;p&gt;The code below is the logic I do for performing this registration&lt;/p&gt;  &lt;pre class="c-sharp" name="code"&gt;	
	var controllerInstances = ObjectFactory.Model.PluginTypes.Where(x =&amp;gt; typeof(BaseController).IsAssignableFrom(x.PluginType));

	foreach (var controllerInstance in controllerInstances) 
	{ 

	var instance = (BaseController)ObjectFactory.GetInstance(controllerInstance.PluginType); 

	instance.RegisterRoutes(RouteTable.Routes); 

	}&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;All of this works and works well but when i added a new controller to the application and did not manually register it (aka using the convention of configuration feature) I was not able to load the new controller.&amp;#160; I was a little stumped at first, but then it downed on me that since i am not pre-registering the controller with StructureMap it may not now how to find it.&amp;#160; To test this theory i simply manually registered the controller and bam, all worked.&lt;/p&gt;

&lt;p&gt;I thought I would share this incase anyone else had the same issue.&lt;/p&gt;

&lt;p&gt;Till next time,&lt;/p&gt;

&lt;p&gt;[--- Remember to check out &lt;a href="http://www.dimecasts.net"&gt;www.dimecasts.net&lt;/a&gt; ---]&lt;/p&gt;&lt;img src="http://devlicious.com/aggbug.aspx?PostID=43448" width="1" height="1"&gt;</content><author><name>Dwhittaker</name><uri>http://devlicious.com/members/Dwhittaker.aspx</uri></author><category term="Agile" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/Agile/default.aspx" /><category term=".Net" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/.Net/default.aspx" /><category term="StructureMap" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/StructureMap/default.aspx" /><category term="ASP.Net MVC" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/ASP.Net+MVC/default.aspx" /></entry><entry><title>Oxite, an example on how NOT to put code on internet</title><link rel="alternate" type="text/html" href="http://devlicious.com/blogs/derik_whittaker/archive/2008/12/13/oxite-an-example-on-how-not-to-put-code-on-internet.aspx" /><id>http://devlicious.com/blogs/derik_whittaker/archive/2008/12/13/oxite-an-example-on-how-not-to-put-code-on-internet.aspx</id><published>2008-12-13T22:21:20Z</published><updated>2008-12-13T22:21:20Z</updated><content type="html">&lt;p&gt;***** UPDATE *****   &lt;br /&gt;In fairness it appears that I had downloaded the latest build, not the ‘official’ release.&amp;#160; So I hear the release does NOT have this issue, only the latest drop.    &lt;br /&gt;***** END UPDATE *****&lt;/p&gt;  &lt;p&gt;Today I had a few minutes so I thought I would grab the &lt;a href="http://www.codeplex.com/oxite"&gt;Oxite&lt;/a&gt; code to take a peek at the code.&amp;#160; I have no plans in actually using the code or application for my site, but I always enjoy looking at other code examples as you can always learn something.&lt;/p&gt;  &lt;p&gt;To get started I went over to the download section of the project to get the code and that was pretty easy, which ends any ‘easiness’ about this.&lt;/p&gt;  &lt;p&gt;After the code was downloaded and unzipped I did what anyone would do, I double clicked on the Oxite.sln to open it.&amp;#160; I fully expected to be able to open the project and compile… NOPE.&amp;#160; &lt;/p&gt;  &lt;p&gt;The first thing it did was bark that the project was under source control and that it could not connect to the source repository.&amp;#160; It then proceeded to bark at me for each and every project in the solution.&amp;#160; This is ok as I have seen this before, but then it did not load any of the projects at the end of all the barking.&amp;#160; It simply opened the solution up and showed all the projects as being unavailable.&amp;#160; The main reason for the source issues is because the source was checked into TFS and I do not have the TFS client installed on my box.&amp;#160; This is a massive fail in my book.&lt;/p&gt;  &lt;p&gt;In order to actually open the .sln file I needed to do the following.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Delete all .vss files from the folder tree &lt;/li&gt;    &lt;li&gt;Open all .proj files in notepad and delete the following      &lt;br /&gt;&amp;lt;SccProjectName&amp;gt;SAK&amp;lt;/SccProjectName&amp;gt;       &lt;br /&gt;&amp;lt;SccLocalPath&amp;gt;SAK&amp;lt;/SccLocalPath&amp;gt;       &lt;br /&gt;&amp;lt;SccAuxPath&amp;gt;SAK&amp;lt;/SccAuxPath&amp;gt;       &lt;br /&gt;&amp;lt;SccProvider&amp;gt;SAK&amp;lt;/SccProvider&amp;gt; &lt;/li&gt;    &lt;li&gt;Open the .sln file in notepad and remove the following section      &lt;br /&gt;      &lt;p&gt;GlobalSection(TeamFoundationVersionControl) = preSolution        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; SccNumberOfProjects = 10         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; SccTeamFoundationServer = &lt;a href="https://tfs04.codeplex.com/"&gt;https://tfs04.codeplex.com/&lt;/a&gt;         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ….         &lt;br /&gt;EndGlobalSection&lt;/p&gt;   &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Once I did the following I was able to run and compile the solution.&amp;#160; &lt;/p&gt;  &lt;p&gt;So, what is my main beef with this?&amp;#160; Simple.&amp;#160; When you post code on the net in this fashion making it hard for people to work with is the exact opposite of what you want.&amp;#160; Make it hard and people will leave, make it easy and people will stay.&lt;/p&gt;  &lt;p&gt;Anyway, my rant is over.&lt;/p&gt;  &lt;p&gt;Till next time,&lt;/p&gt;&lt;img src="http://devlicious.com/aggbug.aspx?PostID=43405" width="1" height="1"&gt;</content><author><name>Dwhittaker</name><uri>http://devlicious.com/members/Dwhittaker.aspx</uri></author></entry><entry><title>Another great gift from Red Gate</title><link rel="alternate" type="text/html" href="http://devlicious.com/blogs/derik_whittaker/archive/2008/12/12/another-great-gift-from-red-gate.aspx" /><id>http://devlicious.com/blogs/derik_whittaker/archive/2008/12/12/another-great-gift-from-red-gate.aspx</id><published>2008-12-13T02:24:28Z</published><updated>2008-12-13T02:24:28Z</updated><content type="html">&lt;p&gt;&lt;a href="http://devlicio.us/blogs/derik_whittaker/WindowsLiveWriter/AnothergreatgiftfromRedGate_11F0F/photo_2.jpg"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="184" alt="photo" src="http://devlicio.us/blogs/derik_whittaker/WindowsLiveWriter/AnothergreatgiftfromRedGate_11F0F/photo_thumb.jpg" width="244" align="right" border="0" /&gt;&lt;/a&gt; Every year &lt;a href="http://www.red-gate.com/index.htm"&gt;Red-Gate&lt;/a&gt; sends all for their &amp;#39;Friends of Red-Gate&amp;#39; a great Christmas basket, this year was no exception.&amp;nbsp; You may be asking &amp;#39;What is a &lt;a href="http://www.red-gate.com/About/community_relations/friends_of_RG.htm"&gt;Friend of Red-Gate&lt;/a&gt;&amp;#39;.&amp;nbsp; This is a great program they started a while back to reach out to the development community ad thank them for their support of their products.&amp;nbsp; I was luck enough to become a &amp;#39;friend&amp;#39; because of my affiliation with Devlicio.us (thanks Brendan).&lt;/p&gt; &lt;p&gt;The basket above is what arrived in the mail today and this year was another great basket of goodies.&amp;nbsp; I would like to send a special Thanks You to &lt;a href="mailto:rachel.hawley@red-gate.com"&gt;Rachel Hawley&lt;/a&gt; as she is the one who coordinates all the community effort.&lt;/p&gt; &lt;p&gt;If you are not familiar with any of the products that Red-Gate offers, pull your head out of the sand and head on over to Red-Gate.com and take a look.&lt;/p&gt; &lt;p&gt;Till next time,&lt;/p&gt;&lt;img src="http://devlicious.com/aggbug.aspx?PostID=43396" width="1" height="1"&gt;</content><author><name>Dwhittaker</name><uri>http://devlicious.com/members/Dwhittaker.aspx</uri></author><category term="Shout-Out" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/Shout-Out/default.aspx" /></entry><entry><title>[PSA] Using the Code Behind in MVC causes blindness</title><link rel="alternate" type="text/html" href="http://devlicious.com/blogs/derik_whittaker/archive/2008/12/12/psa-using-the-code-behind-in-mvc-causes-blindness.aspx" /><id>http://devlicious.com/blogs/derik_whittaker/archive/2008/12/12/psa-using-the-code-behind-in-mvc-causes-blindness.aspx</id><published>2008-12-12T13:38:10Z</published><updated>2008-12-12T13:38:10Z</updated><content type="html">&lt;p&gt;Ok, maybe the title to this post was a little misleading, there have been no studies that actually prove that one way or another if will actually go blind using a CodeBehind, but there have been studies (ok, may just suggestions) that you should NOT use the CodeBehind in a MVC application (for anything other than strongly typing your ViewData).&lt;/p&gt; &lt;p&gt;In standard Asp.net WebForms development the CodeBehind was meant to act as a page controller, but over the years it has turned more into a dumping ground for all sorts of evil code (ie business logic).&amp;nbsp; It is this nasty, ugly code that has given (in part) WebForms a bad image.&amp;nbsp; By continuing to use your code behind in MVC all you are really doing is taking an old nasty technique and applying it to new framework and in turn removing one of the great advantages of MVC.&lt;/p&gt; &lt;p&gt;Part of the beauty of the MVC pattern (notice I said pattern, not framework) is that it helps to enforce Separations of Concerns by pushing logic out of your view and into your controllers. &lt;/p&gt; &lt;p&gt; &lt;hr /&gt; &lt;/p&gt; &lt;p align="center"&gt;&lt;font color="#ff0000" size="5"&gt;&lt;strong&gt;Side Bar&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p align="left"&gt;The controller is NOT to be used in the same manner as Code Behinds in WebForms.&amp;nbsp; The controller should only be responsible for either directional logic or conditional logic.&lt;/p&gt; &lt;p align="left"&gt;What is Directional logic? Directional logic is any logic whose role is to determine how and where data should be gathered base on criteria provided by the routed request.&lt;/p&gt; &lt;p align="left"&gt;What is Conditional logic?&amp;nbsp; Conditional logic is any logic that will attempt to perform various if/else style checks to determine how to best handle the routed request.&lt;/p&gt; &lt;p&gt; &lt;hr /&gt; &lt;/p&gt; &lt;p&gt;If you find yourself using the codebehind for anything OTHER than strongly typing your ViewData you are probably doing something WRONG.&lt;/p&gt; &lt;p&gt;Here are a few rules to live by when doing MVC&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Keep your Code Behind empty&lt;/li&gt; &lt;li&gt;Keep your Views simple&lt;/li&gt; &lt;li&gt;Keep your Controllers light&lt;/li&gt; &lt;li&gt;Keep your Model fat (domain model that is)&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;Till next time,&lt;/p&gt; &lt;p&gt;[--- Check out &lt;a href="http://www.dimecasts.net"&gt;www.dimecasts.net&lt;/a&gt; ---]&lt;/p&gt;&lt;img src="http://devlicious.com/aggbug.aspx?PostID=43382" width="1" height="1"&gt;</content><author><name>Dwhittaker</name><uri>http://devlicious.com/members/Dwhittaker.aspx</uri></author><category term="Best Practice" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/Best+Practice/default.aspx" /><category term="ASP.Net MVC" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/ASP.Net+MVC/default.aspx" /></entry><entry><title>Changing Terms from Mocking Framework to Isolation Framework</title><link rel="alternate" type="text/html" href="http://devlicious.com/blogs/derik_whittaker/archive/2008/12/09/changing-terms-from-mocking-framework-to-isolation-framework.aspx" /><id>http://devlicious.com/blogs/derik_whittaker/archive/2008/12/09/changing-terms-from-mocking-framework-to-isolation-framework.aspx</id><published>2008-12-09T13:14:01Z</published><updated>2008-12-09T13:14:01Z</updated><content type="html">&lt;p&gt;The other day on &lt;a href="http://www.twitter.com"&gt;Twitter&lt;/a&gt;&amp;nbsp;&lt;a href="http://weblogs.asp.net/rosherove/"&gt;Roy Osherove&lt;/a&gt; made the statement that he was teaching a class on TDD and he was showing how to use the various Isolation Frameworks.&amp;nbsp; When I read this I had to ask if he talking about Mocking frameworks when he said Isolation frameworks.&amp;nbsp; And indeed he was.&lt;/p&gt; &lt;p&gt;As I sat back to reflect on the semantic differences between the terms Mocking and Isolation I had an &amp;#39;ah-ha&amp;#39; moment.&amp;nbsp; &lt;/p&gt; &lt;p&gt;When we use the term Mocking we are talking about replacing the &amp;#39;real&amp;#39; functionality with &amp;#39;canned&amp;#39; functionality.&amp;nbsp; Martin Fowler put it best in his &lt;a href="http://martinfowler.com/articles/mocksArentStubs.html"&gt;Mock&amp;#39;s aren&amp;#39;t Stubs&lt;/a&gt; post &lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;Mocks are objects pre-programmed with expectations which form a specification of the calls they are expected to receive.&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;This definition works great and makes a ton of sense, however when most people talk about mocking frameworks do not immediately think &amp;#39;replace real functionality with fake functionality&amp;#39; they are talking about how they setup their tests to test logic in isolation.&lt;/p&gt; &lt;p&gt;However, when you tell someone you are working with an isolation framework the idea should click in their head as to what is going to take place and how it is going to be used.&amp;nbsp; By using the term isolation framework we are telling our end users (developers) that what we are really trying to do with the framework is remove external dependencies from our test in order to make them more granular and reliable.&lt;/p&gt; &lt;p&gt;In fact many times when using a tool like RhinoMocks you are not setting up mocks instances but just removing actual functionality from your tests (remember not all tests need expectations setup). In these cases aren&amp;#39;t we simply isolating behavior?&lt;/p&gt; &lt;p&gt;Maybe switching terms can lead to a wider adoption of mocking (sorry isolation) frameworks being part of our testing tool belts.&lt;/p&gt; &lt;p&gt;I know that at the end of the day a mocking framework like RhinoMocks or Moq really is setting up and executing Mocks for object instances, but I really like the idea of calling these isolation frameworks going forward.&lt;/p&gt; &lt;p&gt;Thoughts, feedback?&lt;/p&gt; &lt;p&gt;Till next time,&lt;/p&gt; &lt;p&gt;[--- check out &lt;a href="http://www.dimecasts.net"&gt;www.dimecasts.net&lt;/a&gt; ---]&lt;/p&gt;&lt;img src="http://devlicious.com/aggbug.aspx?PostID=43348" width="1" height="1"&gt;</content><author><name>Dwhittaker</name><uri>http://devlicious.com/members/Dwhittaker.aspx</uri></author><category term="Development" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/Development/default.aspx" /><category term="Rhino Mocks" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/Rhino+Mocks/default.aspx" /><category term="Opinion" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/Opinion/default.aspx" /><category term="Moq" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/Moq/default.aspx" /></entry><entry><title>Pulling all instances for a base type out of StructureMap</title><link rel="alternate" type="text/html" href="http://devlicious.com/blogs/derik_whittaker/archive/2008/12/05/pulling-all-instances-for-a-base-type-of-structuremap.aspx" /><id>http://devlicious.com/blogs/derik_whittaker/archive/2008/12/05/pulling-all-instances-for-a-base-type-of-structuremap.aspx</id><published>2008-12-05T13:31:53Z</published><updated>2008-12-05T13:31:53Z</updated><content type="html">&lt;p&gt;*** There may be a better way to do this with StructureMap, but this is the way I was able to get this to work ***&lt;/p&gt; &lt;p&gt;Today I decided I wanted to move all my route mapping for Dimecasts out of the Global.asax file and into each of the various Controllers.&amp;nbsp; I wanted to do this for&amp;nbsp; two reasons.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;I was starting to build quite a list of custom route mappings  &lt;li&gt;I have decided that since routes map to a specific controller (in many cases, not all) the controller should be responsible for mapping its own routes&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;When I first decided that I wanted to perform this I tried to think of the various ways that I could accomplish allowing each controller register their own routes.&amp;nbsp; I was able to come up with 3 possible ways to achive this goal.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Hard code the registration for each controller in my Global.asax file.&lt;br /&gt;This method is by far the simplest and would have gotten me to my end point the fastest, but it is simply too my friction in the long run.&amp;nbsp; I did not want to have to remember to add the register logic for each new controller that I added to the site.&amp;nbsp; &lt;br /&gt;&lt;br /&gt;So, in the end this is a non-option.&lt;br /&gt;&lt;br /&gt; &lt;li&gt;Use reflection to find all the instances of my base controller and invoke the register logic.&lt;br /&gt;Using reflection seemed like an easy enough route.&amp;nbsp; In a few simple lines of code I could grab all the correct types and call invoke member.&lt;br /&gt;&lt;br /&gt;&lt;pre class="c-sharp" name="code"&gt;
// Please note, this code has NOT been tested or used so it may not be 100% correct
var controllers = Assembly.GetExecutingAssembly().GetTypes().
		Where( x =&amp;gt; typeof( BaseController ).IsAssignableFrom( x ) );

foreach ( Type type in controllers )
{
	type.InvokeMember(&amp;quot;RegisterRoutes&amp;quot;, BindingFlags.InvokeMethod, 
			Type.DefaultBinder, type, new object[] { routes });
}
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;However, in the long run this would not work either because I do not have any default, empty constructors on my controllers (hey, I am using IoC remember) so I would not be able to create an instance of each controller without massive amount of setup work.&lt;br /&gt;&lt;br /&gt;
&lt;li&gt;Use my IoC container (StructureMap) to get all instances and perform the register logic.&lt;br /&gt;Using my IoC container ended up being the direction I decided to go.&amp;nbsp; This method allowed me to get around the short coming of both options 1 and 2, and I could accomplish the task in a few lines of code.&lt;br /&gt;&lt;br /&gt;&lt;pre class="c-sharp" name="code"&gt;
// Here I am going to pull out all registered plugins that are of type BaseController 
// BaseController is my controller I base off Controllers off of
var controllerInstances = ObjectFactory.Model.
	PluginTypes.Where(x =&amp;gt; typeof(BaseController).IsAssignableFrom(x.PluginType));

foreach (var controllerInstance in controllerInstances)
{
	var instance = (BaseController)ObjectFactory.GetInstance(controllerInstance.PluginType);
        instance.RegisterRoutes(RouteTable.Routes);
}
&lt;/pre&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;As you can see, using StructureMap to grab all instances based on a given type is pretty simple and pretty straight forward.&amp;nbsp; I was pretty happy because it took me longer to create this post then it did to get this logic up and running in the application.&lt;/p&gt;
&lt;p&gt;Till next time,&lt;/p&gt;
&lt;p&gt;&lt;font color="#808080"&gt;[ --- Remember to check out &lt;/font&gt;&lt;a href="http://www.dimecasts.net/"&gt;&lt;font color="#808080"&gt;Dimecasts.net&lt;/font&gt;&lt;/a&gt;&lt;font color="#808080"&gt; ---]&lt;/font&gt;&lt;/p&gt;&lt;img src="http://devlicious.com/aggbug.aspx?PostID=43321" width="1" height="1"&gt;</content><author><name>Dwhittaker</name><uri>http://devlicious.com/members/Dwhittaker.aspx</uri></author><category term="Development" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/Development/default.aspx" /><category term="StructureMap" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/StructureMap/default.aspx" /><category term="HowTo" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/HowTo/default.aspx" /><category term="ASP.Net MVC" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/ASP.Net+MVC/default.aspx" /></entry><entry><title>Using ReCaptcha with Asp.Net MVC</title><link rel="alternate" type="text/html" href="http://devlicious.com/blogs/derik_whittaker/archive/2008/12/02/using-recaptcha-with-asp-net-mvc.aspx" /><id>http://devlicious.com/blogs/derik_whittaker/archive/2008/12/02/using-recaptcha-with-asp-net-mvc.aspx</id><published>2008-12-02T14:09:31Z</published><updated>2008-12-02T14:09:31Z</updated><content type="html">&lt;p&gt;For all the debate regarding if Captcha&amp;#39;s are a good thing or a bad thing one thing is certain (in my book).&amp;nbsp; If you do not have some way to stop spam-bots your site will become overridden with junk in a hurry.&lt;/p&gt; &lt;p&gt;In an effort to reduce the amount of spam comments I am getting over at &lt;a href="http://www.dimecasts.net/"&gt;Dimecasts.net&lt;/a&gt; I finally got off my lazy ass and worked on implementing a Captcha.&amp;nbsp; The solution I ended up going with was &lt;a href="http://recaptcha.net/"&gt;reCaptcha&lt;/a&gt;.&amp;nbsp; I found that their setup was very easy to use and worked right out of the box.&amp;nbsp; However, there was not a lot of information on the net on how to use reCaptcha within an MVC site, only Asp.Net Webforms.&amp;nbsp; So I thought I would share my experiences and explain how I implemented reCaptcha on Dimecasts.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Step 1 - Signup for and download the reCaptcha dll from their site&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Step 2 - Add reference to the Recaptcha.dll to your project&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Step 3 - Create an Action Filter to handle the Captcha validation&lt;/strong&gt; &lt;pre class="c-sharp" name="code"&gt;public class CaptchaValidatorAttribute : ActionFilterAttribute 
{
	private const string CHALLENGE_FIELD_KEY = &amp;quot;recaptcha_challenge_field&amp;quot;;
        private const string RESPONSE_FIELD_KEY = &amp;quot;recaptcha_response_field&amp;quot;;
        
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var captchaChallengeValue = filterContext.HttpContext.Request.Form[CHALLENGE_FIELD_KEY];
            var captchaResponseValue = filterContext.HttpContext.Request.Form[RESPONSE_FIELD_KEY];
            var captchaValidtor = new Recaptcha.RecaptchaValidator
                                      {
                                          PrivateKey = -- PUT PRIVATE KEY HERE --,
                                          RemoteIP = filterContext.HttpContext.Request.UserHostAddress,
                                          Challenge = captchaChallengeValue,
                                          Response = captchaResponseValue
                                      };

            var recaptchaResponse = captchaValidtor.Validate();

	    // this will push the result value into a parameter in our Action
            filterContext.ActionParameters[&amp;quot;captchaValid&amp;quot;] = recaptchaResponse.IsValid;

            base.OnActionExecuting(filterContext);
        }
}
&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Step 4 - Implement the Controller Action that will handle the form submission and Captcha validation&lt;/strong&gt;&lt;br /&gt;&lt;pre class="c-sharp" name="code"&gt;[CaptchaValidator]
[AcceptVerbs( HttpVerbs.Post )]
public ActionResult CreateComment( Int32 id, bool captchaValid )
{
.. Do something here
}
&lt;/pre&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 5 - Create a Html Helper to build and render the Captcha control&lt;/strong&gt; &lt;pre class="c-sharp" name="code"&gt;      
public static string GenerateCaptcha( this HtmlHelper helper )
{
            
	var captchaControl = new Recaptcha.RecaptchaControl
        	{
	                ID = &amp;quot;recaptcha&amp;quot;,
                	Theme = &amp;quot;blackglass&amp;quot;,
        		PublicKey = -- Put Public Key Here --,
                        PrivateKey = -- Put Private Key Here --
		};

	var htmlWriter = new HtmlTextWriter( new StringWriter() );

	captchaControl.RenderControl(htmlWriter);

	return htmlWriter.InnerWriter.ToString();
}
&lt;/pre&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 6 - Implement the logic in your view to actually render the Captcha control&lt;/strong&gt;&lt;br /&gt;&lt;pre class="c-sharp" name="code"&gt;&amp;lt;:%= Html.GenerateCaptcha() %&amp;gt;:
&lt;/pre&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 7 - Oh wait, there is no step 7.&amp;nbsp; You are done.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;There you go, that is all that is needed to setup reCaptcha for use in a MVC application&lt;/p&gt;
&lt;p&gt;Till next time,&lt;/p&gt;
&lt;p&gt;[ --- Remember to check out &lt;a href="http://www.dimecasts.net/"&gt;Dimecasts.net&lt;/a&gt; --- ]&lt;/p&gt;&lt;pre&gt;&lt;/pre&gt;&lt;pre&gt;&lt;/pre&gt;&lt;img src="http://devlicious.com/aggbug.aspx?PostID=43271" width="1" height="1"&gt;</content><author><name>Dwhittaker</name><uri>http://devlicious.com/members/Dwhittaker.aspx</uri></author><category term="asp.net" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/asp.net/default.aspx" /><category term="HowTo" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/HowTo/default.aspx" /><category term="ASP.Net MVC" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/ASP.Net+MVC/default.aspx" /></entry><entry><title>"Operation could destabilize the runtime" from Casting from Concrete to Interfaces with Linq</title><link rel="alternate" type="text/html" href="http://devlicious.com/blogs/derik_whittaker/archive/2008/11/29/quot-operation-could-destabilize-the-runtime-quot-from-casting-from-concrete-to-interfaces-with-linq.aspx" /><id>http://devlicious.com/blogs/derik_whittaker/archive/2008/11/29/quot-operation-could-destabilize-the-runtime-quot-from-casting-from-concrete-to-interfaces-with-linq.aspx</id><published>2008-11-29T16:19:43Z</published><updated>2008-11-29T16:19:43Z</updated><content type="html">&lt;p&gt;In all my years of doing .Net I have to say that I finally came across the exception message that takes the cake.&amp;nbsp; Today while trying to do some refactoring on the &lt;a href="http://www.dimecasts.net/"&gt;DimeCasts.net&lt;/a&gt; code base I received this exception.&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;Operation could destabilize the runtime&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;I received the error while trying to update some Linq-2-Sql code that where I was trying to return the data as IList&amp;lt;IDownloadInformation&amp;gt; (yes I killed the delayed execution).&amp;nbsp; Below is the code that caused the exception&lt;/p&gt;&lt;pre class="c-sharp" name="code"&gt;public IList&amp;lt;IDownloadInformation&amp;gt; FetchEpisodeDownloads( Int32 episodeID )
{
	var result = ( from d in DBContextInstance().EpisodeDownloadInformations
        	where d.EpisodeID == episodeID
		select (IDownloadInformation)new DownloadInformation()
                	{
                        DownloadID = d.ID,
                        EpisodeID = d.EpisodeID,
                        ...
                        
                       	);

	return (IList&amp;lt;IDownloadInformation&amp;gt;) result.ToList();
}
&lt;/pre&gt;
&lt;p&gt;Turns out the above code works, mostly.&amp;nbsp; Everything is fine until I went to cast the return results.&amp;nbsp; It was then I received the nice exception.&lt;/p&gt;
&lt;p&gt;As soon as I found the error I hit Google for some help. I was able to find this &lt;a href="http://netindonesia.net/blogs/jimmy/archive/2008/09/22/operation-could-destabilize-the-runtime.aspx"&gt;post&lt;/a&gt; which helped to point me in the right direction.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;After taking a look at my code again, I was able to get the code below to work (this time I decided to use IQueryable so I could get the delayed execution.&lt;/p&gt;&lt;pre class="c-sharp" name="code"&gt;        
public IQueryable&amp;lt;IDownloadInformation&amp;gt; FetchEpisodeDownloads( Int32 episodeID )
{
	var result = ( from d in DBContextInstance().EpisodeDownloadInformations
        	where d.EpisodeID == episodeID
                	select (IDownloadInformation)new DownloadInformation()
                        {
                        	DownloadID = d.ID,
                                EpisodeID = d.EpisodeID,
                                ..                                 
			}
			);

	return result.OfType&amp;lt;IDownloadInformation&amp;gt;();
}
&lt;/pre&gt;
&lt;p&gt;Using the built in OfType support to cast your return value back to the interface seemed to work and it is pretty clean and simple.&amp;nbsp; What is funny about the actual exception that was thrown is that it makes no sense and really does not lead you to the problem.&amp;nbsp; Gotta love Google :)&lt;/p&gt;
&lt;p&gt;Hope this helps.&lt;/p&gt;
&lt;p&gt;Till next time,&lt;/p&gt;
&lt;p&gt;&lt;font color="#808080"&gt;[--- Check out &lt;/font&gt;&lt;a href="http://www.Dimecasts.net"&gt;&lt;font color="#808080"&gt;www.Dimecasts.net&lt;/font&gt;&lt;/a&gt;&lt;font color="#808080"&gt; ---]&lt;/font&gt;&lt;/p&gt;&lt;img src="http://devlicious.com/aggbug.aspx?PostID=43251" width="1" height="1"&gt;</content><author><name>Dwhittaker</name><uri>http://devlicious.com/members/Dwhittaker.aspx</uri></author><category term="Development" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/Development/default.aspx" /><category term="HowTo" scheme="http://devlicious.com/blogs/derik_whittaker/archive/tags/HowTo/default.aspx" /></entry></feed>