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

<channel>
	<title>Elegant Code &#187; Microsoft</title>
	<atom:link href="http://elegantcode.com/category/microsoft/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Buy Quinine Without Prescription</title>
		<link>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=awarded-microsoft-community-contributor-award-2012</link>
		<comments>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 23:03:17 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[awards]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/</guid>
		<description><![CDATA[Buy Quinine Without Prescription, Today I received an email informing me that I have been awarded the Microsoft Community Contributor Award.&#160; This is the second time I have been awarded this particular award and it feels just as good this time as it did last time.&#160; I’m not sure how you go about getting nominated [...]]]></description>
			<content:encoded><![CDATA[<p> <p> <b>Buy Quinine Without Prescription</b>, Today I received an email informing me that I have been awarded the Microsoft Community Contributor Award.&#160; This is the second time I have been awarded this particular award and it feels just as good this time as it did last time.&#160; I’m not sure how you go about getting nominated for this award, but apparently I am doing something right.</p>  <p>I would like to thank whoever nominated me for this award and Microsoft for listening to that person.&#160; I would most of all like to thank the community.&#160; Without the support of the community I would probably still be a cop. Oh, <b>australia, uk, us, usa</b>, <b>Discount Quinine</b>, you probably didn’t know that about me.</p>  <p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="Brian Lagunas awarded Microsoft Community Contributor Award" border="0" alt="Brian Lagunas awarded Microsoft Community Contributor Award" src="http://elegantcode.com/wp-content/uploads/2012/03/MCC12_Logo_Horizontal_Full-color.jpg" width="500" height="202" /></p>.  Quinine pharmacy.  Herbal Quinine.  Order Quinine no prescription.  What is Quinine.  Buy Quinine online cod.  Quinine street price.  Quinine use.  Effects of Quinine.  Buy Quinine online no prescription.  Is Quinine safe.  Where can i cheapest Quinine online.  Order Quinine online overnight delivery no prescription.  Where to buy Quinine.  Quinine duration.  Quinine from canada.  Fast shipping Quinine.  After Quinine.  Quinine no prescription.  Quinine cost.  Quinine alternatives.  Quinine samples.  Buy Quinine from canada.  Buy Quinine no prescription.  Ordering Quinine online.  Quinine mg.  Quinine dangers.  Where can i buy Quinine online.  Purchase Quinine online.  Quinine maximum dosage.  Buy Quinine online cod.  Rx free Quinine.  Order Quinine from United States pharmacy.  Buy generic Quinine.  No prescription Quinine online.  Quinine australia, uk, us, usa.  Quinine overnight.  Buy Quinine without a prescription.  Quinine online cod.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4728'>Ventolin For Sale</a>. <a href='http://elegantcode.com/?p=4184'>Synthroid For Sale</a>. <a href='http://elegantcode.com/?p=4384'>Buy Ultram Without Prescription</a>. <a href='http://elegantcode.com/?p=4373'>Topamax For Sale</a>. <a href='http://elegantcode.com/?p=5156'>Amoxicillin For Sale</a>. <a href='http://elegantcode.com/?p=4384'>Order Ultram online overnight delivery no prescription</a>. <a href='http://elegantcode.com/?p=4683'>Inderal schedule</a>. <a href='http://elegantcode.com/?p=4822'>About Hydrochlorothiazide</a>. <a href='http://elegantcode.com/?p=4728'>Ventolin australia, uk, us, usa</a>. <a href='http://elegantcode.com/?p=4694'>Human Growth Hormone interactions</a>.<br />
<b>Trackbacks from:</b> <a href='http://social-blend.com/?p=1163'>Buy Quinine Without Prescription</a>. <a href='http://www.quarterlives.com/?p=710'>Buy Quinine Without Prescription</a>. <a href='http://4realz.net/?p=1873'>Buy Quinine Without Prescription</a>. <a href='http://www.macneilbmx.com/blog/?p=6577'>Buy Quinine Without Prescription</a>. <a href='http://www.greatgreengoods.com/?p=2921'>Buy Quinine Without Prescription</a>. <a href='http://blog.farmland.org/?p=1913'>Online buy Quinine without a prescription</a>. <a href='http://reversemortgagedaily.com/?p=14688'>Is Quinine addictive</a>. <a href='http://linuxologist.com/?p=1495'>Quinine over the counter</a>. <a href='http://home.officesnapshots.com/?p=235'>Order Quinine from United States pharmacy</a>. <a href='http://evanrapoport.com/?p=720'>Generic Quinine</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Silverlight Profiling PowerShell helper.</title>
		<link>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=silverlight-profiling-powershell-helper</link>
		<comments>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/#comments</comments>
		<pubDate>Sat, 15 May 2010 16:47:22 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/</guid>
		<description><![CDATA[I was playing around with some Silverlight profiling the other night to see if I could find any obvious issues with my open source project StatLight and wound up writing a little script in PowerShell I hoped someone might find helpful. But I didn’t know you could profile a Silverlight app. I didn’t until I [...]]]></description>
			<content:encoded><![CDATA[<p>I was playing around with some Silverlight profiling the other night to see if I could find any obvious issues with my open source project <a href="http://statlight.net" target="_blank">StatLight</a> and wound up writing a little script in PowerShell I hoped someone might find helpful.</p>  <h4>But I didn’t know you could profile a Silverlight app.</h4>  <p>I didn’t until I started doing some digging online. Now, the Silverlight profiling story (at least from what I’ve seen/tried) is not near the easy of say <a href="http://www.red-gate.com/products/ants_performance_profiler/index.htm">Redgate ANTS Performance Profiler</a>. However, it’s do-able. (And with this helper script – hopefully a little simpler?)</p>  <h4>How can I profile a Silverlight Application?</h4>  <p>I would recommend you read the following blog, which explains one way of doing it very well.</p>  <p><a title="http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx" href="http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx">http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx</a></p>  <h4>So… what’s this script for?</h4>  <p>If you read the blog above, or have done this before, then you probably noticed that there was quite a series of commands you had to execute before you could wind up with a performance report. </p>  <p>I threw together a quick little PowerShell script in an attempt to automate smooth out the process.</p>  <h4>Hot do I use it?</h4>  <ol>   <li>Download the script &amp; save it somewhere. <a href="http://github.com/staxmanade/Scripts/blob/master/SilverlightProfiler.ps1"><strong>http://github.com/staxmanade/Scripts/blob/master/SilverlightProfiler.ps1</strong></a> </li>    <li>Open the PowerShell console. cd to the directory your xap/assemblies are stored.      <br />(EX: {myProject}\Bin\Debug\ ) </li>    <li>Execute:      <br />{pathToScript}\SilverlightProfiler.ps1 -urlPath &quot;{myProject}\Bin\Debug\TestPage.html&quot; </li>    <li>When your done profiling press enter to signal that your done.      <p></p> Once complete, it will print the location your profiling report was saved. You can then open it with Visual Studio.</li> </ol>  <h5>Couple of disclaimers.</h5>  <ul>   <li>Some paths are hard-coded to my x86 machine. </li>    <li>I had troubles running the built in visual studio .bat files (from powershell) that are supposed to set the environment variables. So I extracted out what vars I could find to make it work. </li>    <li>I’m not a profiling expert – just hacked this together to get it to work for me.</li> </ul>  <p>I hope this is useful, and if you know of a better way, I’m always interested in hearing your feedback.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tell me what you don&#8217;t like about TFS 2010</title>
		<link>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tell-me-what-you-dont-like-about-tfs-2010</link>
		<comments>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/#comments</comments>
		<pubDate>Sat, 15 May 2010 15:48:18 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Team System]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/</guid>
		<description><![CDATA[I know that a lot of people have had bad experiences with TFS over the years, and so does the TFS development team. The team at Microsoft is very intent on learning what it is that people find irritating, problematic, or difficult, and correcting it. Some major headway was made with the 2010 release of [...]]]></description>
			<content:encoded><![CDATA[<p>I know that a lot of people have had bad experiences with TFS over the years, and so does the TFS development team. The team at Microsoft is very intent on learning what it is that people find irritating, problematic, or difficult, and correcting it. Some major headway was made with the 2010 release of Team Foundation Server to make it easier to setup and administer, and also to improve the usability of several of its key features.</p>  <p>That said, there is still room for improvement and both the team and I understand there are still opportunities to improve. In all seriousness, the team at Microsoft wants to make TFS an approachable, no-brainer install decision for .NET teams, even small ones. This means they want to be able to compete for your attention with the likes of SVN, Git, Jira, Perforce, and anyone else making collaboration tools for developers.</p>  <p>The point of this post is for you to help me know what feedback I can give the TFS product development team as they look ahead to the next release of TFS. I am looking for legitimate feedback I can give the team on how to improve the TFS product.</p>  <p>Please bear in mind that I am interested in your feedback on TFS 2010, as TFS 2008 was improved upon 10 fold in the latest release. Also, I am not necessarily looking for feedback on Visual Studio, just the TFS side of the house. Please realize that the team who makes this product at Microsoft is just as committed and passionate about making great software as you are. They just really need your feedback to make the thing you want. In fact, they want to make a tool that every developer loves to use. Really. So what needs to change to make that the case?</p>  <p>Recall that TFS functionality is broken into the following major areas and I am looking for feedback on the 2010 version.</p>  <ul>   <li>Version Control </li>    <li>Work Item management </li>    <li>Team Foundation Build </li>    <li>SharePoint integration (optional) </li>    <li>Reporting and SSRS Integration (optional) </li> </ul>  <p>Thanks for anything you have. Thank you also for being respectful and not making this a bash-fest.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>Visual Studio: Open in Full XAML View by Default</title>
		<link>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=visual-studio-open-in-full-xaml-view-by-default</link>
		<comments>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 15:49:14 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/</guid>
		<description><![CDATA[So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane [...]]]></description>
			<content:encoded><![CDATA[<p>So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane blows.&#160; So now I have to sit and wait for VS to render my view in the preview pane, and sometimes it can take a while, if it doesn’t just completely crash.&#160; Sometimes I take the extra time to go grab a snack and beverage of my choice.&#160; </p>  <p>So here is a hidden performance increasing jewel you might find useful.&#160; We can set the default open mode to be in full XAML view.</p>  <p>First thing you need to do is in Visual Studio go to your Tools ==&gt; Options ==&gt; Text Editor ==&gt; XAML ==&gt; Miscellaneous.&#160; There you will see an option for “Always open documents in full XAML view”.&#160; Check that box.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/04/image.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="xaml options for opening in full xaml view" border="0" alt="xaml options for opening in full xaml view" src="http://elegantcode.com/wp-content/uploads/2010/04/image_thumb.png" width="244" height="146" /></a> </p>  <p>Now every time you open a XAML file it will open in full XAML view and give you one less thing to gripe about.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Looking Ahead to 2010</title>
		<link>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=looking-ahead-to-2010</link>
		<comments>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 21:02:11 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/02/09/looking-ahead-to-2010/</guid>
		<description><![CDATA[No, this isn't another prognostication post foretelling the woes of the world for the next year. This is a note to everyone who hasn't yet played with the Visual Studio ALM tools and Team Foundation Server 2010. Folks, this product is getting better. That stands to reason. After all, this is basically version 3 of [...]]]></description>
			<content:encoded><![CDATA[<p><img align="left" src="http://elegantcode.com/wp-content/uploads/2010/02/020910_2101_LookingAhea13.png" alt=""/>No, this isn't another prognostication post foretelling the woes of the world for the next year. This is a note to everyone who hasn't yet played with the Visual Studio ALM tools and Team Foundation Server 2010.
</p><p>Folks, this product is getting better. That stands to reason. After all, this is basically version 3 of the product and you know what they say! Version 3 is the one to buy. Most of the kinks are worked out now.
</p><p>Now, I won't pretend for a moment that Team Foundation Server hasn't had its challenges fitting in with agile teams. I think that has come from a history of development by a team that itself was learning and growing just like the rest of us. Now that many of the teams within Microsoft are practicing some form of iterative development with completed cycles of "all the way done", we are starting to see the influence in the tools they are producing. And the effect is not half bad.
</p><p>I have been using Visual Studio 2010 for a few months now, and with the recent release of the RC, I can see:
</p><ol><li>Performance is getting better (XAML).
</li><li>Features are getting more solid (fewer exceptions)
</li><li>The polish of the overall user experience is becoming a great example of an application I am happy to look at all day long.
</li><li>The Team Foundation Server features being added are consistent with what we are learning to be effective as an agile community.
</li></ol><p>So, where's the meat? What are these shiny features of which you speak, Mr. Starr? Well, here is a short sample because I am sitting in an airport listening to the chaos and I can't think of it all. 
</p><p>I should also say that this is a very small list of features that I personally am really excited about. The rest of the world probably has other things they care about. These are mine because I believe they have to potential to really change life on a team for the better.
</p><h2>Layer Diagrams
</h2><p>There is a major focus in this release to add UML support to Visual Studio Ultimate. OK, not a huge fan and I know some people will dog on this feature, but I am all about the Layer Diagrams. These are diagrams that we can create just like the UML diagrams that Visual Studio now supports, but the value of a Layer Diagram is that it has teeth and can bite back. 
</p><p>Here's how it works:
</p><ol><li>Create a Layer Diagram.
</li><li>Draw your favorite design pattern or desired architectural separation model using tools in the Toolbox. In a simple example, this might be to create a model of the MVP pattern. In a large example this model might show the multiple layers in my solution that uses CSLA, Silverlight with MVVM, WCF, and Entity Framework. (Hi, Scott <span style="font-family:Wingdings">J</span> You knew that was for you.)
</li><li>Add some things to it from your solution. Drop things onto the diagram and into the boxes like classes, namespaces, and Visual Studio projects.
</li><li>Now you can generate dependencies between these things and see the existing relationships. Yawn. Cool, but we get this with dependency diagrams, too.
</li><li><div>Validate the model.<br/><br/>Wait for it. . .  Grok it. . .
</div><p><br/>You got it! Yeah, that's right. Validate the LOGICAL model of your application. This is so sweet it comes on a stick. This means that not only can I verify I haven't violated my design with a bad reference or super egregious abstraction hole, but I can make this validation part of the build process and catch it if I accidently violate my own design later. Where I come from, they call that cool.
</p></li></ol><h2>Way Better Work Items
</h2><p>This is non-trivial for teams who live every day of their lives in Team Foundation Server to manage their requirements and work queues. Sure, we might all prefer note cards on the wall, but for many this is simply not possible. And for those folks who use Team Foundation Server to manage their notecards, there are some great new things to make that task easier.
</p><ol><li>Hierarchical relationships between Work Items.
</li><li>Agile planning Workbooks.
</li><li>Seamless Team Project Dashboards.
</li><li>MSF Agile 5.
</li></ol><h2>Gated Check In
</h2><p>This is a feature of Team Foundation Build that will actually build and test your software before a check-in is committed to Source Control. The mechanical effect of this is simple: Code that would break the build is never committed to Source Control. The implications are far larger, though. Think it through for a moment. What would change in your daily life if you flat out were unable to commit code that breaks the build? The short answer is, "Quality goes up." I bit more verbose answer is that I need to be more careful before committing my code.
</p><p>Yes, I know other vendors have had this feature for a while. So what? So, Team Foundation Server shouldn't have it too? It rocks and now we get it in Team Foundation Build.
</p><h2>IntelliTrace
</h2><p>I am not even sure how cool this is yet, only that it is. This feature is also known as Historical Debugging and gives the ability to step back and forth through call stacks and watched variables during a debug run. To be clear, that's <em>Back and Forth through time</em>. So, the first time I hit the breakpoint, here was the status of the code. The second time it was this. And so on. Also, I can inspect all this data on system events (like CLR events) and can therefore tap into my app at a lot of different levels.
</p><p>Now, I know that you don't need debuggers anymore because every line of code we write is Test Driven and that means we don't need debuggers, right? Yeah, sure you never need a debugger. As I said, this is just a wicked tool, but I am not yet sure how wicked. The community will definitely ferret that out over time.
</p><h2>Other Stuff
</h2><p>This only scratches the surface of what's in Visual Studio and Team Foundation Server 2010. There are a lot more things, many of them bigger and higher profile than the things I mentioned. I just happen to be in love with these particular features at the moment. As I get deeper into things, I will let you know what I see.
</p><p>One last thing, I know these tools get a lot of flak in some communities, but I feel comfortable with them. I also understand that many developers out there in the world don't get to choose their tools. Often tools are assigned. What I see is that the 2010 versions of Visual Studio and Team Foundation Server really have raised the bar. I don't feel like teams are still having to compromise on tooling to get everything they need in an integrated environment.
</p><p>Will I still run R#? Well, yeah.
</p><p>
 </p><p>
 </p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Powershell: Load assembly without locking file.</title>
		<link>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-load-assembly-without-locking-file</link>
		<comments>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 05:40:23 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/</guid>
		<description><![CDATA[I have a set of PowerShell build scripts and ran into a case where I needed to load an assembly (to get the assembly’s version) and still (at a later time) work with the assembly file on disk. A typical way to load an assembly within PowerShell is to use the Assembly.LoadFrom(filePath) # Powershell [System.Reflection.Assembly]::LoadFrom($assemblyPath) [...]]]></description>
			<content:encoded><![CDATA[<p>I have a set of PowerShell build scripts and ran into a case where I needed to load an assembly (to get the assembly’s version) and still (at a later time) work with the assembly file on disk.</p>  <p>A typical way to load an assembly within PowerShell is to use the Assembly.LoadFrom(filePath)</p>  <blockquote>   <p># Powershell</p>    <p>[System.Reflection.Assembly]::LoadFrom($assemblyPath)</p> </blockquote>  <p><a href="http://elegantcode.com/wp-content/uploads/2009/12/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2009/12/image_thumb9.png" width="690" height="391" /></a> </p>  <p>Except the problem with this (in my case) was it would <strong>lock the file for the lifespan of the PowerShell console instance</strong>. I didn’t want to have to close and re-open the PowerShell console every time I need to run a build so there had to be a work-around for this.</p>  <p>After searching the web for a solution, I couldn’t find anything that was “easy” and worth the effort to get it to work.</p>  <blockquote>   <p>EX: One solution was to create a new AppDomain, do the necessary work and the close the AppDomain which would release the lock on the file.</p>    <p>I’ve never done this myself, and even thought there is example code out there to get this accomplished, it just seemed over the top for what I was trying to do, and back to my previous criteria it wasn’t “worth the effort to get it to work”</p> </blockquote>  <p>Then I remembered in a previous life I used an overload that took an array of bytes to load the an assembly.</p>  <blockquote>   <p>[System.Reflection.Assembly]::Load($assemblyBytes)</p> </blockquote>  <p>After spiking it in PowerShell with the below test. I was quite happy with the solution, so I thought I’d throw it out there.</p>  <p>Just stream the assembly from disk into a byte array manually, and call assembly load from there.</p>  <p>Here’s my test case which shows that the file is not locked after it was loaded into the PowerShell runtime</p>  <pre>$file = &quot;.\Moq.dll&quot;
$tempFileName = &quot;.\Moq-Renamed.dll&quot;

$fileStream = ([System.IO.FileInfo] (Get-Item $file)).OpenRead();
$assemblyBytes = new-object byte[] $fileStream.Length
$fileStream.Read($assemblyBytes, 0, $fileStream.Length);
$fileStream.Close();

$assemblyLoaded = [System.Reflection.Assembly]::Load($assemblyBytes);

# notice that we can move the file on disk after 
# it's loaded into the powershell runtime
Move-Item $file $tempFileName
Move-Item $tempFileName $file 

# and display the assembly information to show we still have it in memory
echo $assemblyLoaded</pre>

<p>After that test passed, and the main reason I wanted to do this, I wrote the “get-assembly-version” PowerShell function.</p>

<pre><strike>function get-assembly-version() {
    param([string] $file)
    
    # load the assembly bytes quickly - as to not lock the file for too long
    $fileStream = ([System.IO.FileInfo] (Get-Item $file)).OpenRead()
    $assemblyBytes = new-object byte[] $fileStream.Length
    $fileStream.Read($assemblyBytes, 0, $fileStream.Length) | Out-Null #out null this because this function should only return the version &amp; this call was outputting some garbage number
    $fileStream.Close()
    
    # return the version of the assembly
    [System.Reflection.Assembly]::Load($assemblyBytes).GetName().Version;
}

$version = get-assembly-version(&quot;.\Moq.dll&quot;)

echo &quot;Loaded v$($version.Major).$($version.Minor).$($version.Build).$($version.Revision) version of $file&quot;</strike></pre>
Hope this helps someone out there! 

<p></p>

<p>&#160;</p>

<p><strong>UPDATE:</strong></p>

<p><a href="http://achuebrigens.wordpress.com">Martin</a> commented below on a much better solution to the assembly version info problem. Amazing how complicated we can make things if we don’t know the path.</p>

<pre>
function get-assembly-version() {
    param([string] $file)
    
    $version = [System.Reflection.AssemblyName]::GetAssemblyName($file).Version;
    
    #format the version and output it...
    $version
}</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Removing WSUS</title>
		<link>http://elegantcode.com/2009/12/01/removing-wsus/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=removing-wsus</link>
		<comments>http://elegantcode.com/2009/12/01/removing-wsus/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 21:53:49 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[WSUS]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/01/removing-wsus/</guid>
		<description><![CDATA[A while back, the company I work for experimented with setting up a Windows Server Update Service (WSUS).&#160; The idea is that you have one server that goes out and downloads all of the hotfixes, service packs, and so on for your network – then each of your client machines goes directly to the local [...]]]></description>
			<content:encoded><![CDATA[<p>A while back, the company I work for experimented with setting up a Windows Server Update Service (WSUS).&#160; The idea is that you have one server that goes out and downloads all of the hotfixes, service packs, and so on for your network – then each of your client machines goes directly to the local WSUS server to get the weekly dose of patches, configurable by various group policies, and with monitoring to make sure that everything is going smoothly.&#160; At the time we set it up, we were having crushing bandwidth problems – two servers downloading a service pack would pretty much disable the building…</p>  <p>Over time, the bandwidth problems were fixed, and as sometimes happens the WSUS server crumbled to dust.&#160; For the most part nobody noticed – new servers and clients were not configured with the WSUS policy, downloading their hotfixes direct from Microsoft through plentiful bandwidth.&#160; Unfortunately, older server and clients were left in the dark, sending cries out to a WSUS URL that will never respond...&#160; oops</p>  <h4>To Fix (and get your automatic updates to work again):</h4>  <p>Delete the registry key at “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate”.&#160; For fun, restart the “Windows Update” service (not sure if this is necessary).&#160; </p>  <p>I found <a href="http://www.d.umn.edu/itss/security/sus/" target="_blank">this VBS file</a> to be useful in figuring out if a server was still trying to use an old WSUS install, or if the problem was group-policy related.&#160; </p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/01/removing-wsus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PDC Notes</title>
		<link>http://elegantcode.com/2009/11/17/pdc-notes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pdc-notes</link>
		<comments>http://elegantcode.com/2009/11/17/pdc-notes/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 17:23:30 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/17/pdc-notes/</guid>
		<description><![CDATA[I am grateful to INETA to be attending PDC this year. Also, I grateful to Visual Stuart, who is letting me crash in his room. Turns out, I am a cheap skate :) I am sitting in the keynote on Tuesday and thinking about the week. In addition to the Wait? What the… Wordpress moving [...]]]></description>
			<content:encoded><![CDATA[<p>I am grateful to INETA to be attending <a href="http://microsoftpdc.com">PDC</a> this year. Also, I grateful to <a href="http://visualstuart.com">Visual Stuart</a>, who is letting me crash in his room. Turns out, I am a cheap skate :)</p>  <p>I am sitting in the keynote on Tuesday and thinking about the week. In addition to the </p>  <blockquote>   <p><font style="background-color: #ffffff">Wait? What the… Wordpress moving into the Azure cloud? Sweet!</font></p> </blockquote>  <p>volunteer sessions I am doing for INETA, I am hosting a Birds of a Feather session with Mike Vincent. Our BOF is this afternoon and is entitled, “Agile Tales of Triumph, Tribulation, Tools, and Teams”. Drop by and join the discussion to learn </p>  <blockquote>   <p><font style="background-color: #ffffff">Code name Dallas: A uniform way to access data in the cloud and mash it all up.</font></p> </blockquote>  <p>and share what really works.</p>  <p>It has been very cool to meet many of the Pluralsight instructors for the first time. We all live in different parts of the world, and PDC provides that opportunity for us to </p>  <blockquote>   <p>Everyone get your 3D glasses on! Oh, that was very anti-climactic.</p> </blockquote>  <p>all actually shake physical hands rather than electronic ones.</p>  <p>Also, drop by the Pluralsight booth and share your developer stories with me. Here’s the sneak peek as to why: <font style="background-color: #ffffff"><a href="http://www.pluralsight.com/main/pluralcast/default.aspx">Pluralcast</a>. More on that in another post. Suffice </font></p>  <blockquote>   <p><font style="background-color: #ffffff">I think that guy onstage is showing an iPhone and talking about how easy it was to write an app for it. Weird.</font></p> </blockquote>  <p><font style="background-color: #ffffff">to say </font>there will be some changes in the Elegant Code Cast.</p>  <blockquote>   <p>Did he just say, “Create applications for the good of the republic?” Seriously?</p> </blockquote>  <p>Lastly, if you see me running around the halls, please stop me and say, Hello.” It’s very cool to be able to meet people I usually only get to chat with online. If you are looking for a <a href="http://guild3.com">great developer team</a> to build your next big thing, we can talk about that, too!</p>  <blockquote>   <p>Please stop saying “3 screens in the cloud.”</p> </blockquote>  <p>Ray Ozzie final points from the keynote:</p>  <ol>   <li>Bet your next user experience on Windows 7</li>    <li>When thinking of the cloud, bet on Azure.</li>    <li>Take a moment to think about how the world is changing and the potential role of cloud in that world.</li> </ol>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/17/pdc-notes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>StructureMap and SharePoint</title>
		<link>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=structuremap-and-sharepoint</link>
		<comments>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 18:00:22 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[StructureMap]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/</guid>
		<description><![CDATA[I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; </p>  <p>I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user is authorized to use.&#160; The source of this data (names, URLs, etc.) comes from an external-to-SharePoint system, accessed through another C# assembly.&#160; Once the web part gets the data there is some more processing to be done – we need to do more than just blindly display a list of URLs.&#160; Rather than get into details I’m just going to do some handwaving here and say that “if you have access to X, then {stuff happens}, or if you have access to Y then {other stuff happens}.”&#160; You know, business logic, stuff that is good to test.</p>  <p>the first thing I need to do is get business logic out of the WebPart and into something that I can write without having to reset AppPools over and over, not to mention have some unit tests to verify I’m going in the right direction.&#160; So, I created a standard application service class which has a dependency on the external authorization system, via constructor injection.&#160; </p>  <pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> AuthorizedAppsService : IAuthorizedAppsService
{
  <span class="kwrd">private</span> <span class="kwrd">readonly</span> ExternalAuthorizeService authService;

  <span class="kwrd">public</span> AuthorizedAppsService(
    ExternalAuthorizeService authService) 
  {
    <span class="kwrd">this</span>.authService = authService;
  }

  <span class="kwrd">public</span> AuthorizedApplications GetAuthorizedApplications(
                                  <span class="kwrd">string</span> userName)
  {
    var allApps = authService.AuthorizedApplications(userName);
    <span class="rem">// business logic stuff happens here</span>
    <span class="kwrd">return</span> thoseResultsWeJustFiguredOut;
  }
}</pre>

<p>Next, I created a StructureMap Registry class to scan my assemblies, as well as adding in the details of how to create this external authorize service, using the typical method: <style type="text/css">




.csharpcode, .csharpcode pre
{
	font-size: x-small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style></p>

<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyRegistry : Registry
{
  <span class="kwrd">public</span> MyRegistry()
  {
    Scan(scanner =&gt; {
      scanner.TheCallingAssembly();
      scanner.AssemblyContainingType(<span class="kwrd">typeof</span>(MyRegistry));
      scanner.WithDefaultConventions();
      });

    ForRequestedType&lt;ExternalAuthorizeService&gt;()
      .AsSingletons()
      .TheDefault.Is.ConstructedBy(c =&gt; Provider.GetService());

    <span class="rem">// other dependency configuration...</span>
  }
  <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> InitializeForSharepoint()
  {
    ObjectFactory.Initialize(init =&gt; init.AddRegistry&lt;MyRegistry&gt;());
    ObjectFactory.AssertConfigurationIsValid();
  }
}</pre>

<p>And then, what remains is to have SharePoint call my StructureMap initialization when my SharePoint application starts up.&#160; In an MVC or WebForms app, I’d just add code to the appropriate place in Global.asax.cs, but in SharePointLand, this is looked down on.&#160; Instead, the preferred mechanism seems to be to use an HttpModule and a FeatureReceiver to plug the Module into the app’s web.config.</p>

<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyStartupModule : IHttpModule
{
  <span class="kwrd">public</span> <span class="kwrd">void</span> Init(HttpApplication context)
  {
        ConfigureOtherStuff();
        MyRegistry.InitializeForSharepoint();
  }
  <span class="kwrd">public</span> <span class="kwrd">void</span> Dispose() { }
}</pre>

<p>And then the FeatureReceiver to alter the app’s Web.Config looks something like this (note I borrowed most of this code from another sample SharePoint project:</p>

<p>&#160;</p>

<pre class="csharpcode"><span class="rem">//</span>
<span class="rem">// this is borrowing heavily from http://www.codeplex.com/SPAXO</span>
<span class="rem">// </span>
<span class="kwrd">public</span> <span class="kwrd">class</span> StartupFeatureReceiver : SPFeatureReceiver
{
  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureActivated(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    AddWebConfigEntry(webApp);
    UpdateApp(webApp);
  }

  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureDeactivating(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    RemoveWebConfigEntry(webApp);
    UpdateApp(webApp);
  }


  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> AddWebConfigEntry(SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    var existingModifications = 
             <span class="kwrd">new</span> List&lt;SPWebConfigModification&gt;(
                      webApp.WebConfigModifications);
    <span class="kwrd">if</span> (existingModifications.FindIndex(
                    <span class="kwrd">value</span> =&gt;
                        <span class="kwrd">value</span>.Name == mod.Name &amp;&amp;
                        <span class="kwrd">value</span>.Value == mod.Value &amp;&amp;
                        <span class="kwrd">value</span>.Owner == mod.Owner) == -1)
    {
      <span class="rem">// If the modifcation does not already exist </span>
      <span class="rem">// add the entry to the config</span>
      webApp.WebConfigModifications.Add(mod);
    }
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> RemoveWebConfigEntry(
            SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    webApp.WebConfigModifications.Remove(mod);
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> SPWebConfigModification GetModification()
  {
    <span class="kwrd">string</span> asmName = <span class="kwrd">typeof</span>(StartupModule).AssemblyQualifiedName;
    <span class="kwrd">string</span> typeName = <span class="kwrd">typeof</span>(StartupModule).FullName;

    <span class="kwrd">return</span> <span class="kwrd">new</span> SPWebConfigModification
      {
        Path = <span class="str">&quot;configuration/system.web/httpModules&quot;</span>,
        Name = String.Format(CultureInfo.InvariantCulture,
                <span class="str">&quot;add[@name='{0}'][@type='{1}']&quot;</span>,
                typeName, asmName),
        Sequence = 0,
        Owner = asmName,
        Type = SPWebConfigModification.
                    SPWebConfigModificationType.EnsureChildNode,
        Value = String.Format(CultureInfo.InvariantCulture,
                  <span class="str">&quot;&lt;add name='{0}' type='{1}' /&gt;&quot;</span>,
                  typeName, asmName)
      };
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> UpdateApp(SPWebApplication webApp)
  {
    <span class="rem">// Update the Web App and apply the changes </span>
    <span class="rem">// to all servers in the farm</span>
    webApp.Update();
    webApp.Farm.Services
        .GetValue&lt;SPWebService&gt;()
        .ApplyWebConfigModifications();
  }
}</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Integration Test Brought to you by Powershell &amp; NUnit &#8211; with a Little Specification Syntax for Flavoring</title>
	<atom:link href="http://elegantcode.com/category/microsoft/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Elegant Code &#187; Microsoft</title>
	<atom:link href="http://elegantcode.com/category/microsoft/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Buy Quinine Without Prescription</title>
		<link>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=awarded-microsoft-community-contributor-award-2012</link>
		<comments>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 23:03:17 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[awards]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/</guid>
		<description><![CDATA[Buy Quinine Without Prescription, Today I received an email informing me that I have been awarded the Microsoft Community Contributor Award.&#160; This is the second time I have been awarded this particular award and it feels just as good this time as it did last time.&#160; I’m not sure how you go about getting nominated [...]]]></description>
			<content:encoded><![CDATA[<p> <p> <b>Buy Quinine Without Prescription</b>, Today I received an email informing me that I have been awarded the Microsoft Community Contributor Award.&#160; This is the second time I have been awarded this particular award and it feels just as good this time as it did last time.&#160; I’m not sure how you go about getting nominated for this award, but apparently I am doing something right.</p>  <p>I would like to thank whoever nominated me for this award and Microsoft for listening to that person.&#160; I would most of all like to thank the community.&#160; Without the support of the community I would probably still be a cop. Oh, <b>australia, uk, us, usa</b>, <b>Discount Quinine</b>, you probably didn’t know that about me.</p>  <p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="Brian Lagunas awarded Microsoft Community Contributor Award" border="0" alt="Brian Lagunas awarded Microsoft Community Contributor Award" src="http://elegantcode.com/wp-content/uploads/2012/03/MCC12_Logo_Horizontal_Full-color.jpg" width="500" height="202" /></p>.  Quinine pharmacy.  Herbal Quinine.  Order Quinine no prescription.  What is Quinine.  Buy Quinine online cod.  Quinine street price.  Quinine use.  Effects of Quinine.  Buy Quinine online no prescription.  Is Quinine safe.  Where can i cheapest Quinine online.  Order Quinine online overnight delivery no prescription.  Where to buy Quinine.  Quinine duration.  Quinine from canada.  Fast shipping Quinine.  After Quinine.  Quinine no prescription.  Quinine cost.  Quinine alternatives.  Quinine samples.  Buy Quinine from canada.  Buy Quinine no prescription.  Ordering Quinine online.  Quinine mg.  Quinine dangers.  Where can i buy Quinine online.  Purchase Quinine online.  Quinine maximum dosage.  Buy Quinine online cod.  Rx free Quinine.  Order Quinine from United States pharmacy.  Buy generic Quinine.  No prescription Quinine online.  Quinine australia, uk, us, usa.  Quinine overnight.  Buy Quinine without a prescription.  Quinine online cod.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4728'>Ventolin For Sale</a>. <a href='http://elegantcode.com/?p=4184'>Synthroid For Sale</a>. <a href='http://elegantcode.com/?p=4384'>Buy Ultram Without Prescription</a>. <a href='http://elegantcode.com/?p=4373'>Topamax For Sale</a>. <a href='http://elegantcode.com/?p=5156'>Amoxicillin For Sale</a>. <a href='http://elegantcode.com/?p=4384'>Order Ultram online overnight delivery no prescription</a>. <a href='http://elegantcode.com/?p=4683'>Inderal schedule</a>. <a href='http://elegantcode.com/?p=4822'>About Hydrochlorothiazide</a>. <a href='http://elegantcode.com/?p=4728'>Ventolin australia, uk, us, usa</a>. <a href='http://elegantcode.com/?p=4694'>Human Growth Hormone interactions</a>.<br />
<b>Trackbacks from:</b> <a href='http://social-blend.com/?p=1163'>Buy Quinine Without Prescription</a>. <a href='http://www.quarterlives.com/?p=710'>Buy Quinine Without Prescription</a>. <a href='http://4realz.net/?p=1873'>Buy Quinine Without Prescription</a>. <a href='http://www.macneilbmx.com/blog/?p=6577'>Buy Quinine Without Prescription</a>. <a href='http://www.greatgreengoods.com/?p=2921'>Buy Quinine Without Prescription</a>. <a href='http://blog.farmland.org/?p=1913'>Online buy Quinine without a prescription</a>. <a href='http://reversemortgagedaily.com/?p=14688'>Is Quinine addictive</a>. <a href='http://linuxologist.com/?p=1495'>Quinine over the counter</a>. <a href='http://home.officesnapshots.com/?p=235'>Order Quinine from United States pharmacy</a>. <a href='http://evanrapoport.com/?p=720'>Generic Quinine</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Silverlight Profiling PowerShell helper.</title>
		<link>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=silverlight-profiling-powershell-helper</link>
		<comments>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/#comments</comments>
		<pubDate>Sat, 15 May 2010 16:47:22 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/</guid>
		<description><![CDATA[I was playing around with some Silverlight profiling the other night to see if I could find any obvious issues with my open source project StatLight and wound up writing a little script in PowerShell I hoped someone might find helpful. But I didn’t know you could profile a Silverlight app. I didn’t until I [...]]]></description>
			<content:encoded><![CDATA[<p>I was playing around with some Silverlight profiling the other night to see if I could find any obvious issues with my open source project <a href="http://statlight.net" target="_blank">StatLight</a> and wound up writing a little script in PowerShell I hoped someone might find helpful.</p>  <h4>But I didn’t know you could profile a Silverlight app.</h4>  <p>I didn’t until I started doing some digging online. Now, the Silverlight profiling story (at least from what I’ve seen/tried) is not near the easy of say <a href="http://www.red-gate.com/products/ants_performance_profiler/index.htm">Redgate ANTS Performance Profiler</a>. However, it’s do-able. (And with this helper script – hopefully a little simpler?)</p>  <h4>How can I profile a Silverlight Application?</h4>  <p>I would recommend you read the following blog, which explains one way of doing it very well.</p>  <p><a title="http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx" href="http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx">http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx</a></p>  <h4>So… what’s this script for?</h4>  <p>If you read the blog above, or have done this before, then you probably noticed that there was quite a series of commands you had to execute before you could wind up with a performance report. </p>  <p>I threw together a quick little PowerShell script in an attempt to automate smooth out the process.</p>  <h4>Hot do I use it?</h4>  <ol>   <li>Download the script &amp; save it somewhere. <a href="http://github.com/staxmanade/Scripts/blob/master/SilverlightProfiler.ps1"><strong>http://github.com/staxmanade/Scripts/blob/master/SilverlightProfiler.ps1</strong></a> </li>    <li>Open the PowerShell console. cd to the directory your xap/assemblies are stored.      <br />(EX: {myProject}\Bin\Debug\ ) </li>    <li>Execute:      <br />{pathToScript}\SilverlightProfiler.ps1 -urlPath &quot;{myProject}\Bin\Debug\TestPage.html&quot; </li>    <li>When your done profiling press enter to signal that your done.      <p></p> Once complete, it will print the location your profiling report was saved. You can then open it with Visual Studio.</li> </ol>  <h5>Couple of disclaimers.</h5>  <ul>   <li>Some paths are hard-coded to my x86 machine. </li>    <li>I had troubles running the built in visual studio .bat files (from powershell) that are supposed to set the environment variables. So I extracted out what vars I could find to make it work. </li>    <li>I’m not a profiling expert – just hacked this together to get it to work for me.</li> </ul>  <p>I hope this is useful, and if you know of a better way, I’m always interested in hearing your feedback.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tell me what you don&#8217;t like about TFS 2010</title>
		<link>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tell-me-what-you-dont-like-about-tfs-2010</link>
		<comments>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/#comments</comments>
		<pubDate>Sat, 15 May 2010 15:48:18 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Team System]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/</guid>
		<description><![CDATA[I know that a lot of people have had bad experiences with TFS over the years, and so does the TFS development team. The team at Microsoft is very intent on learning what it is that people find irritating, problematic, or difficult, and correcting it. Some major headway was made with the 2010 release of [...]]]></description>
			<content:encoded><![CDATA[<p>I know that a lot of people have had bad experiences with TFS over the years, and so does the TFS development team. The team at Microsoft is very intent on learning what it is that people find irritating, problematic, or difficult, and correcting it. Some major headway was made with the 2010 release of Team Foundation Server to make it easier to setup and administer, and also to improve the usability of several of its key features.</p>  <p>That said, there is still room for improvement and both the team and I understand there are still opportunities to improve. In all seriousness, the team at Microsoft wants to make TFS an approachable, no-brainer install decision for .NET teams, even small ones. This means they want to be able to compete for your attention with the likes of SVN, Git, Jira, Perforce, and anyone else making collaboration tools for developers.</p>  <p>The point of this post is for you to help me know what feedback I can give the TFS product development team as they look ahead to the next release of TFS. I am looking for legitimate feedback I can give the team on how to improve the TFS product.</p>  <p>Please bear in mind that I am interested in your feedback on TFS 2010, as TFS 2008 was improved upon 10 fold in the latest release. Also, I am not necessarily looking for feedback on Visual Studio, just the TFS side of the house. Please realize that the team who makes this product at Microsoft is just as committed and passionate about making great software as you are. They just really need your feedback to make the thing you want. In fact, they want to make a tool that every developer loves to use. Really. So what needs to change to make that the case?</p>  <p>Recall that TFS functionality is broken into the following major areas and I am looking for feedback on the 2010 version.</p>  <ul>   <li>Version Control </li>    <li>Work Item management </li>    <li>Team Foundation Build </li>    <li>SharePoint integration (optional) </li>    <li>Reporting and SSRS Integration (optional) </li> </ul>  <p>Thanks for anything you have. Thank you also for being respectful and not making this a bash-fest.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>Visual Studio: Open in Full XAML View by Default</title>
		<link>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=visual-studio-open-in-full-xaml-view-by-default</link>
		<comments>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 15:49:14 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/</guid>
		<description><![CDATA[So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane [...]]]></description>
			<content:encoded><![CDATA[<p>So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane blows.&#160; So now I have to sit and wait for VS to render my view in the preview pane, and sometimes it can take a while, if it doesn’t just completely crash.&#160; Sometimes I take the extra time to go grab a snack and beverage of my choice.&#160; </p>  <p>So here is a hidden performance increasing jewel you might find useful.&#160; We can set the default open mode to be in full XAML view.</p>  <p>First thing you need to do is in Visual Studio go to your Tools ==&gt; Options ==&gt; Text Editor ==&gt; XAML ==&gt; Miscellaneous.&#160; There you will see an option for “Always open documents in full XAML view”.&#160; Check that box.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/04/image.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="xaml options for opening in full xaml view" border="0" alt="xaml options for opening in full xaml view" src="http://elegantcode.com/wp-content/uploads/2010/04/image_thumb.png" width="244" height="146" /></a> </p>  <p>Now every time you open a XAML file it will open in full XAML view and give you one less thing to gripe about.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Looking Ahead to 2010</title>
		<link>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=looking-ahead-to-2010</link>
		<comments>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 21:02:11 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/02/09/looking-ahead-to-2010/</guid>
		<description><![CDATA[No, this isn't another prognostication post foretelling the woes of the world for the next year. This is a note to everyone who hasn't yet played with the Visual Studio ALM tools and Team Foundation Server 2010. Folks, this product is getting better. That stands to reason. After all, this is basically version 3 of [...]]]></description>
			<content:encoded><![CDATA[<p><img align="left" src="http://elegantcode.com/wp-content/uploads/2010/02/020910_2101_LookingAhea13.png" alt=""/>No, this isn't another prognostication post foretelling the woes of the world for the next year. This is a note to everyone who hasn't yet played with the Visual Studio ALM tools and Team Foundation Server 2010.
</p><p>Folks, this product is getting better. That stands to reason. After all, this is basically version 3 of the product and you know what they say! Version 3 is the one to buy. Most of the kinks are worked out now.
</p><p>Now, I won't pretend for a moment that Team Foundation Server hasn't had its challenges fitting in with agile teams. I think that has come from a history of development by a team that itself was learning and growing just like the rest of us. Now that many of the teams within Microsoft are practicing some form of iterative development with completed cycles of "all the way done", we are starting to see the influence in the tools they are producing. And the effect is not half bad.
</p><p>I have been using Visual Studio 2010 for a few months now, and with the recent release of the RC, I can see:
</p><ol><li>Performance is getting better (XAML).
</li><li>Features are getting more solid (fewer exceptions)
</li><li>The polish of the overall user experience is becoming a great example of an application I am happy to look at all day long.
</li><li>The Team Foundation Server features being added are consistent with what we are learning to be effective as an agile community.
</li></ol><p>So, where's the meat? What are these shiny features of which you speak, Mr. Starr? Well, here is a short sample because I am sitting in an airport listening to the chaos and I can't think of it all. 
</p><p>I should also say that this is a very small list of features that I personally am really excited about. The rest of the world probably has other things they care about. These are mine because I believe they have to potential to really change life on a team for the better.
</p><h2>Layer Diagrams
</h2><p>There is a major focus in this release to add UML support to Visual Studio Ultimate. OK, not a huge fan and I know some people will dog on this feature, but I am all about the Layer Diagrams. These are diagrams that we can create just like the UML diagrams that Visual Studio now supports, but the value of a Layer Diagram is that it has teeth and can bite back. 
</p><p>Here's how it works:
</p><ol><li>Create a Layer Diagram.
</li><li>Draw your favorite design pattern or desired architectural separation model using tools in the Toolbox. In a simple example, this might be to create a model of the MVP pattern. In a large example this model might show the multiple layers in my solution that uses CSLA, Silverlight with MVVM, WCF, and Entity Framework. (Hi, Scott <span style="font-family:Wingdings">J</span> You knew that was for you.)
</li><li>Add some things to it from your solution. Drop things onto the diagram and into the boxes like classes, namespaces, and Visual Studio projects.
</li><li>Now you can generate dependencies between these things and see the existing relationships. Yawn. Cool, but we get this with dependency diagrams, too.
</li><li><div>Validate the model.<br/><br/>Wait for it. . .  Grok it. . .
</div><p><br/>You got it! Yeah, that's right. Validate the LOGICAL model of your application. This is so sweet it comes on a stick. This means that not only can I verify I haven't violated my design with a bad reference or super egregious abstraction hole, but I can make this validation part of the build process and catch it if I accidently violate my own design later. Where I come from, they call that cool.
</p></li></ol><h2>Way Better Work Items
</h2><p>This is non-trivial for teams who live every day of their lives in Team Foundation Server to manage their requirements and work queues. Sure, we might all prefer note cards on the wall, but for many this is simply not possible. And for those folks who use Team Foundation Server to manage their notecards, there are some great new things to make that task easier.
</p><ol><li>Hierarchical relationships between Work Items.
</li><li>Agile planning Workbooks.
</li><li>Seamless Team Project Dashboards.
</li><li>MSF Agile 5.
</li></ol><h2>Gated Check In
</h2><p>This is a feature of Team Foundation Build that will actually build and test your software before a check-in is committed to Source Control. The mechanical effect of this is simple: Code that would break the build is never committed to Source Control. The implications are far larger, though. Think it through for a moment. What would change in your daily life if you flat out were unable to commit code that breaks the build? The short answer is, "Quality goes up." I bit more verbose answer is that I need to be more careful before committing my code.
</p><p>Yes, I know other vendors have had this feature for a while. So what? So, Team Foundation Server shouldn't have it too? It rocks and now we get it in Team Foundation Build.
</p><h2>IntelliTrace
</h2><p>I am not even sure how cool this is yet, only that it is. This feature is also known as Historical Debugging and gives the ability to step back and forth through call stacks and watched variables during a debug run. To be clear, that's <em>Back and Forth through time</em>. So, the first time I hit the breakpoint, here was the status of the code. The second time it was this. And so on. Also, I can inspect all this data on system events (like CLR events) and can therefore tap into my app at a lot of different levels.
</p><p>Now, I know that you don't need debuggers anymore because every line of code we write is Test Driven and that means we don't need debuggers, right? Yeah, sure you never need a debugger. As I said, this is just a wicked tool, but I am not yet sure how wicked. The community will definitely ferret that out over time.
</p><h2>Other Stuff
</h2><p>This only scratches the surface of what's in Visual Studio and Team Foundation Server 2010. There are a lot more things, many of them bigger and higher profile than the things I mentioned. I just happen to be in love with these particular features at the moment. As I get deeper into things, I will let you know what I see.
</p><p>One last thing, I know these tools get a lot of flak in some communities, but I feel comfortable with them. I also understand that many developers out there in the world don't get to choose their tools. Often tools are assigned. What I see is that the 2010 versions of Visual Studio and Team Foundation Server really have raised the bar. I don't feel like teams are still having to compromise on tooling to get everything they need in an integrated environment.
</p><p>Will I still run R#? Well, yeah.
</p><p>
 </p><p>
 </p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Powershell: Load assembly without locking file.</title>
		<link>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-load-assembly-without-locking-file</link>
		<comments>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 05:40:23 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/</guid>
		<description><![CDATA[I have a set of PowerShell build scripts and ran into a case where I needed to load an assembly (to get the assembly’s version) and still (at a later time) work with the assembly file on disk. A typical way to load an assembly within PowerShell is to use the Assembly.LoadFrom(filePath) # Powershell [System.Reflection.Assembly]::LoadFrom($assemblyPath) [...]]]></description>
			<content:encoded><![CDATA[<p>I have a set of PowerShell build scripts and ran into a case where I needed to load an assembly (to get the assembly’s version) and still (at a later time) work with the assembly file on disk.</p>  <p>A typical way to load an assembly within PowerShell is to use the Assembly.LoadFrom(filePath)</p>  <blockquote>   <p># Powershell</p>    <p>[System.Reflection.Assembly]::LoadFrom($assemblyPath)</p> </blockquote>  <p><a href="http://elegantcode.com/wp-content/uploads/2009/12/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2009/12/image_thumb9.png" width="690" height="391" /></a> </p>  <p>Except the problem with this (in my case) was it would <strong>lock the file for the lifespan of the PowerShell console instance</strong>. I didn’t want to have to close and re-open the PowerShell console every time I need to run a build so there had to be a work-around for this.</p>  <p>After searching the web for a solution, I couldn’t find anything that was “easy” and worth the effort to get it to work.</p>  <blockquote>   <p>EX: One solution was to create a new AppDomain, do the necessary work and the close the AppDomain which would release the lock on the file.</p>    <p>I’ve never done this myself, and even thought there is example code out there to get this accomplished, it just seemed over the top for what I was trying to do, and back to my previous criteria it wasn’t “worth the effort to get it to work”</p> </blockquote>  <p>Then I remembered in a previous life I used an overload that took an array of bytes to load the an assembly.</p>  <blockquote>   <p>[System.Reflection.Assembly]::Load($assemblyBytes)</p> </blockquote>  <p>After spiking it in PowerShell with the below test. I was quite happy with the solution, so I thought I’d throw it out there.</p>  <p>Just stream the assembly from disk into a byte array manually, and call assembly load from there.</p>  <p>Here’s my test case which shows that the file is not locked after it was loaded into the PowerShell runtime</p>  <pre>$file = &quot;.\Moq.dll&quot;
$tempFileName = &quot;.\Moq-Renamed.dll&quot;

$fileStream = ([System.IO.FileInfo] (Get-Item $file)).OpenRead();
$assemblyBytes = new-object byte[] $fileStream.Length
$fileStream.Read($assemblyBytes, 0, $fileStream.Length);
$fileStream.Close();

$assemblyLoaded = [System.Reflection.Assembly]::Load($assemblyBytes);

# notice that we can move the file on disk after 
# it's loaded into the powershell runtime
Move-Item $file $tempFileName
Move-Item $tempFileName $file 

# and display the assembly information to show we still have it in memory
echo $assemblyLoaded</pre>

<p>After that test passed, and the main reason I wanted to do this, I wrote the “get-assembly-version” PowerShell function.</p>

<pre><strike>function get-assembly-version() {
    param([string] $file)
    
    # load the assembly bytes quickly - as to not lock the file for too long
    $fileStream = ([System.IO.FileInfo] (Get-Item $file)).OpenRead()
    $assemblyBytes = new-object byte[] $fileStream.Length
    $fileStream.Read($assemblyBytes, 0, $fileStream.Length) | Out-Null #out null this because this function should only return the version &amp; this call was outputting some garbage number
    $fileStream.Close()
    
    # return the version of the assembly
    [System.Reflection.Assembly]::Load($assemblyBytes).GetName().Version;
}

$version = get-assembly-version(&quot;.\Moq.dll&quot;)

echo &quot;Loaded v$($version.Major).$($version.Minor).$($version.Build).$($version.Revision) version of $file&quot;</strike></pre>
Hope this helps someone out there! 

<p></p>

<p>&#160;</p>

<p><strong>UPDATE:</strong></p>

<p><a href="http://achuebrigens.wordpress.com">Martin</a> commented below on a much better solution to the assembly version info problem. Amazing how complicated we can make things if we don’t know the path.</p>

<pre>
function get-assembly-version() {
    param([string] $file)
    
    $version = [System.Reflection.AssemblyName]::GetAssemblyName($file).Version;
    
    #format the version and output it...
    $version
}</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Removing WSUS</title>
		<link>http://elegantcode.com/2009/12/01/removing-wsus/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=removing-wsus</link>
		<comments>http://elegantcode.com/2009/12/01/removing-wsus/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 21:53:49 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[WSUS]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/01/removing-wsus/</guid>
		<description><![CDATA[A while back, the company I work for experimented with setting up a Windows Server Update Service (WSUS).&#160; The idea is that you have one server that goes out and downloads all of the hotfixes, service packs, and so on for your network – then each of your client machines goes directly to the local [...]]]></description>
			<content:encoded><![CDATA[<p>A while back, the company I work for experimented with setting up a Windows Server Update Service (WSUS).&#160; The idea is that you have one server that goes out and downloads all of the hotfixes, service packs, and so on for your network – then each of your client machines goes directly to the local WSUS server to get the weekly dose of patches, configurable by various group policies, and with monitoring to make sure that everything is going smoothly.&#160; At the time we set it up, we were having crushing bandwidth problems – two servers downloading a service pack would pretty much disable the building…</p>  <p>Over time, the bandwidth problems were fixed, and as sometimes happens the WSUS server crumbled to dust.&#160; For the most part nobody noticed – new servers and clients were not configured with the WSUS policy, downloading their hotfixes direct from Microsoft through plentiful bandwidth.&#160; Unfortunately, older server and clients were left in the dark, sending cries out to a WSUS URL that will never respond...&#160; oops</p>  <h4>To Fix (and get your automatic updates to work again):</h4>  <p>Delete the registry key at “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate”.&#160; For fun, restart the “Windows Update” service (not sure if this is necessary).&#160; </p>  <p>I found <a href="http://www.d.umn.edu/itss/security/sus/" target="_blank">this VBS file</a> to be useful in figuring out if a server was still trying to use an old WSUS install, or if the problem was group-policy related.&#160; </p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/01/removing-wsus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PDC Notes</title>
		<link>http://elegantcode.com/2009/11/17/pdc-notes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pdc-notes</link>
		<comments>http://elegantcode.com/2009/11/17/pdc-notes/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 17:23:30 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/17/pdc-notes/</guid>
		<description><![CDATA[I am grateful to INETA to be attending PDC this year. Also, I grateful to Visual Stuart, who is letting me crash in his room. Turns out, I am a cheap skate :) I am sitting in the keynote on Tuesday and thinking about the week. In addition to the Wait? What the… Wordpress moving [...]]]></description>
			<content:encoded><![CDATA[<p>I am grateful to INETA to be attending <a href="http://microsoftpdc.com">PDC</a> this year. Also, I grateful to <a href="http://visualstuart.com">Visual Stuart</a>, who is letting me crash in his room. Turns out, I am a cheap skate :)</p>  <p>I am sitting in the keynote on Tuesday and thinking about the week. In addition to the </p>  <blockquote>   <p><font style="background-color: #ffffff">Wait? What the… Wordpress moving into the Azure cloud? Sweet!</font></p> </blockquote>  <p>volunteer sessions I am doing for INETA, I am hosting a Birds of a Feather session with Mike Vincent. Our BOF is this afternoon and is entitled, “Agile Tales of Triumph, Tribulation, Tools, and Teams”. Drop by and join the discussion to learn </p>  <blockquote>   <p><font style="background-color: #ffffff">Code name Dallas: A uniform way to access data in the cloud and mash it all up.</font></p> </blockquote>  <p>and share what really works.</p>  <p>It has been very cool to meet many of the Pluralsight instructors for the first time. We all live in different parts of the world, and PDC provides that opportunity for us to </p>  <blockquote>   <p>Everyone get your 3D glasses on! Oh, that was very anti-climactic.</p> </blockquote>  <p>all actually shake physical hands rather than electronic ones.</p>  <p>Also, drop by the Pluralsight booth and share your developer stories with me. Here’s the sneak peek as to why: <font style="background-color: #ffffff"><a href="http://www.pluralsight.com/main/pluralcast/default.aspx">Pluralcast</a>. More on that in another post. Suffice </font></p>  <blockquote>   <p><font style="background-color: #ffffff">I think that guy onstage is showing an iPhone and talking about how easy it was to write an app for it. Weird.</font></p> </blockquote>  <p><font style="background-color: #ffffff">to say </font>there will be some changes in the Elegant Code Cast.</p>  <blockquote>   <p>Did he just say, “Create applications for the good of the republic?” Seriously?</p> </blockquote>  <p>Lastly, if you see me running around the halls, please stop me and say, Hello.” It’s very cool to be able to meet people I usually only get to chat with online. If you are looking for a <a href="http://guild3.com">great developer team</a> to build your next big thing, we can talk about that, too!</p>  <blockquote>   <p>Please stop saying “3 screens in the cloud.”</p> </blockquote>  <p>Ray Ozzie final points from the keynote:</p>  <ol>   <li>Bet your next user experience on Windows 7</li>    <li>When thinking of the cloud, bet on Azure.</li>    <li>Take a moment to think about how the world is changing and the potential role of cloud in that world.</li> </ol>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/17/pdc-notes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>StructureMap and SharePoint</title>
		<link>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=structuremap-and-sharepoint</link>
		<comments>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 18:00:22 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[StructureMap]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/</guid>
		<description><![CDATA[I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; </p>  <p>I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user is authorized to use.&#160; The source of this data (names, URLs, etc.) comes from an external-to-SharePoint system, accessed through another C# assembly.&#160; Once the web part gets the data there is some more processing to be done – we need to do more than just blindly display a list of URLs.&#160; Rather than get into details I’m just going to do some handwaving here and say that “if you have access to X, then {stuff happens}, or if you have access to Y then {other stuff happens}.”&#160; You know, business logic, stuff that is good to test.</p>  <p>the first thing I need to do is get business logic out of the WebPart and into something that I can write without having to reset AppPools over and over, not to mention have some unit tests to verify I’m going in the right direction.&#160; So, I created a standard application service class which has a dependency on the external authorization system, via constructor injection.&#160; </p>  <pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> AuthorizedAppsService : IAuthorizedAppsService
{
  <span class="kwrd">private</span> <span class="kwrd">readonly</span> ExternalAuthorizeService authService;

  <span class="kwrd">public</span> AuthorizedAppsService(
    ExternalAuthorizeService authService) 
  {
    <span class="kwrd">this</span>.authService = authService;
  }

  <span class="kwrd">public</span> AuthorizedApplications GetAuthorizedApplications(
                                  <span class="kwrd">string</span> userName)
  {
    var allApps = authService.AuthorizedApplications(userName);
    <span class="rem">// business logic stuff happens here</span>
    <span class="kwrd">return</span> thoseResultsWeJustFiguredOut;
  }
}</pre>

<p>Next, I created a StructureMap Registry class to scan my assemblies, as well as adding in the details of how to create this external authorize service, using the typical method: <style type="text/css">




.csharpcode, .csharpcode pre
{
	font-size: x-small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style></p>

<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyRegistry : Registry
{
  <span class="kwrd">public</span> MyRegistry()
  {
    Scan(scanner =&gt; {
      scanner.TheCallingAssembly();
      scanner.AssemblyContainingType(<span class="kwrd">typeof</span>(MyRegistry));
      scanner.WithDefaultConventions();
      });

    ForRequestedType&lt;ExternalAuthorizeService&gt;()
      .AsSingletons()
      .TheDefault.Is.ConstructedBy(c =&gt; Provider.GetService());

    <span class="rem">// other dependency configuration...</span>
  }
  <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> InitializeForSharepoint()
  {
    ObjectFactory.Initialize(init =&gt; init.AddRegistry&lt;MyRegistry&gt;());
    ObjectFactory.AssertConfigurationIsValid();
  }
}</pre>

<p>And then, what remains is to have SharePoint call my StructureMap initialization when my SharePoint application starts up.&#160; In an MVC or WebForms app, I’d just add code to the appropriate place in Global.asax.cs, but in SharePointLand, this is looked down on.&#160; Instead, the preferred mechanism seems to be to use an HttpModule and a FeatureReceiver to plug the Module into the app’s web.config.</p>

<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyStartupModule : IHttpModule
{
  <span class="kwrd">public</span> <span class="kwrd">void</span> Init(HttpApplication context)
  {
        ConfigureOtherStuff();
        MyRegistry.InitializeForSharepoint();
  }
  <span class="kwrd">public</span> <span class="kwrd">void</span> Dispose() { }
}</pre>

<p>And then the FeatureReceiver to alter the app’s Web.Config looks something like this (note I borrowed most of this code from another sample SharePoint project:</p>

<p>&#160;</p>

<pre class="csharpcode"><span class="rem">//</span>
<span class="rem">// this is borrowing heavily from http://www.codeplex.com/SPAXO</span>
<span class="rem">// </span>
<span class="kwrd">public</span> <span class="kwrd">class</span> StartupFeatureReceiver : SPFeatureReceiver
{
  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureActivated(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    AddWebConfigEntry(webApp);
    UpdateApp(webApp);
  }

  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureDeactivating(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    RemoveWebConfigEntry(webApp);
    UpdateApp(webApp);
  }


  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> AddWebConfigEntry(SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    var existingModifications = 
             <span class="kwrd">new</span> List&lt;SPWebConfigModification&gt;(
                      webApp.WebConfigModifications);
    <span class="kwrd">if</span> (existingModifications.FindIndex(
                    <span class="kwrd">value</span> =&gt;
                        <span class="kwrd">value</span>.Name == mod.Name &amp;&amp;
                        <span class="kwrd">value</span>.Value == mod.Value &amp;&amp;
                        <span class="kwrd">value</span>.Owner == mod.Owner) == -1)
    {
      <span class="rem">// If the modifcation does not already exist </span>
      <span class="rem">// add the entry to the config</span>
      webApp.WebConfigModifications.Add(mod);
    }
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> RemoveWebConfigEntry(
            SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    webApp.WebConfigModifications.Remove(mod);
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> SPWebConfigModification GetModification()
  {
    <span class="kwrd">string</span> asmName = <span class="kwrd">typeof</span>(StartupModule).AssemblyQualifiedName;
    <span class="kwrd">string</span> typeName = <span class="kwrd">typeof</span>(StartupModule).FullName;

    <span class="kwrd">return</span> <span class="kwrd">new</span> SPWebConfigModification
      {
        Path = <span class="str">&quot;configuration/system.web/httpModules&quot;</span>,
        Name = String.Format(CultureInfo.InvariantCulture,
                <span class="str">&quot;add[@name='{0}'][@type='{1}']&quot;</span>,
                typeName, asmName),
        Sequence = 0,
        Owner = asmName,
        Type = SPWebConfigModification.
                    SPWebConfigModificationType.EnsureChildNode,
        Value = String.Format(CultureInfo.InvariantCulture,
                  <span class="str">&quot;&lt;add name='{0}' type='{1}' /&gt;&quot;</span>,
                  typeName, asmName)
      };
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> UpdateApp(SPWebApplication webApp)
  {
    <span class="rem">// Update the Web App and apply the changes </span>
    <span class="rem">// to all servers in the farm</span>
    webApp.Update();
    webApp.Farm.Services
        .GetValue&lt;SPWebService&gt;()
        .ApplyWebConfigModifications();
  }
}</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Integration Test Brought to you by Powershell &amp; NUnit &#8211; with a Little Specification Syntax for Flavoring</title>
		<link>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=awarded-microsoft-community-contributor-award-2012</link>
		<comments>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 23:03:17 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[awards]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/</guid>
		<description><![CDATA[Buy Quinine Without Prescription, Today I received an email informing me that I have been awarded the Microsoft Community Contributor Award.&#160; This is the second time I have been awarded this particular award and it feels just as good this time as it did last time.&#160; I’m not sure how you go about getting nominated [...]]]></description>
			<content:encoded><![CDATA[<p> <p> <b>Buy Quinine Without Prescription</b>, Today I received an email informing me that I have been awarded the Microsoft Community Contributor Award.&#160; This is the second time I have been awarded this particular award and it feels just as good this time as it did last time.&#160; I’m not sure how you go about getting nominated for this award, but apparently I am doing something right.</p>  <p>I would like to thank whoever nominated me for this award and Microsoft for listening to that person.&#160; I would most of all like to thank the community.&#160; Without the support of the community I would probably still be a cop. Oh, <b>australia, uk, us, usa</b>, <b>Discount Quinine</b>, you probably didn’t know that about me.</p>  <p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="Brian Lagunas awarded Microsoft Community Contributor Award" border="0" alt="Brian Lagunas awarded Microsoft Community Contributor Award" src="http://elegantcode.com/wp-content/uploads/2012/03/MCC12_Logo_Horizontal_Full-color.jpg" width="500" height="202" /></p>.  Quinine pharmacy.  Herbal Quinine.  Order Quinine no prescription.  What is Quinine.  Buy Quinine online cod.  Quinine street price.  Quinine use.  Effects of Quinine.  Buy Quinine online no prescription.  Is Quinine safe.  Where can i cheapest Quinine online.  Order Quinine online overnight delivery no prescription.  Where to buy Quinine.  Quinine duration.  Quinine from canada.  Fast shipping Quinine.  After Quinine.  Quinine no prescription.  Quinine cost.  Quinine alternatives.  Quinine samples.  Buy Quinine from canada.  Buy Quinine no prescription.  Ordering Quinine online.  Quinine mg.  Quinine dangers.  Where can i buy Quinine online.  Purchase Quinine online.  Quinine maximum dosage.  Buy Quinine online cod.  Rx free Quinine.  Order Quinine from United States pharmacy.  Buy generic Quinine.  No prescription Quinine online.  Quinine australia, uk, us, usa.  Quinine overnight.  Buy Quinine without a prescription.  Quinine online cod.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4728'>Ventolin For Sale</a>. <a href='http://elegantcode.com/?p=4184'>Synthroid For Sale</a>. <a href='http://elegantcode.com/?p=4384'>Buy Ultram Without Prescription</a>. <a href='http://elegantcode.com/?p=4373'>Topamax For Sale</a>. <a href='http://elegantcode.com/?p=5156'>Amoxicillin For Sale</a>. <a href='http://elegantcode.com/?p=4384'>Order Ultram online overnight delivery no prescription</a>. <a href='http://elegantcode.com/?p=4683'>Inderal schedule</a>. <a href='http://elegantcode.com/?p=4822'>About Hydrochlorothiazide</a>. <a href='http://elegantcode.com/?p=4728'>Ventolin australia, uk, us, usa</a>. <a href='http://elegantcode.com/?p=4694'>Human Growth Hormone interactions</a>.<br />
<b>Trackbacks from:</b> <a href='http://social-blend.com/?p=1163'>Buy Quinine Without Prescription</a>. <a href='http://www.quarterlives.com/?p=710'>Buy Quinine Without Prescription</a>. <a href='http://4realz.net/?p=1873'>Buy Quinine Without Prescription</a>. <a href='http://www.macneilbmx.com/blog/?p=6577'>Buy Quinine Without Prescription</a>. <a href='http://www.greatgreengoods.com/?p=2921'>Buy Quinine Without Prescription</a>. <a href='http://blog.farmland.org/?p=1913'>Online buy Quinine without a prescription</a>. <a href='http://reversemortgagedaily.com/?p=14688'>Is Quinine addictive</a>. <a href='http://linuxologist.com/?p=1495'>Quinine over the counter</a>. <a href='http://home.officesnapshots.com/?p=235'>Order Quinine from United States pharmacy</a>. <a href='http://evanrapoport.com/?p=720'>Generic Quinine</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Elegant Code &#187; Microsoft</title>
	<atom:link href="http://elegantcode.com/category/microsoft/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Buy Quinine Without Prescription</title>
		<link>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=awarded-microsoft-community-contributor-award-2012</link>
		<comments>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 23:03:17 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[awards]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/</guid>
		<description><![CDATA[Buy Quinine Without Prescription, Today I received an email informing me that I have been awarded the Microsoft Community Contributor Award.&#160; This is the second time I have been awarded this particular award and it feels just as good this time as it did last time.&#160; I’m not sure how you go about getting nominated [...]]]></description>
			<content:encoded><![CDATA[<p> <p> <b>Buy Quinine Without Prescription</b>, Today I received an email informing me that I have been awarded the Microsoft Community Contributor Award.&#160; This is the second time I have been awarded this particular award and it feels just as good this time as it did last time.&#160; I’m not sure how you go about getting nominated for this award, but apparently I am doing something right.</p>  <p>I would like to thank whoever nominated me for this award and Microsoft for listening to that person.&#160; I would most of all like to thank the community.&#160; Without the support of the community I would probably still be a cop. Oh, <b>australia, uk, us, usa</b>, <b>Discount Quinine</b>, you probably didn’t know that about me.</p>  <p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="Brian Lagunas awarded Microsoft Community Contributor Award" border="0" alt="Brian Lagunas awarded Microsoft Community Contributor Award" src="http://elegantcode.com/wp-content/uploads/2012/03/MCC12_Logo_Horizontal_Full-color.jpg" width="500" height="202" /></p>.  Quinine pharmacy.  Herbal Quinine.  Order Quinine no prescription.  What is Quinine.  Buy Quinine online cod.  Quinine street price.  Quinine use.  Effects of Quinine.  Buy Quinine online no prescription.  Is Quinine safe.  Where can i cheapest Quinine online.  Order Quinine online overnight delivery no prescription.  Where to buy Quinine.  Quinine duration.  Quinine from canada.  Fast shipping Quinine.  After Quinine.  Quinine no prescription.  Quinine cost.  Quinine alternatives.  Quinine samples.  Buy Quinine from canada.  Buy Quinine no prescription.  Ordering Quinine online.  Quinine mg.  Quinine dangers.  Where can i buy Quinine online.  Purchase Quinine online.  Quinine maximum dosage.  Buy Quinine online cod.  Rx free Quinine.  Order Quinine from United States pharmacy.  Buy generic Quinine.  No prescription Quinine online.  Quinine australia, uk, us, usa.  Quinine overnight.  Buy Quinine without a prescription.  Quinine online cod.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4728'>Ventolin For Sale</a>. <a href='http://elegantcode.com/?p=4184'>Synthroid For Sale</a>. <a href='http://elegantcode.com/?p=4384'>Buy Ultram Without Prescription</a>. <a href='http://elegantcode.com/?p=4373'>Topamax For Sale</a>. <a href='http://elegantcode.com/?p=5156'>Amoxicillin For Sale</a>. <a href='http://elegantcode.com/?p=4384'>Order Ultram online overnight delivery no prescription</a>. <a href='http://elegantcode.com/?p=4683'>Inderal schedule</a>. <a href='http://elegantcode.com/?p=4822'>About Hydrochlorothiazide</a>. <a href='http://elegantcode.com/?p=4728'>Ventolin australia, uk, us, usa</a>. <a href='http://elegantcode.com/?p=4694'>Human Growth Hormone interactions</a>.<br />
<b>Trackbacks from:</b> <a href='http://social-blend.com/?p=1163'>Buy Quinine Without Prescription</a>. <a href='http://www.quarterlives.com/?p=710'>Buy Quinine Without Prescription</a>. <a href='http://4realz.net/?p=1873'>Buy Quinine Without Prescription</a>. <a href='http://www.macneilbmx.com/blog/?p=6577'>Buy Quinine Without Prescription</a>. <a href='http://www.greatgreengoods.com/?p=2921'>Buy Quinine Without Prescription</a>. <a href='http://blog.farmland.org/?p=1913'>Online buy Quinine without a prescription</a>. <a href='http://reversemortgagedaily.com/?p=14688'>Is Quinine addictive</a>. <a href='http://linuxologist.com/?p=1495'>Quinine over the counter</a>. <a href='http://home.officesnapshots.com/?p=235'>Order Quinine from United States pharmacy</a>. <a href='http://evanrapoport.com/?p=720'>Generic Quinine</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Silverlight Profiling PowerShell helper.</title>
		<link>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=silverlight-profiling-powershell-helper</link>
		<comments>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/#comments</comments>
		<pubDate>Sat, 15 May 2010 16:47:22 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/</guid>
		<description><![CDATA[I was playing around with some Silverlight profiling the other night to see if I could find any obvious issues with my open source project StatLight and wound up writing a little script in PowerShell I hoped someone might find helpful. But I didn’t know you could profile a Silverlight app. I didn’t until I [...]]]></description>
			<content:encoded><![CDATA[<p>I was playing around with some Silverlight profiling the other night to see if I could find any obvious issues with my open source project <a href="http://statlight.net" target="_blank">StatLight</a> and wound up writing a little script in PowerShell I hoped someone might find helpful.</p>  <h4>But I didn’t know you could profile a Silverlight app.</h4>  <p>I didn’t until I started doing some digging online. Now, the Silverlight profiling story (at least from what I’ve seen/tried) is not near the easy of say <a href="http://www.red-gate.com/products/ants_performance_profiler/index.htm">Redgate ANTS Performance Profiler</a>. However, it’s do-able. (And with this helper script – hopefully a little simpler?)</p>  <h4>How can I profile a Silverlight Application?</h4>  <p>I would recommend you read the following blog, which explains one way of doing it very well.</p>  <p><a title="http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx" href="http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx">http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx</a></p>  <h4>So… what’s this script for?</h4>  <p>If you read the blog above, or have done this before, then you probably noticed that there was quite a series of commands you had to execute before you could wind up with a performance report. </p>  <p>I threw together a quick little PowerShell script in an attempt to automate smooth out the process.</p>  <h4>Hot do I use it?</h4>  <ol>   <li>Download the script &amp; save it somewhere. <a href="http://github.com/staxmanade/Scripts/blob/master/SilverlightProfiler.ps1"><strong>http://github.com/staxmanade/Scripts/blob/master/SilverlightProfiler.ps1</strong></a> </li>    <li>Open the PowerShell console. cd to the directory your xap/assemblies are stored.      <br />(EX: {myProject}\Bin\Debug\ ) </li>    <li>Execute:      <br />{pathToScript}\SilverlightProfiler.ps1 -urlPath &quot;{myProject}\Bin\Debug\TestPage.html&quot; </li>    <li>When your done profiling press enter to signal that your done.      <p></p> Once complete, it will print the location your profiling report was saved. You can then open it with Visual Studio.</li> </ol>  <h5>Couple of disclaimers.</h5>  <ul>   <li>Some paths are hard-coded to my x86 machine. </li>    <li>I had troubles running the built in visual studio .bat files (from powershell) that are supposed to set the environment variables. So I extracted out what vars I could find to make it work. </li>    <li>I’m not a profiling expert – just hacked this together to get it to work for me.</li> </ul>  <p>I hope this is useful, and if you know of a better way, I’m always interested in hearing your feedback.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tell me what you don&#8217;t like about TFS 2010</title>
		<link>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tell-me-what-you-dont-like-about-tfs-2010</link>
		<comments>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/#comments</comments>
		<pubDate>Sat, 15 May 2010 15:48:18 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Team System]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/</guid>
		<description><![CDATA[I know that a lot of people have had bad experiences with TFS over the years, and so does the TFS development team. The team at Microsoft is very intent on learning what it is that people find irritating, problematic, or difficult, and correcting it. Some major headway was made with the 2010 release of [...]]]></description>
			<content:encoded><![CDATA[<p>I know that a lot of people have had bad experiences with TFS over the years, and so does the TFS development team. The team at Microsoft is very intent on learning what it is that people find irritating, problematic, or difficult, and correcting it. Some major headway was made with the 2010 release of Team Foundation Server to make it easier to setup and administer, and also to improve the usability of several of its key features.</p>  <p>That said, there is still room for improvement and both the team and I understand there are still opportunities to improve. In all seriousness, the team at Microsoft wants to make TFS an approachable, no-brainer install decision for .NET teams, even small ones. This means they want to be able to compete for your attention with the likes of SVN, Git, Jira, Perforce, and anyone else making collaboration tools for developers.</p>  <p>The point of this post is for you to help me know what feedback I can give the TFS product development team as they look ahead to the next release of TFS. I am looking for legitimate feedback I can give the team on how to improve the TFS product.</p>  <p>Please bear in mind that I am interested in your feedback on TFS 2010, as TFS 2008 was improved upon 10 fold in the latest release. Also, I am not necessarily looking for feedback on Visual Studio, just the TFS side of the house. Please realize that the team who makes this product at Microsoft is just as committed and passionate about making great software as you are. They just really need your feedback to make the thing you want. In fact, they want to make a tool that every developer loves to use. Really. So what needs to change to make that the case?</p>  <p>Recall that TFS functionality is broken into the following major areas and I am looking for feedback on the 2010 version.</p>  <ul>   <li>Version Control </li>    <li>Work Item management </li>    <li>Team Foundation Build </li>    <li>SharePoint integration (optional) </li>    <li>Reporting and SSRS Integration (optional) </li> </ul>  <p>Thanks for anything you have. Thank you also for being respectful and not making this a bash-fest.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>Visual Studio: Open in Full XAML View by Default</title>
		<link>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=visual-studio-open-in-full-xaml-view-by-default</link>
		<comments>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 15:49:14 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/</guid>
		<description><![CDATA[So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane [...]]]></description>
			<content:encoded><![CDATA[<p>So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane blows.&#160; So now I have to sit and wait for VS to render my view in the preview pane, and sometimes it can take a while, if it doesn’t just completely crash.&#160; Sometimes I take the extra time to go grab a snack and beverage of my choice.&#160; </p>  <p>So here is a hidden performance increasing jewel you might find useful.&#160; We can set the default open mode to be in full XAML view.</p>  <p>First thing you need to do is in Visual Studio go to your Tools ==&gt; Options ==&gt; Text Editor ==&gt; XAML ==&gt; Miscellaneous.&#160; There you will see an option for “Always open documents in full XAML view”.&#160; Check that box.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/04/image.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="xaml options for opening in full xaml view" border="0" alt="xaml options for opening in full xaml view" src="http://elegantcode.com/wp-content/uploads/2010/04/image_thumb.png" width="244" height="146" /></a> </p>  <p>Now every time you open a XAML file it will open in full XAML view and give you one less thing to gripe about.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Looking Ahead to 2010</title>
		<link>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=looking-ahead-to-2010</link>
		<comments>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 21:02:11 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/02/09/looking-ahead-to-2010/</guid>
		<description><![CDATA[No, this isn't another prognostication post foretelling the woes of the world for the next year. This is a note to everyone who hasn't yet played with the Visual Studio ALM tools and Team Foundation Server 2010. Folks, this product is getting better. That stands to reason. After all, this is basically version 3 of [...]]]></description>
			<content:encoded><![CDATA[<p><img align="left" src="http://elegantcode.com/wp-content/uploads/2010/02/020910_2101_LookingAhea13.png" alt=""/>No, this isn't another prognostication post foretelling the woes of the world for the next year. This is a note to everyone who hasn't yet played with the Visual Studio ALM tools and Team Foundation Server 2010.
</p><p>Folks, this product is getting better. That stands to reason. After all, this is basically version 3 of the product and you know what they say! Version 3 is the one to buy. Most of the kinks are worked out now.
</p><p>Now, I won't pretend for a moment that Team Foundation Server hasn't had its challenges fitting in with agile teams. I think that has come from a history of development by a team that itself was learning and growing just like the rest of us. Now that many of the teams within Microsoft are practicing some form of iterative development with completed cycles of "all the way done", we are starting to see the influence in the tools they are producing. And the effect is not half bad.
</p><p>I have been using Visual Studio 2010 for a few months now, and with the recent release of the RC, I can see:
</p><ol><li>Performance is getting better (XAML).
</li><li>Features are getting more solid (fewer exceptions)
</li><li>The polish of the overall user experience is becoming a great example of an application I am happy to look at all day long.
</li><li>The Team Foundation Server features being added are consistent with what we are learning to be effective as an agile community.
</li></ol><p>So, where's the meat? What are these shiny features of which you speak, Mr. Starr? Well, here is a short sample because I am sitting in an airport listening to the chaos and I can't think of it all. 
</p><p>I should also say that this is a very small list of features that I personally am really excited about. The rest of the world probably has other things they care about. These are mine because I believe they have to potential to really change life on a team for the better.
</p><h2>Layer Diagrams
</h2><p>There is a major focus in this release to add UML support to Visual Studio Ultimate. OK, not a huge fan and I know some people will dog on this feature, but I am all about the Layer Diagrams. These are diagrams that we can create just like the UML diagrams that Visual Studio now supports, but the value of a Layer Diagram is that it has teeth and can bite back. 
</p><p>Here's how it works:
</p><ol><li>Create a Layer Diagram.
</li><li>Draw your favorite design pattern or desired architectural separation model using tools in the Toolbox. In a simple example, this might be to create a model of the MVP pattern. In a large example this model might show the multiple layers in my solution that uses CSLA, Silverlight with MVVM, WCF, and Entity Framework. (Hi, Scott <span style="font-family:Wingdings">J</span> You knew that was for you.)
</li><li>Add some things to it from your solution. Drop things onto the diagram and into the boxes like classes, namespaces, and Visual Studio projects.
</li><li>Now you can generate dependencies between these things and see the existing relationships. Yawn. Cool, but we get this with dependency diagrams, too.
</li><li><div>Validate the model.<br/><br/>Wait for it. . .  Grok it. . .
</div><p><br/>You got it! Yeah, that's right. Validate the LOGICAL model of your application. This is so sweet it comes on a stick. This means that not only can I verify I haven't violated my design with a bad reference or super egregious abstraction hole, but I can make this validation part of the build process and catch it if I accidently violate my own design later. Where I come from, they call that cool.
</p></li></ol><h2>Way Better Work Items
</h2><p>This is non-trivial for teams who live every day of their lives in Team Foundation Server to manage their requirements and work queues. Sure, we might all prefer note cards on the wall, but for many this is simply not possible. And for those folks who use Team Foundation Server to manage their notecards, there are some great new things to make that task easier.
</p><ol><li>Hierarchical relationships between Work Items.
</li><li>Agile planning Workbooks.
</li><li>Seamless Team Project Dashboards.
</li><li>MSF Agile 5.
</li></ol><h2>Gated Check In
</h2><p>This is a feature of Team Foundation Build that will actually build and test your software before a check-in is committed to Source Control. The mechanical effect of this is simple: Code that would break the build is never committed to Source Control. The implications are far larger, though. Think it through for a moment. What would change in your daily life if you flat out were unable to commit code that breaks the build? The short answer is, "Quality goes up." I bit more verbose answer is that I need to be more careful before committing my code.
</p><p>Yes, I know other vendors have had this feature for a while. So what? So, Team Foundation Server shouldn't have it too? It rocks and now we get it in Team Foundation Build.
</p><h2>IntelliTrace
</h2><p>I am not even sure how cool this is yet, only that it is. This feature is also known as Historical Debugging and gives the ability to step back and forth through call stacks and watched variables during a debug run. To be clear, that's <em>Back and Forth through time</em>. So, the first time I hit the breakpoint, here was the status of the code. The second time it was this. And so on. Also, I can inspect all this data on system events (like CLR events) and can therefore tap into my app at a lot of different levels.
</p><p>Now, I know that you don't need debuggers anymore because every line of code we write is Test Driven and that means we don't need debuggers, right? Yeah, sure you never need a debugger. As I said, this is just a wicked tool, but I am not yet sure how wicked. The community will definitely ferret that out over time.
</p><h2>Other Stuff
</h2><p>This only scratches the surface of what's in Visual Studio and Team Foundation Server 2010. There are a lot more things, many of them bigger and higher profile than the things I mentioned. I just happen to be in love with these particular features at the moment. As I get deeper into things, I will let you know what I see.
</p><p>One last thing, I know these tools get a lot of flak in some communities, but I feel comfortable with them. I also understand that many developers out there in the world don't get to choose their tools. Often tools are assigned. What I see is that the 2010 versions of Visual Studio and Team Foundation Server really have raised the bar. I don't feel like teams are still having to compromise on tooling to get everything they need in an integrated environment.
</p><p>Will I still run R#? Well, yeah.
</p><p>
 </p><p>
 </p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Powershell: Load assembly without locking file.</title>
		<link>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-load-assembly-without-locking-file</link>
		<comments>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 05:40:23 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/</guid>
		<description><![CDATA[I have a set of PowerShell build scripts and ran into a case where I needed to load an assembly (to get the assembly’s version) and still (at a later time) work with the assembly file on disk. A typical way to load an assembly within PowerShell is to use the Assembly.LoadFrom(filePath) # Powershell [System.Reflection.Assembly]::LoadFrom($assemblyPath) [...]]]></description>
			<content:encoded><![CDATA[<p>I have a set of PowerShell build scripts and ran into a case where I needed to load an assembly (to get the assembly’s version) and still (at a later time) work with the assembly file on disk.</p>  <p>A typical way to load an assembly within PowerShell is to use the Assembly.LoadFrom(filePath)</p>  <blockquote>   <p># Powershell</p>    <p>[System.Reflection.Assembly]::LoadFrom($assemblyPath)</p> </blockquote>  <p><a href="http://elegantcode.com/wp-content/uploads/2009/12/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2009/12/image_thumb9.png" width="690" height="391" /></a> </p>  <p>Except the problem with this (in my case) was it would <strong>lock the file for the lifespan of the PowerShell console instance</strong>. I didn’t want to have to close and re-open the PowerShell console every time I need to run a build so there had to be a work-around for this.</p>  <p>After searching the web for a solution, I couldn’t find anything that was “easy” and worth the effort to get it to work.</p>  <blockquote>   <p>EX: One solution was to create a new AppDomain, do the necessary work and the close the AppDomain which would release the lock on the file.</p>    <p>I’ve never done this myself, and even thought there is example code out there to get this accomplished, it just seemed over the top for what I was trying to do, and back to my previous criteria it wasn’t “worth the effort to get it to work”</p> </blockquote>  <p>Then I remembered in a previous life I used an overload that took an array of bytes to load the an assembly.</p>  <blockquote>   <p>[System.Reflection.Assembly]::Load($assemblyBytes)</p> </blockquote>  <p>After spiking it in PowerShell with the below test. I was quite happy with the solution, so I thought I’d throw it out there.</p>  <p>Just stream the assembly from disk into a byte array manually, and call assembly load from there.</p>  <p>Here’s my test case which shows that the file is not locked after it was loaded into the PowerShell runtime</p>  <pre>$file = &quot;.\Moq.dll&quot;
$tempFileName = &quot;.\Moq-Renamed.dll&quot;

$fileStream = ([System.IO.FileInfo] (Get-Item $file)).OpenRead();
$assemblyBytes = new-object byte[] $fileStream.Length
$fileStream.Read($assemblyBytes, 0, $fileStream.Length);
$fileStream.Close();

$assemblyLoaded = [System.Reflection.Assembly]::Load($assemblyBytes);

# notice that we can move the file on disk after 
# it's loaded into the powershell runtime
Move-Item $file $tempFileName
Move-Item $tempFileName $file 

# and display the assembly information to show we still have it in memory
echo $assemblyLoaded</pre>

<p>After that test passed, and the main reason I wanted to do this, I wrote the “get-assembly-version” PowerShell function.</p>

<pre><strike>function get-assembly-version() {
    param([string] $file)
    
    # load the assembly bytes quickly - as to not lock the file for too long
    $fileStream = ([System.IO.FileInfo] (Get-Item $file)).OpenRead()
    $assemblyBytes = new-object byte[] $fileStream.Length
    $fileStream.Read($assemblyBytes, 0, $fileStream.Length) | Out-Null #out null this because this function should only return the version &amp; this call was outputting some garbage number
    $fileStream.Close()
    
    # return the version of the assembly
    [System.Reflection.Assembly]::Load($assemblyBytes).GetName().Version;
}

$version = get-assembly-version(&quot;.\Moq.dll&quot;)

echo &quot;Loaded v$($version.Major).$($version.Minor).$($version.Build).$($version.Revision) version of $file&quot;</strike></pre>
Hope this helps someone out there! 

<p></p>

<p>&#160;</p>

<p><strong>UPDATE:</strong></p>

<p><a href="http://achuebrigens.wordpress.com">Martin</a> commented below on a much better solution to the assembly version info problem. Amazing how complicated we can make things if we don’t know the path.</p>

<pre>
function get-assembly-version() {
    param([string] $file)
    
    $version = [System.Reflection.AssemblyName]::GetAssemblyName($file).Version;
    
    #format the version and output it...
    $version
}</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Removing WSUS</title>
		<link>http://elegantcode.com/2009/12/01/removing-wsus/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=removing-wsus</link>
		<comments>http://elegantcode.com/2009/12/01/removing-wsus/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 21:53:49 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[WSUS]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/01/removing-wsus/</guid>
		<description><![CDATA[A while back, the company I work for experimented with setting up a Windows Server Update Service (WSUS).&#160; The idea is that you have one server that goes out and downloads all of the hotfixes, service packs, and so on for your network – then each of your client machines goes directly to the local [...]]]></description>
			<content:encoded><![CDATA[<p>A while back, the company I work for experimented with setting up a Windows Server Update Service (WSUS).&#160; The idea is that you have one server that goes out and downloads all of the hotfixes, service packs, and so on for your network – then each of your client machines goes directly to the local WSUS server to get the weekly dose of patches, configurable by various group policies, and with monitoring to make sure that everything is going smoothly.&#160; At the time we set it up, we were having crushing bandwidth problems – two servers downloading a service pack would pretty much disable the building…</p>  <p>Over time, the bandwidth problems were fixed, and as sometimes happens the WSUS server crumbled to dust.&#160; For the most part nobody noticed – new servers and clients were not configured with the WSUS policy, downloading their hotfixes direct from Microsoft through plentiful bandwidth.&#160; Unfortunately, older server and clients were left in the dark, sending cries out to a WSUS URL that will never respond...&#160; oops</p>  <h4>To Fix (and get your automatic updates to work again):</h4>  <p>Delete the registry key at “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate”.&#160; For fun, restart the “Windows Update” service (not sure if this is necessary).&#160; </p>  <p>I found <a href="http://www.d.umn.edu/itss/security/sus/" target="_blank">this VBS file</a> to be useful in figuring out if a server was still trying to use an old WSUS install, or if the problem was group-policy related.&#160; </p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/01/removing-wsus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PDC Notes</title>
		<link>http://elegantcode.com/2009/11/17/pdc-notes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pdc-notes</link>
		<comments>http://elegantcode.com/2009/11/17/pdc-notes/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 17:23:30 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/17/pdc-notes/</guid>
		<description><![CDATA[I am grateful to INETA to be attending PDC this year. Also, I grateful to Visual Stuart, who is letting me crash in his room. Turns out, I am a cheap skate :) I am sitting in the keynote on Tuesday and thinking about the week. In addition to the Wait? What the… Wordpress moving [...]]]></description>
			<content:encoded><![CDATA[<p>I am grateful to INETA to be attending <a href="http://microsoftpdc.com">PDC</a> this year. Also, I grateful to <a href="http://visualstuart.com">Visual Stuart</a>, who is letting me crash in his room. Turns out, I am a cheap skate :)</p>  <p>I am sitting in the keynote on Tuesday and thinking about the week. In addition to the </p>  <blockquote>   <p><font style="background-color: #ffffff">Wait? What the… Wordpress moving into the Azure cloud? Sweet!</font></p> </blockquote>  <p>volunteer sessions I am doing for INETA, I am hosting a Birds of a Feather session with Mike Vincent. Our BOF is this afternoon and is entitled, “Agile Tales of Triumph, Tribulation, Tools, and Teams”. Drop by and join the discussion to learn </p>  <blockquote>   <p><font style="background-color: #ffffff">Code name Dallas: A uniform way to access data in the cloud and mash it all up.</font></p> </blockquote>  <p>and share what really works.</p>  <p>It has been very cool to meet many of the Pluralsight instructors for the first time. We all live in different parts of the world, and PDC provides that opportunity for us to </p>  <blockquote>   <p>Everyone get your 3D glasses on! Oh, that was very anti-climactic.</p> </blockquote>  <p>all actually shake physical hands rather than electronic ones.</p>  <p>Also, drop by the Pluralsight booth and share your developer stories with me. Here’s the sneak peek as to why: <font style="background-color: #ffffff"><a href="http://www.pluralsight.com/main/pluralcast/default.aspx">Pluralcast</a>. More on that in another post. Suffice </font></p>  <blockquote>   <p><font style="background-color: #ffffff">I think that guy onstage is showing an iPhone and talking about how easy it was to write an app for it. Weird.</font></p> </blockquote>  <p><font style="background-color: #ffffff">to say </font>there will be some changes in the Elegant Code Cast.</p>  <blockquote>   <p>Did he just say, “Create applications for the good of the republic?” Seriously?</p> </blockquote>  <p>Lastly, if you see me running around the halls, please stop me and say, Hello.” It’s very cool to be able to meet people I usually only get to chat with online. If you are looking for a <a href="http://guild3.com">great developer team</a> to build your next big thing, we can talk about that, too!</p>  <blockquote>   <p>Please stop saying “3 screens in the cloud.”</p> </blockquote>  <p>Ray Ozzie final points from the keynote:</p>  <ol>   <li>Bet your next user experience on Windows 7</li>    <li>When thinking of the cloud, bet on Azure.</li>    <li>Take a moment to think about how the world is changing and the potential role of cloud in that world.</li> </ol>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/17/pdc-notes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>StructureMap and SharePoint</title>
		<link>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=structuremap-and-sharepoint</link>
		<comments>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 18:00:22 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[StructureMap]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/</guid>
		<description><![CDATA[I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; </p>  <p>I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user is authorized to use.&#160; The source of this data (names, URLs, etc.) comes from an external-to-SharePoint system, accessed through another C# assembly.&#160; Once the web part gets the data there is some more processing to be done – we need to do more than just blindly display a list of URLs.&#160; Rather than get into details I’m just going to do some handwaving here and say that “if you have access to X, then {stuff happens}, or if you have access to Y then {other stuff happens}.”&#160; You know, business logic, stuff that is good to test.</p>  <p>the first thing I need to do is get business logic out of the WebPart and into something that I can write without having to reset AppPools over and over, not to mention have some unit tests to verify I’m going in the right direction.&#160; So, I created a standard application service class which has a dependency on the external authorization system, via constructor injection.&#160; </p>  <pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> AuthorizedAppsService : IAuthorizedAppsService
{
  <span class="kwrd">private</span> <span class="kwrd">readonly</span> ExternalAuthorizeService authService;

  <span class="kwrd">public</span> AuthorizedAppsService(
    ExternalAuthorizeService authService) 
  {
    <span class="kwrd">this</span>.authService = authService;
  }

  <span class="kwrd">public</span> AuthorizedApplications GetAuthorizedApplications(
                                  <span class="kwrd">string</span> userName)
  {
    var allApps = authService.AuthorizedApplications(userName);
    <span class="rem">// business logic stuff happens here</span>
    <span class="kwrd">return</span> thoseResultsWeJustFiguredOut;
  }
}</pre>

<p>Next, I created a StructureMap Registry class to scan my assemblies, as well as adding in the details of how to create this external authorize service, using the typical method: <style type="text/css">




.csharpcode, .csharpcode pre
{
	font-size: x-small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style></p>

<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyRegistry : Registry
{
  <span class="kwrd">public</span> MyRegistry()
  {
    Scan(scanner =&gt; {
      scanner.TheCallingAssembly();
      scanner.AssemblyContainingType(<span class="kwrd">typeof</span>(MyRegistry));
      scanner.WithDefaultConventions();
      });

    ForRequestedType&lt;ExternalAuthorizeService&gt;()
      .AsSingletons()
      .TheDefault.Is.ConstructedBy(c =&gt; Provider.GetService());

    <span class="rem">// other dependency configuration...</span>
  }
  <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> InitializeForSharepoint()
  {
    ObjectFactory.Initialize(init =&gt; init.AddRegistry&lt;MyRegistry&gt;());
    ObjectFactory.AssertConfigurationIsValid();
  }
}</pre>

<p>And then, what remains is to have SharePoint call my StructureMap initialization when my SharePoint application starts up.&#160; In an MVC or WebForms app, I’d just add code to the appropriate place in Global.asax.cs, but in SharePointLand, this is looked down on.&#160; Instead, the preferred mechanism seems to be to use an HttpModule and a FeatureReceiver to plug the Module into the app’s web.config.</p>

<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyStartupModule : IHttpModule
{
  <span class="kwrd">public</span> <span class="kwrd">void</span> Init(HttpApplication context)
  {
        ConfigureOtherStuff();
        MyRegistry.InitializeForSharepoint();
  }
  <span class="kwrd">public</span> <span class="kwrd">void</span> Dispose() { }
}</pre>

<p>And then the FeatureReceiver to alter the app’s Web.Config looks something like this (note I borrowed most of this code from another sample SharePoint project:</p>

<p>&#160;</p>

<pre class="csharpcode"><span class="rem">//</span>
<span class="rem">// this is borrowing heavily from http://www.codeplex.com/SPAXO</span>
<span class="rem">// </span>
<span class="kwrd">public</span> <span class="kwrd">class</span> StartupFeatureReceiver : SPFeatureReceiver
{
  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureActivated(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    AddWebConfigEntry(webApp);
    UpdateApp(webApp);
  }

  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureDeactivating(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    RemoveWebConfigEntry(webApp);
    UpdateApp(webApp);
  }


  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> AddWebConfigEntry(SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    var existingModifications = 
             <span class="kwrd">new</span> List&lt;SPWebConfigModification&gt;(
                      webApp.WebConfigModifications);
    <span class="kwrd">if</span> (existingModifications.FindIndex(
                    <span class="kwrd">value</span> =&gt;
                        <span class="kwrd">value</span>.Name == mod.Name &amp;&amp;
                        <span class="kwrd">value</span>.Value == mod.Value &amp;&amp;
                        <span class="kwrd">value</span>.Owner == mod.Owner) == -1)
    {
      <span class="rem">// If the modifcation does not already exist </span>
      <span class="rem">// add the entry to the config</span>
      webApp.WebConfigModifications.Add(mod);
    }
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> RemoveWebConfigEntry(
            SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    webApp.WebConfigModifications.Remove(mod);
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> SPWebConfigModification GetModification()
  {
    <span class="kwrd">string</span> asmName = <span class="kwrd">typeof</span>(StartupModule).AssemblyQualifiedName;
    <span class="kwrd">string</span> typeName = <span class="kwrd">typeof</span>(StartupModule).FullName;

    <span class="kwrd">return</span> <span class="kwrd">new</span> SPWebConfigModification
      {
        Path = <span class="str">&quot;configuration/system.web/httpModules&quot;</span>,
        Name = String.Format(CultureInfo.InvariantCulture,
                <span class="str">&quot;add[@name='{0}'][@type='{1}']&quot;</span>,
                typeName, asmName),
        Sequence = 0,
        Owner = asmName,
        Type = SPWebConfigModification.
                    SPWebConfigModificationType.EnsureChildNode,
        Value = String.Format(CultureInfo.InvariantCulture,
                  <span class="str">&quot;&lt;add name='{0}' type='{1}' /&gt;&quot;</span>,
                  typeName, asmName)
      };
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> UpdateApp(SPWebApplication webApp)
  {
    <span class="rem">// Update the Web App and apply the changes </span>
    <span class="rem">// to all servers in the farm</span>
    webApp.Update();
    webApp.Farm.Services
        .GetValue&lt;SPWebService&gt;()
        .ApplyWebConfigModifications();
  }
}</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Integration Test Brought to you by Powershell &amp; NUnit &#8211; with a Little Specification Syntax for Flavoring</title>
		<link>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=silverlight-profiling-powershell-helper</link>
		<comments>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/#comments</comments>
		<pubDate>Sat, 15 May 2010 16:47:22 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/</guid>
		<description><![CDATA[I was playing around with some Silverlight profiling the other night to see if I could find any obvious issues with my open source project StatLight and wound up writing a little script in PowerShell I hoped someone might find helpful. But I didn’t know you could profile a Silverlight app. I didn’t until I [...]]]></description>
			<content:encoded><![CDATA[<p>I was playing around with some Silverlight profiling the other night to see if I could find any obvious issues with my open source project <a href="http://statlight.net" target="_blank">StatLight</a> and wound up writing a little script in PowerShell I hoped someone might find helpful.</p>  <h4>But I didn’t know you could profile a Silverlight app.</h4>  <p>I didn’t until I started doing some digging online. Now, the Silverlight profiling story (at least from what I’ve seen/tried) is not near the easy of say <a href="http://www.red-gate.com/products/ants_performance_profiler/index.htm">Redgate ANTS Performance Profiler</a>. However, it’s do-able. (And with this helper script – hopefully a little simpler?)</p>  <h4>How can I profile a Silverlight Application?</h4>  <p>I would recommend you read the following blog, which explains one way of doing it very well.</p>  <p><a title="http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx" href="http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx">http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx</a></p>  <h4>So… what’s this script for?</h4>  <p>If you read the blog above, or have done this before, then you probably noticed that there was quite a series of commands you had to execute before you could wind up with a performance report. </p>  <p>I threw together a quick little PowerShell script in an attempt to automate smooth out the process.</p>  <h4>Hot do I use it?</h4>  <ol>   <li>Download the script &amp; save it somewhere. <a href="http://github.com/staxmanade/Scripts/blob/master/SilverlightProfiler.ps1"><strong>http://github.com/staxmanade/Scripts/blob/master/SilverlightProfiler.ps1</strong></a> </li>    <li>Open the PowerShell console. cd to the directory your xap/assemblies are stored.      <br />(EX: {myProject}\Bin\Debug\ ) </li>    <li>Execute:      <br />{pathToScript}\SilverlightProfiler.ps1 -urlPath &quot;{myProject}\Bin\Debug\TestPage.html&quot; </li>    <li>When your done profiling press enter to signal that your done.      <p></p> Once complete, it will print the location your profiling report was saved. You can then open it with Visual Studio.</li> </ol>  <h5>Couple of disclaimers.</h5>  <ul>   <li>Some paths are hard-coded to my x86 machine. </li>    <li>I had troubles running the built in visual studio .bat files (from powershell) that are supposed to set the environment variables. So I extracted out what vars I could find to make it work. </li>    <li>I’m not a profiling expert – just hacked this together to get it to work for me.</li> </ul>  <p>I hope this is useful, and if you know of a better way, I’m always interested in hearing your feedback.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Elegant Code &#187; Microsoft</title>
	<atom:link href="http://elegantcode.com/category/microsoft/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Buy Quinine Without Prescription</title>
		<link>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=awarded-microsoft-community-contributor-award-2012</link>
		<comments>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 23:03:17 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[awards]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/</guid>
		<description><![CDATA[Buy Quinine Without Prescription, Today I received an email informing me that I have been awarded the Microsoft Community Contributor Award.&#160; This is the second time I have been awarded this particular award and it feels just as good this time as it did last time.&#160; I’m not sure how you go about getting nominated [...]]]></description>
			<content:encoded><![CDATA[<p> <p> <b>Buy Quinine Without Prescription</b>, Today I received an email informing me that I have been awarded the Microsoft Community Contributor Award.&#160; This is the second time I have been awarded this particular award and it feels just as good this time as it did last time.&#160; I’m not sure how you go about getting nominated for this award, but apparently I am doing something right.</p>  <p>I would like to thank whoever nominated me for this award and Microsoft for listening to that person.&#160; I would most of all like to thank the community.&#160; Without the support of the community I would probably still be a cop. Oh, <b>australia, uk, us, usa</b>, <b>Discount Quinine</b>, you probably didn’t know that about me.</p>  <p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="Brian Lagunas awarded Microsoft Community Contributor Award" border="0" alt="Brian Lagunas awarded Microsoft Community Contributor Award" src="http://elegantcode.com/wp-content/uploads/2012/03/MCC12_Logo_Horizontal_Full-color.jpg" width="500" height="202" /></p>.  Quinine pharmacy.  Herbal Quinine.  Order Quinine no prescription.  What is Quinine.  Buy Quinine online cod.  Quinine street price.  Quinine use.  Effects of Quinine.  Buy Quinine online no prescription.  Is Quinine safe.  Where can i cheapest Quinine online.  Order Quinine online overnight delivery no prescription.  Where to buy Quinine.  Quinine duration.  Quinine from canada.  Fast shipping Quinine.  After Quinine.  Quinine no prescription.  Quinine cost.  Quinine alternatives.  Quinine samples.  Buy Quinine from canada.  Buy Quinine no prescription.  Ordering Quinine online.  Quinine mg.  Quinine dangers.  Where can i buy Quinine online.  Purchase Quinine online.  Quinine maximum dosage.  Buy Quinine online cod.  Rx free Quinine.  Order Quinine from United States pharmacy.  Buy generic Quinine.  No prescription Quinine online.  Quinine australia, uk, us, usa.  Quinine overnight.  Buy Quinine without a prescription.  Quinine online cod.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4728'>Ventolin For Sale</a>. <a href='http://elegantcode.com/?p=4184'>Synthroid For Sale</a>. <a href='http://elegantcode.com/?p=4384'>Buy Ultram Without Prescription</a>. <a href='http://elegantcode.com/?p=4373'>Topamax For Sale</a>. <a href='http://elegantcode.com/?p=5156'>Amoxicillin For Sale</a>. <a href='http://elegantcode.com/?p=4384'>Order Ultram online overnight delivery no prescription</a>. <a href='http://elegantcode.com/?p=4683'>Inderal schedule</a>. <a href='http://elegantcode.com/?p=4822'>About Hydrochlorothiazide</a>. <a href='http://elegantcode.com/?p=4728'>Ventolin australia, uk, us, usa</a>. <a href='http://elegantcode.com/?p=4694'>Human Growth Hormone interactions</a>.<br />
<b>Trackbacks from:</b> <a href='http://social-blend.com/?p=1163'>Buy Quinine Without Prescription</a>. <a href='http://www.quarterlives.com/?p=710'>Buy Quinine Without Prescription</a>. <a href='http://4realz.net/?p=1873'>Buy Quinine Without Prescription</a>. <a href='http://www.macneilbmx.com/blog/?p=6577'>Buy Quinine Without Prescription</a>. <a href='http://www.greatgreengoods.com/?p=2921'>Buy Quinine Without Prescription</a>. <a href='http://blog.farmland.org/?p=1913'>Online buy Quinine without a prescription</a>. <a href='http://reversemortgagedaily.com/?p=14688'>Is Quinine addictive</a>. <a href='http://linuxologist.com/?p=1495'>Quinine over the counter</a>. <a href='http://home.officesnapshots.com/?p=235'>Order Quinine from United States pharmacy</a>. <a href='http://evanrapoport.com/?p=720'>Generic Quinine</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Silverlight Profiling PowerShell helper.</title>
		<link>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=silverlight-profiling-powershell-helper</link>
		<comments>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/#comments</comments>
		<pubDate>Sat, 15 May 2010 16:47:22 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/</guid>
		<description><![CDATA[I was playing around with some Silverlight profiling the other night to see if I could find any obvious issues with my open source project StatLight and wound up writing a little script in PowerShell I hoped someone might find helpful. But I didn’t know you could profile a Silverlight app. I didn’t until I [...]]]></description>
			<content:encoded><![CDATA[<p>I was playing around with some Silverlight profiling the other night to see if I could find any obvious issues with my open source project <a href="http://statlight.net" target="_blank">StatLight</a> and wound up writing a little script in PowerShell I hoped someone might find helpful.</p>  <h4>But I didn’t know you could profile a Silverlight app.</h4>  <p>I didn’t until I started doing some digging online. Now, the Silverlight profiling story (at least from what I’ve seen/tried) is not near the easy of say <a href="http://www.red-gate.com/products/ants_performance_profiler/index.htm">Redgate ANTS Performance Profiler</a>. However, it’s do-able. (And with this helper script – hopefully a little simpler?)</p>  <h4>How can I profile a Silverlight Application?</h4>  <p>I would recommend you read the following blog, which explains one way of doing it very well.</p>  <p><a title="http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx" href="http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx">http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx</a></p>  <h4>So… what’s this script for?</h4>  <p>If you read the blog above, or have done this before, then you probably noticed that there was quite a series of commands you had to execute before you could wind up with a performance report. </p>  <p>I threw together a quick little PowerShell script in an attempt to automate smooth out the process.</p>  <h4>Hot do I use it?</h4>  <ol>   <li>Download the script &amp; save it somewhere. <a href="http://github.com/staxmanade/Scripts/blob/master/SilverlightProfiler.ps1"><strong>http://github.com/staxmanade/Scripts/blob/master/SilverlightProfiler.ps1</strong></a> </li>    <li>Open the PowerShell console. cd to the directory your xap/assemblies are stored.      <br />(EX: {myProject}\Bin\Debug\ ) </li>    <li>Execute:      <br />{pathToScript}\SilverlightProfiler.ps1 -urlPath &quot;{myProject}\Bin\Debug\TestPage.html&quot; </li>    <li>When your done profiling press enter to signal that your done.      <p></p> Once complete, it will print the location your profiling report was saved. You can then open it with Visual Studio.</li> </ol>  <h5>Couple of disclaimers.</h5>  <ul>   <li>Some paths are hard-coded to my x86 machine. </li>    <li>I had troubles running the built in visual studio .bat files (from powershell) that are supposed to set the environment variables. So I extracted out what vars I could find to make it work. </li>    <li>I’m not a profiling expert – just hacked this together to get it to work for me.</li> </ul>  <p>I hope this is useful, and if you know of a better way, I’m always interested in hearing your feedback.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tell me what you don&#8217;t like about TFS 2010</title>
		<link>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tell-me-what-you-dont-like-about-tfs-2010</link>
		<comments>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/#comments</comments>
		<pubDate>Sat, 15 May 2010 15:48:18 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Team System]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/</guid>
		<description><![CDATA[I know that a lot of people have had bad experiences with TFS over the years, and so does the TFS development team. The team at Microsoft is very intent on learning what it is that people find irritating, problematic, or difficult, and correcting it. Some major headway was made with the 2010 release of [...]]]></description>
			<content:encoded><![CDATA[<p>I know that a lot of people have had bad experiences with TFS over the years, and so does the TFS development team. The team at Microsoft is very intent on learning what it is that people find irritating, problematic, or difficult, and correcting it. Some major headway was made with the 2010 release of Team Foundation Server to make it easier to setup and administer, and also to improve the usability of several of its key features.</p>  <p>That said, there is still room for improvement and both the team and I understand there are still opportunities to improve. In all seriousness, the team at Microsoft wants to make TFS an approachable, no-brainer install decision for .NET teams, even small ones. This means they want to be able to compete for your attention with the likes of SVN, Git, Jira, Perforce, and anyone else making collaboration tools for developers.</p>  <p>The point of this post is for you to help me know what feedback I can give the TFS product development team as they look ahead to the next release of TFS. I am looking for legitimate feedback I can give the team on how to improve the TFS product.</p>  <p>Please bear in mind that I am interested in your feedback on TFS 2010, as TFS 2008 was improved upon 10 fold in the latest release. Also, I am not necessarily looking for feedback on Visual Studio, just the TFS side of the house. Please realize that the team who makes this product at Microsoft is just as committed and passionate about making great software as you are. They just really need your feedback to make the thing you want. In fact, they want to make a tool that every developer loves to use. Really. So what needs to change to make that the case?</p>  <p>Recall that TFS functionality is broken into the following major areas and I am looking for feedback on the 2010 version.</p>  <ul>   <li>Version Control </li>    <li>Work Item management </li>    <li>Team Foundation Build </li>    <li>SharePoint integration (optional) </li>    <li>Reporting and SSRS Integration (optional) </li> </ul>  <p>Thanks for anything you have. Thank you also for being respectful and not making this a bash-fest.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>Visual Studio: Open in Full XAML View by Default</title>
		<link>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=visual-studio-open-in-full-xaml-view-by-default</link>
		<comments>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 15:49:14 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/</guid>
		<description><![CDATA[So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane [...]]]></description>
			<content:encoded><![CDATA[<p>So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane blows.&#160; So now I have to sit and wait for VS to render my view in the preview pane, and sometimes it can take a while, if it doesn’t just completely crash.&#160; Sometimes I take the extra time to go grab a snack and beverage of my choice.&#160; </p>  <p>So here is a hidden performance increasing jewel you might find useful.&#160; We can set the default open mode to be in full XAML view.</p>  <p>First thing you need to do is in Visual Studio go to your Tools ==&gt; Options ==&gt; Text Editor ==&gt; XAML ==&gt; Miscellaneous.&#160; There you will see an option for “Always open documents in full XAML view”.&#160; Check that box.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/04/image.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="xaml options for opening in full xaml view" border="0" alt="xaml options for opening in full xaml view" src="http://elegantcode.com/wp-content/uploads/2010/04/image_thumb.png" width="244" height="146" /></a> </p>  <p>Now every time you open a XAML file it will open in full XAML view and give you one less thing to gripe about.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Looking Ahead to 2010</title>
		<link>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=looking-ahead-to-2010</link>
		<comments>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 21:02:11 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/02/09/looking-ahead-to-2010/</guid>
		<description><![CDATA[No, this isn't another prognostication post foretelling the woes of the world for the next year. This is a note to everyone who hasn't yet played with the Visual Studio ALM tools and Team Foundation Server 2010. Folks, this product is getting better. That stands to reason. After all, this is basically version 3 of [...]]]></description>
			<content:encoded><![CDATA[<p><img align="left" src="http://elegantcode.com/wp-content/uploads/2010/02/020910_2101_LookingAhea13.png" alt=""/>No, this isn't another prognostication post foretelling the woes of the world for the next year. This is a note to everyone who hasn't yet played with the Visual Studio ALM tools and Team Foundation Server 2010.
</p><p>Folks, this product is getting better. That stands to reason. After all, this is basically version 3 of the product and you know what they say! Version 3 is the one to buy. Most of the kinks are worked out now.
</p><p>Now, I won't pretend for a moment that Team Foundation Server hasn't had its challenges fitting in with agile teams. I think that has come from a history of development by a team that itself was learning and growing just like the rest of us. Now that many of the teams within Microsoft are practicing some form of iterative development with completed cycles of "all the way done", we are starting to see the influence in the tools they are producing. And the effect is not half bad.
</p><p>I have been using Visual Studio 2010 for a few months now, and with the recent release of the RC, I can see:
</p><ol><li>Performance is getting better (XAML).
</li><li>Features are getting more solid (fewer exceptions)
</li><li>The polish of the overall user experience is becoming a great example of an application I am happy to look at all day long.
</li><li>The Team Foundation Server features being added are consistent with what we are learning to be effective as an agile community.
</li></ol><p>So, where's the meat? What are these shiny features of which you speak, Mr. Starr? Well, here is a short sample because I am sitting in an airport listening to the chaos and I can't think of it all. 
</p><p>I should also say that this is a very small list of features that I personally am really excited about. The rest of the world probably has other things they care about. These are mine because I believe they have to potential to really change life on a team for the better.
</p><h2>Layer Diagrams
</h2><p>There is a major focus in this release to add UML support to Visual Studio Ultimate. OK, not a huge fan and I know some people will dog on this feature, but I am all about the Layer Diagrams. These are diagrams that we can create just like the UML diagrams that Visual Studio now supports, but the value of a Layer Diagram is that it has teeth and can bite back. 
</p><p>Here's how it works:
</p><ol><li>Create a Layer Diagram.
</li><li>Draw your favorite design pattern or desired architectural separation model using tools in the Toolbox. In a simple example, this might be to create a model of the MVP pattern. In a large example this model might show the multiple layers in my solution that uses CSLA, Silverlight with MVVM, WCF, and Entity Framework. (Hi, Scott <span style="font-family:Wingdings">J</span> You knew that was for you.)
</li><li>Add some things to it from your solution. Drop things onto the diagram and into the boxes like classes, namespaces, and Visual Studio projects.
</li><li>Now you can generate dependencies between these things and see the existing relationships. Yawn. Cool, but we get this with dependency diagrams, too.
</li><li><div>Validate the model.<br/><br/>Wait for it. . .  Grok it. . .
</div><p><br/>You got it! Yeah, that's right. Validate the LOGICAL model of your application. This is so sweet it comes on a stick. This means that not only can I verify I haven't violated my design with a bad reference or super egregious abstraction hole, but I can make this validation part of the build process and catch it if I accidently violate my own design later. Where I come from, they call that cool.
</p></li></ol><h2>Way Better Work Items
</h2><p>This is non-trivial for teams who live every day of their lives in Team Foundation Server to manage their requirements and work queues. Sure, we might all prefer note cards on the wall, but for many this is simply not possible. And for those folks who use Team Foundation Server to manage their notecards, there are some great new things to make that task easier.
</p><ol><li>Hierarchical relationships between Work Items.
</li><li>Agile planning Workbooks.
</li><li>Seamless Team Project Dashboards.
</li><li>MSF Agile 5.
</li></ol><h2>Gated Check In
</h2><p>This is a feature of Team Foundation Build that will actually build and test your software before a check-in is committed to Source Control. The mechanical effect of this is simple: Code that would break the build is never committed to Source Control. The implications are far larger, though. Think it through for a moment. What would change in your daily life if you flat out were unable to commit code that breaks the build? The short answer is, "Quality goes up." I bit more verbose answer is that I need to be more careful before committing my code.
</p><p>Yes, I know other vendors have had this feature for a while. So what? So, Team Foundation Server shouldn't have it too? It rocks and now we get it in Team Foundation Build.
</p><h2>IntelliTrace
</h2><p>I am not even sure how cool this is yet, only that it is. This feature is also known as Historical Debugging and gives the ability to step back and forth through call stacks and watched variables during a debug run. To be clear, that's <em>Back and Forth through time</em>. So, the first time I hit the breakpoint, here was the status of the code. The second time it was this. And so on. Also, I can inspect all this data on system events (like CLR events) and can therefore tap into my app at a lot of different levels.
</p><p>Now, I know that you don't need debuggers anymore because every line of code we write is Test Driven and that means we don't need debuggers, right? Yeah, sure you never need a debugger. As I said, this is just a wicked tool, but I am not yet sure how wicked. The community will definitely ferret that out over time.
</p><h2>Other Stuff
</h2><p>This only scratches the surface of what's in Visual Studio and Team Foundation Server 2010. There are a lot more things, many of them bigger and higher profile than the things I mentioned. I just happen to be in love with these particular features at the moment. As I get deeper into things, I will let you know what I see.
</p><p>One last thing, I know these tools get a lot of flak in some communities, but I feel comfortable with them. I also understand that many developers out there in the world don't get to choose their tools. Often tools are assigned. What I see is that the 2010 versions of Visual Studio and Team Foundation Server really have raised the bar. I don't feel like teams are still having to compromise on tooling to get everything they need in an integrated environment.
</p><p>Will I still run R#? Well, yeah.
</p><p>
 </p><p>
 </p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Powershell: Load assembly without locking file.</title>
		<link>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-load-assembly-without-locking-file</link>
		<comments>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 05:40:23 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/</guid>
		<description><![CDATA[I have a set of PowerShell build scripts and ran into a case where I needed to load an assembly (to get the assembly’s version) and still (at a later time) work with the assembly file on disk. A typical way to load an assembly within PowerShell is to use the Assembly.LoadFrom(filePath) # Powershell [System.Reflection.Assembly]::LoadFrom($assemblyPath) [...]]]></description>
			<content:encoded><![CDATA[<p>I have a set of PowerShell build scripts and ran into a case where I needed to load an assembly (to get the assembly’s version) and still (at a later time) work with the assembly file on disk.</p>  <p>A typical way to load an assembly within PowerShell is to use the Assembly.LoadFrom(filePath)</p>  <blockquote>   <p># Powershell</p>    <p>[System.Reflection.Assembly]::LoadFrom($assemblyPath)</p> </blockquote>  <p><a href="http://elegantcode.com/wp-content/uploads/2009/12/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2009/12/image_thumb9.png" width="690" height="391" /></a> </p>  <p>Except the problem with this (in my case) was it would <strong>lock the file for the lifespan of the PowerShell console instance</strong>. I didn’t want to have to close and re-open the PowerShell console every time I need to run a build so there had to be a work-around for this.</p>  <p>After searching the web for a solution, I couldn’t find anything that was “easy” and worth the effort to get it to work.</p>  <blockquote>   <p>EX: One solution was to create a new AppDomain, do the necessary work and the close the AppDomain which would release the lock on the file.</p>    <p>I’ve never done this myself, and even thought there is example code out there to get this accomplished, it just seemed over the top for what I was trying to do, and back to my previous criteria it wasn’t “worth the effort to get it to work”</p> </blockquote>  <p>Then I remembered in a previous life I used an overload that took an array of bytes to load the an assembly.</p>  <blockquote>   <p>[System.Reflection.Assembly]::Load($assemblyBytes)</p> </blockquote>  <p>After spiking it in PowerShell with the below test. I was quite happy with the solution, so I thought I’d throw it out there.</p>  <p>Just stream the assembly from disk into a byte array manually, and call assembly load from there.</p>  <p>Here’s my test case which shows that the file is not locked after it was loaded into the PowerShell runtime</p>  <pre>$file = &quot;.\Moq.dll&quot;
$tempFileName = &quot;.\Moq-Renamed.dll&quot;

$fileStream = ([System.IO.FileInfo] (Get-Item $file)).OpenRead();
$assemblyBytes = new-object byte[] $fileStream.Length
$fileStream.Read($assemblyBytes, 0, $fileStream.Length);
$fileStream.Close();

$assemblyLoaded = [System.Reflection.Assembly]::Load($assemblyBytes);

# notice that we can move the file on disk after 
# it's loaded into the powershell runtime
Move-Item $file $tempFileName
Move-Item $tempFileName $file 

# and display the assembly information to show we still have it in memory
echo $assemblyLoaded</pre>

<p>After that test passed, and the main reason I wanted to do this, I wrote the “get-assembly-version” PowerShell function.</p>

<pre><strike>function get-assembly-version() {
    param([string] $file)
    
    # load the assembly bytes quickly - as to not lock the file for too long
    $fileStream = ([System.IO.FileInfo] (Get-Item $file)).OpenRead()
    $assemblyBytes = new-object byte[] $fileStream.Length
    $fileStream.Read($assemblyBytes, 0, $fileStream.Length) | Out-Null #out null this because this function should only return the version &amp; this call was outputting some garbage number
    $fileStream.Close()
    
    # return the version of the assembly
    [System.Reflection.Assembly]::Load($assemblyBytes).GetName().Version;
}

$version = get-assembly-version(&quot;.\Moq.dll&quot;)

echo &quot;Loaded v$($version.Major).$($version.Minor).$($version.Build).$($version.Revision) version of $file&quot;</strike></pre>
Hope this helps someone out there! 

<p></p>

<p>&#160;</p>

<p><strong>UPDATE:</strong></p>

<p><a href="http://achuebrigens.wordpress.com">Martin</a> commented below on a much better solution to the assembly version info problem. Amazing how complicated we can make things if we don’t know the path.</p>

<pre>
function get-assembly-version() {
    param([string] $file)
    
    $version = [System.Reflection.AssemblyName]::GetAssemblyName($file).Version;
    
    #format the version and output it...
    $version
}</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Removing WSUS</title>
		<link>http://elegantcode.com/2009/12/01/removing-wsus/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=removing-wsus</link>
		<comments>http://elegantcode.com/2009/12/01/removing-wsus/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 21:53:49 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[WSUS]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/01/removing-wsus/</guid>
		<description><![CDATA[A while back, the company I work for experimented with setting up a Windows Server Update Service (WSUS).&#160; The idea is that you have one server that goes out and downloads all of the hotfixes, service packs, and so on for your network – then each of your client machines goes directly to the local [...]]]></description>
			<content:encoded><![CDATA[<p>A while back, the company I work for experimented with setting up a Windows Server Update Service (WSUS).&#160; The idea is that you have one server that goes out and downloads all of the hotfixes, service packs, and so on for your network – then each of your client machines goes directly to the local WSUS server to get the weekly dose of patches, configurable by various group policies, and with monitoring to make sure that everything is going smoothly.&#160; At the time we set it up, we were having crushing bandwidth problems – two servers downloading a service pack would pretty much disable the building…</p>  <p>Over time, the bandwidth problems were fixed, and as sometimes happens the WSUS server crumbled to dust.&#160; For the most part nobody noticed – new servers and clients were not configured with the WSUS policy, downloading their hotfixes direct from Microsoft through plentiful bandwidth.&#160; Unfortunately, older server and clients were left in the dark, sending cries out to a WSUS URL that will never respond...&#160; oops</p>  <h4>To Fix (and get your automatic updates to work again):</h4>  <p>Delete the registry key at “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate”.&#160; For fun, restart the “Windows Update” service (not sure if this is necessary).&#160; </p>  <p>I found <a href="http://www.d.umn.edu/itss/security/sus/" target="_blank">this VBS file</a> to be useful in figuring out if a server was still trying to use an old WSUS install, or if the problem was group-policy related.&#160; </p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/01/removing-wsus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PDC Notes</title>
		<link>http://elegantcode.com/2009/11/17/pdc-notes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pdc-notes</link>
		<comments>http://elegantcode.com/2009/11/17/pdc-notes/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 17:23:30 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/17/pdc-notes/</guid>
		<description><![CDATA[I am grateful to INETA to be attending PDC this year. Also, I grateful to Visual Stuart, who is letting me crash in his room. Turns out, I am a cheap skate :) I am sitting in the keynote on Tuesday and thinking about the week. In addition to the Wait? What the… Wordpress moving [...]]]></description>
			<content:encoded><![CDATA[<p>I am grateful to INETA to be attending <a href="http://microsoftpdc.com">PDC</a> this year. Also, I grateful to <a href="http://visualstuart.com">Visual Stuart</a>, who is letting me crash in his room. Turns out, I am a cheap skate :)</p>  <p>I am sitting in the keynote on Tuesday and thinking about the week. In addition to the </p>  <blockquote>   <p><font style="background-color: #ffffff">Wait? What the… Wordpress moving into the Azure cloud? Sweet!</font></p> </blockquote>  <p>volunteer sessions I am doing for INETA, I am hosting a Birds of a Feather session with Mike Vincent. Our BOF is this afternoon and is entitled, “Agile Tales of Triumph, Tribulation, Tools, and Teams”. Drop by and join the discussion to learn </p>  <blockquote>   <p><font style="background-color: #ffffff">Code name Dallas: A uniform way to access data in the cloud and mash it all up.</font></p> </blockquote>  <p>and share what really works.</p>  <p>It has been very cool to meet many of the Pluralsight instructors for the first time. We all live in different parts of the world, and PDC provides that opportunity for us to </p>  <blockquote>   <p>Everyone get your 3D glasses on! Oh, that was very anti-climactic.</p> </blockquote>  <p>all actually shake physical hands rather than electronic ones.</p>  <p>Also, drop by the Pluralsight booth and share your developer stories with me. Here’s the sneak peek as to why: <font style="background-color: #ffffff"><a href="http://www.pluralsight.com/main/pluralcast/default.aspx">Pluralcast</a>. More on that in another post. Suffice </font></p>  <blockquote>   <p><font style="background-color: #ffffff">I think that guy onstage is showing an iPhone and talking about how easy it was to write an app for it. Weird.</font></p> </blockquote>  <p><font style="background-color: #ffffff">to say </font>there will be some changes in the Elegant Code Cast.</p>  <blockquote>   <p>Did he just say, “Create applications for the good of the republic?” Seriously?</p> </blockquote>  <p>Lastly, if you see me running around the halls, please stop me and say, Hello.” It’s very cool to be able to meet people I usually only get to chat with online. If you are looking for a <a href="http://guild3.com">great developer team</a> to build your next big thing, we can talk about that, too!</p>  <blockquote>   <p>Please stop saying “3 screens in the cloud.”</p> </blockquote>  <p>Ray Ozzie final points from the keynote:</p>  <ol>   <li>Bet your next user experience on Windows 7</li>    <li>When thinking of the cloud, bet on Azure.</li>    <li>Take a moment to think about how the world is changing and the potential role of cloud in that world.</li> </ol>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/17/pdc-notes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>StructureMap and SharePoint</title>
		<link>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=structuremap-and-sharepoint</link>
		<comments>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 18:00:22 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[StructureMap]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/</guid>
		<description><![CDATA[I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; </p>  <p>I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user is authorized to use.&#160; The source of this data (names, URLs, etc.) comes from an external-to-SharePoint system, accessed through another C# assembly.&#160; Once the web part gets the data there is some more processing to be done – we need to do more than just blindly display a list of URLs.&#160; Rather than get into details I’m just going to do some handwaving here and say that “if you have access to X, then {stuff happens}, or if you have access to Y then {other stuff happens}.”&#160; You know, business logic, stuff that is good to test.</p>  <p>the first thing I need to do is get business logic out of the WebPart and into something that I can write without having to reset AppPools over and over, not to mention have some unit tests to verify I’m going in the right direction.&#160; So, I created a standard application service class which has a dependency on the external authorization system, via constructor injection.&#160; </p>  <pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> AuthorizedAppsService : IAuthorizedAppsService
{
  <span class="kwrd">private</span> <span class="kwrd">readonly</span> ExternalAuthorizeService authService;

  <span class="kwrd">public</span> AuthorizedAppsService(
    ExternalAuthorizeService authService) 
  {
    <span class="kwrd">this</span>.authService = authService;
  }

  <span class="kwrd">public</span> AuthorizedApplications GetAuthorizedApplications(
                                  <span class="kwrd">string</span> userName)
  {
    var allApps = authService.AuthorizedApplications(userName);
    <span class="rem">// business logic stuff happens here</span>
    <span class="kwrd">return</span> thoseResultsWeJustFiguredOut;
  }
}</pre>

<p>Next, I created a StructureMap Registry class to scan my assemblies, as well as adding in the details of how to create this external authorize service, using the typical method: <style type="text/css">




.csharpcode, .csharpcode pre
{
	font-size: x-small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style></p>

<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyRegistry : Registry
{
  <span class="kwrd">public</span> MyRegistry()
  {
    Scan(scanner =&gt; {
      scanner.TheCallingAssembly();
      scanner.AssemblyContainingType(<span class="kwrd">typeof</span>(MyRegistry));
      scanner.WithDefaultConventions();
      });

    ForRequestedType&lt;ExternalAuthorizeService&gt;()
      .AsSingletons()
      .TheDefault.Is.ConstructedBy(c =&gt; Provider.GetService());

    <span class="rem">// other dependency configuration...</span>
  }
  <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> InitializeForSharepoint()
  {
    ObjectFactory.Initialize(init =&gt; init.AddRegistry&lt;MyRegistry&gt;());
    ObjectFactory.AssertConfigurationIsValid();
  }
}</pre>

<p>And then, what remains is to have SharePoint call my StructureMap initialization when my SharePoint application starts up.&#160; In an MVC or WebForms app, I’d just add code to the appropriate place in Global.asax.cs, but in SharePointLand, this is looked down on.&#160; Instead, the preferred mechanism seems to be to use an HttpModule and a FeatureReceiver to plug the Module into the app’s web.config.</p>

<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyStartupModule : IHttpModule
{
  <span class="kwrd">public</span> <span class="kwrd">void</span> Init(HttpApplication context)
  {
        ConfigureOtherStuff();
        MyRegistry.InitializeForSharepoint();
  }
  <span class="kwrd">public</span> <span class="kwrd">void</span> Dispose() { }
}</pre>

<p>And then the FeatureReceiver to alter the app’s Web.Config looks something like this (note I borrowed most of this code from another sample SharePoint project:</p>

<p>&#160;</p>

<pre class="csharpcode"><span class="rem">//</span>
<span class="rem">// this is borrowing heavily from http://www.codeplex.com/SPAXO</span>
<span class="rem">// </span>
<span class="kwrd">public</span> <span class="kwrd">class</span> StartupFeatureReceiver : SPFeatureReceiver
{
  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureActivated(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    AddWebConfigEntry(webApp);
    UpdateApp(webApp);
  }

  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureDeactivating(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    RemoveWebConfigEntry(webApp);
    UpdateApp(webApp);
  }


  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> AddWebConfigEntry(SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    var existingModifications = 
             <span class="kwrd">new</span> List&lt;SPWebConfigModification&gt;(
                      webApp.WebConfigModifications);
    <span class="kwrd">if</span> (existingModifications.FindIndex(
                    <span class="kwrd">value</span> =&gt;
                        <span class="kwrd">value</span>.Name == mod.Name &amp;&amp;
                        <span class="kwrd">value</span>.Value == mod.Value &amp;&amp;
                        <span class="kwrd">value</span>.Owner == mod.Owner) == -1)
    {
      <span class="rem">// If the modifcation does not already exist </span>
      <span class="rem">// add the entry to the config</span>
      webApp.WebConfigModifications.Add(mod);
    }
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> RemoveWebConfigEntry(
            SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    webApp.WebConfigModifications.Remove(mod);
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> SPWebConfigModification GetModification()
  {
    <span class="kwrd">string</span> asmName = <span class="kwrd">typeof</span>(StartupModule).AssemblyQualifiedName;
    <span class="kwrd">string</span> typeName = <span class="kwrd">typeof</span>(StartupModule).FullName;

    <span class="kwrd">return</span> <span class="kwrd">new</span> SPWebConfigModification
      {
        Path = <span class="str">&quot;configuration/system.web/httpModules&quot;</span>,
        Name = String.Format(CultureInfo.InvariantCulture,
                <span class="str">&quot;add[@name='{0}'][@type='{1}']&quot;</span>,
                typeName, asmName),
        Sequence = 0,
        Owner = asmName,
        Type = SPWebConfigModification.
                    SPWebConfigModificationType.EnsureChildNode,
        Value = String.Format(CultureInfo.InvariantCulture,
                  <span class="str">&quot;&lt;add name='{0}' type='{1}' /&gt;&quot;</span>,
                  typeName, asmName)
      };
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> UpdateApp(SPWebApplication webApp)
  {
    <span class="rem">// Update the Web App and apply the changes </span>
    <span class="rem">// to all servers in the farm</span>
    webApp.Update();
    webApp.Farm.Services
        .GetValue&lt;SPWebService&gt;()
        .ApplyWebConfigModifications();
  }
}</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Integration Test Brought to you by Powershell &amp; NUnit &#8211; with a Little Specification Syntax for Flavoring</title>
		<link>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tell-me-what-you-dont-like-about-tfs-2010</link>
		<comments>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/#comments</comments>
		<pubDate>Sat, 15 May 2010 15:48:18 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Team System]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/</guid>
		<description><![CDATA[I know that a lot of people have had bad experiences with TFS over the years, and so does the TFS development team. The team at Microsoft is very intent on learning what it is that people find irritating, problematic, or difficult, and correcting it. Some major headway was made with the 2010 release of [...]]]></description>
			<content:encoded><![CDATA[<p>I know that a lot of people have had bad experiences with TFS over the years, and so does the TFS development team. The team at Microsoft is very intent on learning what it is that people find irritating, problematic, or difficult, and correcting it. Some major headway was made with the 2010 release of Team Foundation Server to make it easier to setup and administer, and also to improve the usability of several of its key features.</p>  <p>That said, there is still room for improvement and both the team and I understand there are still opportunities to improve. In all seriousness, the team at Microsoft wants to make TFS an approachable, no-brainer install decision for .NET teams, even small ones. This means they want to be able to compete for your attention with the likes of SVN, Git, Jira, Perforce, and anyone else making collaboration tools for developers.</p>  <p>The point of this post is for you to help me know what feedback I can give the TFS product development team as they look ahead to the next release of TFS. I am looking for legitimate feedback I can give the team on how to improve the TFS product.</p>  <p>Please bear in mind that I am interested in your feedback on TFS 2010, as TFS 2008 was improved upon 10 fold in the latest release. Also, I am not necessarily looking for feedback on Visual Studio, just the TFS side of the house. Please realize that the team who makes this product at Microsoft is just as committed and passionate about making great software as you are. They just really need your feedback to make the thing you want. In fact, they want to make a tool that every developer loves to use. Really. So what needs to change to make that the case?</p>  <p>Recall that TFS functionality is broken into the following major areas and I am looking for feedback on the 2010 version.</p>  <ul>   <li>Version Control </li>    <li>Work Item management </li>    <li>Team Foundation Build </li>    <li>SharePoint integration (optional) </li>    <li>Reporting and SSRS Integration (optional) </li> </ul>  <p>Thanks for anything you have. Thank you also for being respectful and not making this a bash-fest.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>Elegant Code &#187; Microsoft</title>
	<atom:link href="http://elegantcode.com/category/microsoft/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Buy Quinine Without Prescription</title>
		<link>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=awarded-microsoft-community-contributor-award-2012</link>
		<comments>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 23:03:17 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[awards]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/</guid>
		<description><![CDATA[Buy Quinine Without Prescription, Today I received an email informing me that I have been awarded the Microsoft Community Contributor Award.&#160; This is the second time I have been awarded this particular award and it feels just as good this time as it did last time.&#160; I’m not sure how you go about getting nominated [...]]]></description>
			<content:encoded><![CDATA[<p> <p> <b>Buy Quinine Without Prescription</b>, Today I received an email informing me that I have been awarded the Microsoft Community Contributor Award.&#160; This is the second time I have been awarded this particular award and it feels just as good this time as it did last time.&#160; I’m not sure how you go about getting nominated for this award, but apparently I am doing something right.</p>  <p>I would like to thank whoever nominated me for this award and Microsoft for listening to that person.&#160; I would most of all like to thank the community.&#160; Without the support of the community I would probably still be a cop. Oh, <b>australia, uk, us, usa</b>, <b>Discount Quinine</b>, you probably didn’t know that about me.</p>  <p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="Brian Lagunas awarded Microsoft Community Contributor Award" border="0" alt="Brian Lagunas awarded Microsoft Community Contributor Award" src="http://elegantcode.com/wp-content/uploads/2012/03/MCC12_Logo_Horizontal_Full-color.jpg" width="500" height="202" /></p>.  Quinine pharmacy.  Herbal Quinine.  Order Quinine no prescription.  What is Quinine.  Buy Quinine online cod.  Quinine street price.  Quinine use.  Effects of Quinine.  Buy Quinine online no prescription.  Is Quinine safe.  Where can i cheapest Quinine online.  Order Quinine online overnight delivery no prescription.  Where to buy Quinine.  Quinine duration.  Quinine from canada.  Fast shipping Quinine.  After Quinine.  Quinine no prescription.  Quinine cost.  Quinine alternatives.  Quinine samples.  Buy Quinine from canada.  Buy Quinine no prescription.  Ordering Quinine online.  Quinine mg.  Quinine dangers.  Where can i buy Quinine online.  Purchase Quinine online.  Quinine maximum dosage.  Buy Quinine online cod.  Rx free Quinine.  Order Quinine from United States pharmacy.  Buy generic Quinine.  No prescription Quinine online.  Quinine australia, uk, us, usa.  Quinine overnight.  Buy Quinine without a prescription.  Quinine online cod.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4728'>Ventolin For Sale</a>. <a href='http://elegantcode.com/?p=4184'>Synthroid For Sale</a>. <a href='http://elegantcode.com/?p=4384'>Buy Ultram Without Prescription</a>. <a href='http://elegantcode.com/?p=4373'>Topamax For Sale</a>. <a href='http://elegantcode.com/?p=5156'>Amoxicillin For Sale</a>. <a href='http://elegantcode.com/?p=4384'>Order Ultram online overnight delivery no prescription</a>. <a href='http://elegantcode.com/?p=4683'>Inderal schedule</a>. <a href='http://elegantcode.com/?p=4822'>About Hydrochlorothiazide</a>. <a href='http://elegantcode.com/?p=4728'>Ventolin australia, uk, us, usa</a>. <a href='http://elegantcode.com/?p=4694'>Human Growth Hormone interactions</a>.<br />
<b>Trackbacks from:</b> <a href='http://social-blend.com/?p=1163'>Buy Quinine Without Prescription</a>. <a href='http://www.quarterlives.com/?p=710'>Buy Quinine Without Prescription</a>. <a href='http://4realz.net/?p=1873'>Buy Quinine Without Prescription</a>. <a href='http://www.macneilbmx.com/blog/?p=6577'>Buy Quinine Without Prescription</a>. <a href='http://www.greatgreengoods.com/?p=2921'>Buy Quinine Without Prescription</a>. <a href='http://blog.farmland.org/?p=1913'>Online buy Quinine without a prescription</a>. <a href='http://reversemortgagedaily.com/?p=14688'>Is Quinine addictive</a>. <a href='http://linuxologist.com/?p=1495'>Quinine over the counter</a>. <a href='http://home.officesnapshots.com/?p=235'>Order Quinine from United States pharmacy</a>. <a href='http://evanrapoport.com/?p=720'>Generic Quinine</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Silverlight Profiling PowerShell helper.</title>
		<link>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=silverlight-profiling-powershell-helper</link>
		<comments>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/#comments</comments>
		<pubDate>Sat, 15 May 2010 16:47:22 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/</guid>
		<description><![CDATA[I was playing around with some Silverlight profiling the other night to see if I could find any obvious issues with my open source project StatLight and wound up writing a little script in PowerShell I hoped someone might find helpful. But I didn’t know you could profile a Silverlight app. I didn’t until I [...]]]></description>
			<content:encoded><![CDATA[<p>I was playing around with some Silverlight profiling the other night to see if I could find any obvious issues with my open source project <a href="http://statlight.net" target="_blank">StatLight</a> and wound up writing a little script in PowerShell I hoped someone might find helpful.</p>  <h4>But I didn’t know you could profile a Silverlight app.</h4>  <p>I didn’t until I started doing some digging online. Now, the Silverlight profiling story (at least from what I’ve seen/tried) is not near the easy of say <a href="http://www.red-gate.com/products/ants_performance_profiler/index.htm">Redgate ANTS Performance Profiler</a>. However, it’s do-able. (And with this helper script – hopefully a little simpler?)</p>  <h4>How can I profile a Silverlight Application?</h4>  <p>I would recommend you read the following blog, which explains one way of doing it very well.</p>  <p><a title="http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx" href="http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx">http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx</a></p>  <h4>So… what’s this script for?</h4>  <p>If you read the blog above, or have done this before, then you probably noticed that there was quite a series of commands you had to execute before you could wind up with a performance report. </p>  <p>I threw together a quick little PowerShell script in an attempt to automate smooth out the process.</p>  <h4>Hot do I use it?</h4>  <ol>   <li>Download the script &amp; save it somewhere. <a href="http://github.com/staxmanade/Scripts/blob/master/SilverlightProfiler.ps1"><strong>http://github.com/staxmanade/Scripts/blob/master/SilverlightProfiler.ps1</strong></a> </li>    <li>Open the PowerShell console. cd to the directory your xap/assemblies are stored.      <br />(EX: {myProject}\Bin\Debug\ ) </li>    <li>Execute:      <br />{pathToScript}\SilverlightProfiler.ps1 -urlPath &quot;{myProject}\Bin\Debug\TestPage.html&quot; </li>    <li>When your done profiling press enter to signal that your done.      <p></p> Once complete, it will print the location your profiling report was saved. You can then open it with Visual Studio.</li> </ol>  <h5>Couple of disclaimers.</h5>  <ul>   <li>Some paths are hard-coded to my x86 machine. </li>    <li>I had troubles running the built in visual studio .bat files (from powershell) that are supposed to set the environment variables. So I extracted out what vars I could find to make it work. </li>    <li>I’m not a profiling expert – just hacked this together to get it to work for me.</li> </ul>  <p>I hope this is useful, and if you know of a better way, I’m always interested in hearing your feedback.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tell me what you don&#8217;t like about TFS 2010</title>
		<link>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tell-me-what-you-dont-like-about-tfs-2010</link>
		<comments>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/#comments</comments>
		<pubDate>Sat, 15 May 2010 15:48:18 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Team System]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/</guid>
		<description><![CDATA[I know that a lot of people have had bad experiences with TFS over the years, and so does the TFS development team. The team at Microsoft is very intent on learning what it is that people find irritating, problematic, or difficult, and correcting it. Some major headway was made with the 2010 release of [...]]]></description>
			<content:encoded><![CDATA[<p>I know that a lot of people have had bad experiences with TFS over the years, and so does the TFS development team. The team at Microsoft is very intent on learning what it is that people find irritating, problematic, or difficult, and correcting it. Some major headway was made with the 2010 release of Team Foundation Server to make it easier to setup and administer, and also to improve the usability of several of its key features.</p>  <p>That said, there is still room for improvement and both the team and I understand there are still opportunities to improve. In all seriousness, the team at Microsoft wants to make TFS an approachable, no-brainer install decision for .NET teams, even small ones. This means they want to be able to compete for your attention with the likes of SVN, Git, Jira, Perforce, and anyone else making collaboration tools for developers.</p>  <p>The point of this post is for you to help me know what feedback I can give the TFS product development team as they look ahead to the next release of TFS. I am looking for legitimate feedback I can give the team on how to improve the TFS product.</p>  <p>Please bear in mind that I am interested in your feedback on TFS 2010, as TFS 2008 was improved upon 10 fold in the latest release. Also, I am not necessarily looking for feedback on Visual Studio, just the TFS side of the house. Please realize that the team who makes this product at Microsoft is just as committed and passionate about making great software as you are. They just really need your feedback to make the thing you want. In fact, they want to make a tool that every developer loves to use. Really. So what needs to change to make that the case?</p>  <p>Recall that TFS functionality is broken into the following major areas and I am looking for feedback on the 2010 version.</p>  <ul>   <li>Version Control </li>    <li>Work Item management </li>    <li>Team Foundation Build </li>    <li>SharePoint integration (optional) </li>    <li>Reporting and SSRS Integration (optional) </li> </ul>  <p>Thanks for anything you have. Thank you also for being respectful and not making this a bash-fest.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>Visual Studio: Open in Full XAML View by Default</title>
		<link>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=visual-studio-open-in-full-xaml-view-by-default</link>
		<comments>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 15:49:14 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/</guid>
		<description><![CDATA[So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane [...]]]></description>
			<content:encoded><![CDATA[<p>So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane blows.&#160; So now I have to sit and wait for VS to render my view in the preview pane, and sometimes it can take a while, if it doesn’t just completely crash.&#160; Sometimes I take the extra time to go grab a snack and beverage of my choice.&#160; </p>  <p>So here is a hidden performance increasing jewel you might find useful.&#160; We can set the default open mode to be in full XAML view.</p>  <p>First thing you need to do is in Visual Studio go to your Tools ==&gt; Options ==&gt; Text Editor ==&gt; XAML ==&gt; Miscellaneous.&#160; There you will see an option for “Always open documents in full XAML view”.&#160; Check that box.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/04/image.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="xaml options for opening in full xaml view" border="0" alt="xaml options for opening in full xaml view" src="http://elegantcode.com/wp-content/uploads/2010/04/image_thumb.png" width="244" height="146" /></a> </p>  <p>Now every time you open a XAML file it will open in full XAML view and give you one less thing to gripe about.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Looking Ahead to 2010</title>
		<link>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=looking-ahead-to-2010</link>
		<comments>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 21:02:11 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/02/09/looking-ahead-to-2010/</guid>
		<description><![CDATA[No, this isn't another prognostication post foretelling the woes of the world for the next year. This is a note to everyone who hasn't yet played with the Visual Studio ALM tools and Team Foundation Server 2010. Folks, this product is getting better. That stands to reason. After all, this is basically version 3 of [...]]]></description>
			<content:encoded><![CDATA[<p><img align="left" src="http://elegantcode.com/wp-content/uploads/2010/02/020910_2101_LookingAhea13.png" alt=""/>No, this isn't another prognostication post foretelling the woes of the world for the next year. This is a note to everyone who hasn't yet played with the Visual Studio ALM tools and Team Foundation Server 2010.
</p><p>Folks, this product is getting better. That stands to reason. After all, this is basically version 3 of the product and you know what they say! Version 3 is the one to buy. Most of the kinks are worked out now.
</p><p>Now, I won't pretend for a moment that Team Foundation Server hasn't had its challenges fitting in with agile teams. I think that has come from a history of development by a team that itself was learning and growing just like the rest of us. Now that many of the teams within Microsoft are practicing some form of iterative development with completed cycles of "all the way done", we are starting to see the influence in the tools they are producing. And the effect is not half bad.
</p><p>I have been using Visual Studio 2010 for a few months now, and with the recent release of the RC, I can see:
</p><ol><li>Performance is getting better (XAML).
</li><li>Features are getting more solid (fewer exceptions)
</li><li>The polish of the overall user experience is becoming a great example of an application I am happy to look at all day long.
</li><li>The Team Foundation Server features being added are consistent with what we are learning to be effective as an agile community.
</li></ol><p>So, where's the meat? What are these shiny features of which you speak, Mr. Starr? Well, here is a short sample because I am sitting in an airport listening to the chaos and I can't think of it all. 
</p><p>I should also say that this is a very small list of features that I personally am really excited about. The rest of the world probably has other things they care about. These are mine because I believe they have to potential to really change life on a team for the better.
</p><h2>Layer Diagrams
</h2><p>There is a major focus in this release to add UML support to Visual Studio Ultimate. OK, not a huge fan and I know some people will dog on this feature, but I am all about the Layer Diagrams. These are diagrams that we can create just like the UML diagrams that Visual Studio now supports, but the value of a Layer Diagram is that it has teeth and can bite back. 
</p><p>Here's how it works:
</p><ol><li>Create a Layer Diagram.
</li><li>Draw your favorite design pattern or desired architectural separation model using tools in the Toolbox. In a simple example, this might be to create a model of the MVP pattern. In a large example this model might show the multiple layers in my solution that uses CSLA, Silverlight with MVVM, WCF, and Entity Framework. (Hi, Scott <span style="font-family:Wingdings">J</span> You knew that was for you.)
</li><li>Add some things to it from your solution. Drop things onto the diagram and into the boxes like classes, namespaces, and Visual Studio projects.
</li><li>Now you can generate dependencies between these things and see the existing relationships. Yawn. Cool, but we get this with dependency diagrams, too.
</li><li><div>Validate the model.<br/><br/>Wait for it. . .  Grok it. . .
</div><p><br/>You got it! Yeah, that's right. Validate the LOGICAL model of your application. This is so sweet it comes on a stick. This means that not only can I verify I haven't violated my design with a bad reference or super egregious abstraction hole, but I can make this validation part of the build process and catch it if I accidently violate my own design later. Where I come from, they call that cool.
</p></li></ol><h2>Way Better Work Items
</h2><p>This is non-trivial for teams who live every day of their lives in Team Foundation Server to manage their requirements and work queues. Sure, we might all prefer note cards on the wall, but for many this is simply not possible. And for those folks who use Team Foundation Server to manage their notecards, there are some great new things to make that task easier.
</p><ol><li>Hierarchical relationships between Work Items.
</li><li>Agile planning Workbooks.
</li><li>Seamless Team Project Dashboards.
</li><li>MSF Agile 5.
</li></ol><h2>Gated Check In
</h2><p>This is a feature of Team Foundation Build that will actually build and test your software before a check-in is committed to Source Control. The mechanical effect of this is simple: Code that would break the build is never committed to Source Control. The implications are far larger, though. Think it through for a moment. What would change in your daily life if you flat out were unable to commit code that breaks the build? The short answer is, "Quality goes up." I bit more verbose answer is that I need to be more careful before committing my code.
</p><p>Yes, I know other vendors have had this feature for a while. So what? So, Team Foundation Server shouldn't have it too? It rocks and now we get it in Team Foundation Build.
</p><h2>IntelliTrace
</h2><p>I am not even sure how cool this is yet, only that it is. This feature is also known as Historical Debugging and gives the ability to step back and forth through call stacks and watched variables during a debug run. To be clear, that's <em>Back and Forth through time</em>. So, the first time I hit the breakpoint, here was the status of the code. The second time it was this. And so on. Also, I can inspect all this data on system events (like CLR events) and can therefore tap into my app at a lot of different levels.
</p><p>Now, I know that you don't need debuggers anymore because every line of code we write is Test Driven and that means we don't need debuggers, right? Yeah, sure you never need a debugger. As I said, this is just a wicked tool, but I am not yet sure how wicked. The community will definitely ferret that out over time.
</p><h2>Other Stuff
</h2><p>This only scratches the surface of what's in Visual Studio and Team Foundation Server 2010. There are a lot more things, many of them bigger and higher profile than the things I mentioned. I just happen to be in love with these particular features at the moment. As I get deeper into things, I will let you know what I see.
</p><p>One last thing, I know these tools get a lot of flak in some communities, but I feel comfortable with them. I also understand that many developers out there in the world don't get to choose their tools. Often tools are assigned. What I see is that the 2010 versions of Visual Studio and Team Foundation Server really have raised the bar. I don't feel like teams are still having to compromise on tooling to get everything they need in an integrated environment.
</p><p>Will I still run R#? Well, yeah.
</p><p>
 </p><p>
 </p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Powershell: Load assembly without locking file.</title>
		<link>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-load-assembly-without-locking-file</link>
		<comments>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 05:40:23 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/</guid>
		<description><![CDATA[I have a set of PowerShell build scripts and ran into a case where I needed to load an assembly (to get the assembly’s version) and still (at a later time) work with the assembly file on disk. A typical way to load an assembly within PowerShell is to use the Assembly.LoadFrom(filePath) # Powershell [System.Reflection.Assembly]::LoadFrom($assemblyPath) [...]]]></description>
			<content:encoded><![CDATA[<p>I have a set of PowerShell build scripts and ran into a case where I needed to load an assembly (to get the assembly’s version) and still (at a later time) work with the assembly file on disk.</p>  <p>A typical way to load an assembly within PowerShell is to use the Assembly.LoadFrom(filePath)</p>  <blockquote>   <p># Powershell</p>    <p>[System.Reflection.Assembly]::LoadFrom($assemblyPath)</p> </blockquote>  <p><a href="http://elegantcode.com/wp-content/uploads/2009/12/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2009/12/image_thumb9.png" width="690" height="391" /></a> </p>  <p>Except the problem with this (in my case) was it would <strong>lock the file for the lifespan of the PowerShell console instance</strong>. I didn’t want to have to close and re-open the PowerShell console every time I need to run a build so there had to be a work-around for this.</p>  <p>After searching the web for a solution, I couldn’t find anything that was “easy” and worth the effort to get it to work.</p>  <blockquote>   <p>EX: One solution was to create a new AppDomain, do the necessary work and the close the AppDomain which would release the lock on the file.</p>    <p>I’ve never done this myself, and even thought there is example code out there to get this accomplished, it just seemed over the top for what I was trying to do, and back to my previous criteria it wasn’t “worth the effort to get it to work”</p> </blockquote>  <p>Then I remembered in a previous life I used an overload that took an array of bytes to load the an assembly.</p>  <blockquote>   <p>[System.Reflection.Assembly]::Load($assemblyBytes)</p> </blockquote>  <p>After spiking it in PowerShell with the below test. I was quite happy with the solution, so I thought I’d throw it out there.</p>  <p>Just stream the assembly from disk into a byte array manually, and call assembly load from there.</p>  <p>Here’s my test case which shows that the file is not locked after it was loaded into the PowerShell runtime</p>  <pre>$file = &quot;.\Moq.dll&quot;
$tempFileName = &quot;.\Moq-Renamed.dll&quot;

$fileStream = ([System.IO.FileInfo] (Get-Item $file)).OpenRead();
$assemblyBytes = new-object byte[] $fileStream.Length
$fileStream.Read($assemblyBytes, 0, $fileStream.Length);
$fileStream.Close();

$assemblyLoaded = [System.Reflection.Assembly]::Load($assemblyBytes);

# notice that we can move the file on disk after 
# it's loaded into the powershell runtime
Move-Item $file $tempFileName
Move-Item $tempFileName $file 

# and display the assembly information to show we still have it in memory
echo $assemblyLoaded</pre>

<p>After that test passed, and the main reason I wanted to do this, I wrote the “get-assembly-version” PowerShell function.</p>

<pre><strike>function get-assembly-version() {
    param([string] $file)
    
    # load the assembly bytes quickly - as to not lock the file for too long
    $fileStream = ([System.IO.FileInfo] (Get-Item $file)).OpenRead()
    $assemblyBytes = new-object byte[] $fileStream.Length
    $fileStream.Read($assemblyBytes, 0, $fileStream.Length) | Out-Null #out null this because this function should only return the version &amp; this call was outputting some garbage number
    $fileStream.Close()
    
    # return the version of the assembly
    [System.Reflection.Assembly]::Load($assemblyBytes).GetName().Version;
}

$version = get-assembly-version(&quot;.\Moq.dll&quot;)

echo &quot;Loaded v$($version.Major).$($version.Minor).$($version.Build).$($version.Revision) version of $file&quot;</strike></pre>
Hope this helps someone out there! 

<p></p>

<p>&#160;</p>

<p><strong>UPDATE:</strong></p>

<p><a href="http://achuebrigens.wordpress.com">Martin</a> commented below on a much better solution to the assembly version info problem. Amazing how complicated we can make things if we don’t know the path.</p>

<pre>
function get-assembly-version() {
    param([string] $file)
    
    $version = [System.Reflection.AssemblyName]::GetAssemblyName($file).Version;
    
    #format the version and output it...
    $version
}</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Removing WSUS</title>
		<link>http://elegantcode.com/2009/12/01/removing-wsus/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=removing-wsus</link>
		<comments>http://elegantcode.com/2009/12/01/removing-wsus/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 21:53:49 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[WSUS]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/01/removing-wsus/</guid>
		<description><![CDATA[A while back, the company I work for experimented with setting up a Windows Server Update Service (WSUS).&#160; The idea is that you have one server that goes out and downloads all of the hotfixes, service packs, and so on for your network – then each of your client machines goes directly to the local [...]]]></description>
			<content:encoded><![CDATA[<p>A while back, the company I work for experimented with setting up a Windows Server Update Service (WSUS).&#160; The idea is that you have one server that goes out and downloads all of the hotfixes, service packs, and so on for your network – then each of your client machines goes directly to the local WSUS server to get the weekly dose of patches, configurable by various group policies, and with monitoring to make sure that everything is going smoothly.&#160; At the time we set it up, we were having crushing bandwidth problems – two servers downloading a service pack would pretty much disable the building…</p>  <p>Over time, the bandwidth problems were fixed, and as sometimes happens the WSUS server crumbled to dust.&#160; For the most part nobody noticed – new servers and clients were not configured with the WSUS policy, downloading their hotfixes direct from Microsoft through plentiful bandwidth.&#160; Unfortunately, older server and clients were left in the dark, sending cries out to a WSUS URL that will never respond...&#160; oops</p>  <h4>To Fix (and get your automatic updates to work again):</h4>  <p>Delete the registry key at “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate”.&#160; For fun, restart the “Windows Update” service (not sure if this is necessary).&#160; </p>  <p>I found <a href="http://www.d.umn.edu/itss/security/sus/" target="_blank">this VBS file</a> to be useful in figuring out if a server was still trying to use an old WSUS install, or if the problem was group-policy related.&#160; </p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/01/removing-wsus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PDC Notes</title>
		<link>http://elegantcode.com/2009/11/17/pdc-notes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pdc-notes</link>
		<comments>http://elegantcode.com/2009/11/17/pdc-notes/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 17:23:30 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/17/pdc-notes/</guid>
		<description><![CDATA[I am grateful to INETA to be attending PDC this year. Also, I grateful to Visual Stuart, who is letting me crash in his room. Turns out, I am a cheap skate :) I am sitting in the keynote on Tuesday and thinking about the week. In addition to the Wait? What the… Wordpress moving [...]]]></description>
			<content:encoded><![CDATA[<p>I am grateful to INETA to be attending <a href="http://microsoftpdc.com">PDC</a> this year. Also, I grateful to <a href="http://visualstuart.com">Visual Stuart</a>, who is letting me crash in his room. Turns out, I am a cheap skate :)</p>  <p>I am sitting in the keynote on Tuesday and thinking about the week. In addition to the </p>  <blockquote>   <p><font style="background-color: #ffffff">Wait? What the… Wordpress moving into the Azure cloud? Sweet!</font></p> </blockquote>  <p>volunteer sessions I am doing for INETA, I am hosting a Birds of a Feather session with Mike Vincent. Our BOF is this afternoon and is entitled, “Agile Tales of Triumph, Tribulation, Tools, and Teams”. Drop by and join the discussion to learn </p>  <blockquote>   <p><font style="background-color: #ffffff">Code name Dallas: A uniform way to access data in the cloud and mash it all up.</font></p> </blockquote>  <p>and share what really works.</p>  <p>It has been very cool to meet many of the Pluralsight instructors for the first time. We all live in different parts of the world, and PDC provides that opportunity for us to </p>  <blockquote>   <p>Everyone get your 3D glasses on! Oh, that was very anti-climactic.</p> </blockquote>  <p>all actually shake physical hands rather than electronic ones.</p>  <p>Also, drop by the Pluralsight booth and share your developer stories with me. Here’s the sneak peek as to why: <font style="background-color: #ffffff"><a href="http://www.pluralsight.com/main/pluralcast/default.aspx">Pluralcast</a>. More on that in another post. Suffice </font></p>  <blockquote>   <p><font style="background-color: #ffffff">I think that guy onstage is showing an iPhone and talking about how easy it was to write an app for it. Weird.</font></p> </blockquote>  <p><font style="background-color: #ffffff">to say </font>there will be some changes in the Elegant Code Cast.</p>  <blockquote>   <p>Did he just say, “Create applications for the good of the republic?” Seriously?</p> </blockquote>  <p>Lastly, if you see me running around the halls, please stop me and say, Hello.” It’s very cool to be able to meet people I usually only get to chat with online. If you are looking for a <a href="http://guild3.com">great developer team</a> to build your next big thing, we can talk about that, too!</p>  <blockquote>   <p>Please stop saying “3 screens in the cloud.”</p> </blockquote>  <p>Ray Ozzie final points from the keynote:</p>  <ol>   <li>Bet your next user experience on Windows 7</li>    <li>When thinking of the cloud, bet on Azure.</li>    <li>Take a moment to think about how the world is changing and the potential role of cloud in that world.</li> </ol>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/17/pdc-notes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>StructureMap and SharePoint</title>
		<link>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=structuremap-and-sharepoint</link>
		<comments>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 18:00:22 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[StructureMap]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/</guid>
		<description><![CDATA[I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; </p>  <p>I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user is authorized to use.&#160; The source of this data (names, URLs, etc.) comes from an external-to-SharePoint system, accessed through another C# assembly.&#160; Once the web part gets the data there is some more processing to be done – we need to do more than just blindly display a list of URLs.&#160; Rather than get into details I’m just going to do some handwaving here and say that “if you have access to X, then {stuff happens}, or if you have access to Y then {other stuff happens}.”&#160; You know, business logic, stuff that is good to test.</p>  <p>the first thing I need to do is get business logic out of the WebPart and into something that I can write without having to reset AppPools over and over, not to mention have some unit tests to verify I’m going in the right direction.&#160; So, I created a standard application service class which has a dependency on the external authorization system, via constructor injection.&#160; </p>  <pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> AuthorizedAppsService : IAuthorizedAppsService
{
  <span class="kwrd">private</span> <span class="kwrd">readonly</span> ExternalAuthorizeService authService;

  <span class="kwrd">public</span> AuthorizedAppsService(
    ExternalAuthorizeService authService) 
  {
    <span class="kwrd">this</span>.authService = authService;
  }

  <span class="kwrd">public</span> AuthorizedApplications GetAuthorizedApplications(
                                  <span class="kwrd">string</span> userName)
  {
    var allApps = authService.AuthorizedApplications(userName);
    <span class="rem">// business logic stuff happens here</span>
    <span class="kwrd">return</span> thoseResultsWeJustFiguredOut;
  }
}</pre>

<p>Next, I created a StructureMap Registry class to scan my assemblies, as well as adding in the details of how to create this external authorize service, using the typical method: <style type="text/css">




.csharpcode, .csharpcode pre
{
	font-size: x-small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style></p>

<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyRegistry : Registry
{
  <span class="kwrd">public</span> MyRegistry()
  {
    Scan(scanner =&gt; {
      scanner.TheCallingAssembly();
      scanner.AssemblyContainingType(<span class="kwrd">typeof</span>(MyRegistry));
      scanner.WithDefaultConventions();
      });

    ForRequestedType&lt;ExternalAuthorizeService&gt;()
      .AsSingletons()
      .TheDefault.Is.ConstructedBy(c =&gt; Provider.GetService());

    <span class="rem">// other dependency configuration...</span>
  }
  <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> InitializeForSharepoint()
  {
    ObjectFactory.Initialize(init =&gt; init.AddRegistry&lt;MyRegistry&gt;());
    ObjectFactory.AssertConfigurationIsValid();
  }
}</pre>

<p>And then, what remains is to have SharePoint call my StructureMap initialization when my SharePoint application starts up.&#160; In an MVC or WebForms app, I’d just add code to the appropriate place in Global.asax.cs, but in SharePointLand, this is looked down on.&#160; Instead, the preferred mechanism seems to be to use an HttpModule and a FeatureReceiver to plug the Module into the app’s web.config.</p>

<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyStartupModule : IHttpModule
{
  <span class="kwrd">public</span> <span class="kwrd">void</span> Init(HttpApplication context)
  {
        ConfigureOtherStuff();
        MyRegistry.InitializeForSharepoint();
  }
  <span class="kwrd">public</span> <span class="kwrd">void</span> Dispose() { }
}</pre>

<p>And then the FeatureReceiver to alter the app’s Web.Config looks something like this (note I borrowed most of this code from another sample SharePoint project:</p>

<p>&#160;</p>

<pre class="csharpcode"><span class="rem">//</span>
<span class="rem">// this is borrowing heavily from http://www.codeplex.com/SPAXO</span>
<span class="rem">// </span>
<span class="kwrd">public</span> <span class="kwrd">class</span> StartupFeatureReceiver : SPFeatureReceiver
{
  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureActivated(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    AddWebConfigEntry(webApp);
    UpdateApp(webApp);
  }

  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureDeactivating(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    RemoveWebConfigEntry(webApp);
    UpdateApp(webApp);
  }


  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> AddWebConfigEntry(SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    var existingModifications = 
             <span class="kwrd">new</span> List&lt;SPWebConfigModification&gt;(
                      webApp.WebConfigModifications);
    <span class="kwrd">if</span> (existingModifications.FindIndex(
                    <span class="kwrd">value</span> =&gt;
                        <span class="kwrd">value</span>.Name == mod.Name &amp;&amp;
                        <span class="kwrd">value</span>.Value == mod.Value &amp;&amp;
                        <span class="kwrd">value</span>.Owner == mod.Owner) == -1)
    {
      <span class="rem">// If the modifcation does not already exist </span>
      <span class="rem">// add the entry to the config</span>
      webApp.WebConfigModifications.Add(mod);
    }
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> RemoveWebConfigEntry(
            SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    webApp.WebConfigModifications.Remove(mod);
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> SPWebConfigModification GetModification()
  {
    <span class="kwrd">string</span> asmName = <span class="kwrd">typeof</span>(StartupModule).AssemblyQualifiedName;
    <span class="kwrd">string</span> typeName = <span class="kwrd">typeof</span>(StartupModule).FullName;

    <span class="kwrd">return</span> <span class="kwrd">new</span> SPWebConfigModification
      {
        Path = <span class="str">&quot;configuration/system.web/httpModules&quot;</span>,
        Name = String.Format(CultureInfo.InvariantCulture,
                <span class="str">&quot;add[@name='{0}'][@type='{1}']&quot;</span>,
                typeName, asmName),
        Sequence = 0,
        Owner = asmName,
        Type = SPWebConfigModification.
                    SPWebConfigModificationType.EnsureChildNode,
        Value = String.Format(CultureInfo.InvariantCulture,
                  <span class="str">&quot;&lt;add name='{0}' type='{1}' /&gt;&quot;</span>,
                  typeName, asmName)
      };
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> UpdateApp(SPWebApplication webApp)
  {
    <span class="rem">// Update the Web App and apply the changes </span>
    <span class="rem">// to all servers in the farm</span>
    webApp.Update();
    webApp.Farm.Services
        .GetValue&lt;SPWebService&gt;()
        .ApplyWebConfigModifications();
  }
}</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Integration Test Brought to you by Powershell &amp; NUnit &#8211; with a Little Specification Syntax for Flavoring</title>
		<link>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=visual-studio-open-in-full-xaml-view-by-default</link>
		<comments>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 15:49:14 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/</guid>
		<description><![CDATA[So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane [...]]]></description>
			<content:encoded><![CDATA[<p>So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane blows.&#160; So now I have to sit and wait for VS to render my view in the preview pane, and sometimes it can take a while, if it doesn’t just completely crash.&#160; Sometimes I take the extra time to go grab a snack and beverage of my choice.&#160; </p>  <p>So here is a hidden performance increasing jewel you might find useful.&#160; We can set the default open mode to be in full XAML view.</p>  <p>First thing you need to do is in Visual Studio go to your Tools ==&gt; Options ==&gt; Text Editor ==&gt; XAML ==&gt; Miscellaneous.&#160; There you will see an option for “Always open documents in full XAML view”.&#160; Check that box.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/04/image.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="xaml options for opening in full xaml view" border="0" alt="xaml options for opening in full xaml view" src="http://elegantcode.com/wp-content/uploads/2010/04/image_thumb.png" width="244" height="146" /></a> </p>  <p>Now every time you open a XAML file it will open in full XAML view and give you one less thing to gripe about.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Elegant Code &#187; Microsoft</title>
	<atom:link href="http://elegantcode.com/category/microsoft/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Buy Quinine Without Prescription</title>
		<link>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=awarded-microsoft-community-contributor-award-2012</link>
		<comments>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 23:03:17 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[awards]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/</guid>
		<description><![CDATA[Buy Quinine Without Prescription, Today I received an email informing me that I have been awarded the Microsoft Community Contributor Award.&#160; This is the second time I have been awarded this particular award and it feels just as good this time as it did last time.&#160; I’m not sure how you go about getting nominated [...]]]></description>
			<content:encoded><![CDATA[<p> <p> <b>Buy Quinine Without Prescription</b>, Today I received an email informing me that I have been awarded the Microsoft Community Contributor Award.&#160; This is the second time I have been awarded this particular award and it feels just as good this time as it did last time.&#160; I’m not sure how you go about getting nominated for this award, but apparently I am doing something right.</p>  <p>I would like to thank whoever nominated me for this award and Microsoft for listening to that person.&#160; I would most of all like to thank the community.&#160; Without the support of the community I would probably still be a cop. Oh, <b>australia, uk, us, usa</b>, <b>Discount Quinine</b>, you probably didn’t know that about me.</p>  <p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="Brian Lagunas awarded Microsoft Community Contributor Award" border="0" alt="Brian Lagunas awarded Microsoft Community Contributor Award" src="http://elegantcode.com/wp-content/uploads/2012/03/MCC12_Logo_Horizontal_Full-color.jpg" width="500" height="202" /></p>.  Quinine pharmacy.  Herbal Quinine.  Order Quinine no prescription.  What is Quinine.  Buy Quinine online cod.  Quinine street price.  Quinine use.  Effects of Quinine.  Buy Quinine online no prescription.  Is Quinine safe.  Where can i cheapest Quinine online.  Order Quinine online overnight delivery no prescription.  Where to buy Quinine.  Quinine duration.  Quinine from canada.  Fast shipping Quinine.  After Quinine.  Quinine no prescription.  Quinine cost.  Quinine alternatives.  Quinine samples.  Buy Quinine from canada.  Buy Quinine no prescription.  Ordering Quinine online.  Quinine mg.  Quinine dangers.  Where can i buy Quinine online.  Purchase Quinine online.  Quinine maximum dosage.  Buy Quinine online cod.  Rx free Quinine.  Order Quinine from United States pharmacy.  Buy generic Quinine.  No prescription Quinine online.  Quinine australia, uk, us, usa.  Quinine overnight.  Buy Quinine without a prescription.  Quinine online cod.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4728'>Ventolin For Sale</a>. <a href='http://elegantcode.com/?p=4184'>Synthroid For Sale</a>. <a href='http://elegantcode.com/?p=4384'>Buy Ultram Without Prescription</a>. <a href='http://elegantcode.com/?p=4373'>Topamax For Sale</a>. <a href='http://elegantcode.com/?p=5156'>Amoxicillin For Sale</a>. <a href='http://elegantcode.com/?p=4384'>Order Ultram online overnight delivery no prescription</a>. <a href='http://elegantcode.com/?p=4683'>Inderal schedule</a>. <a href='http://elegantcode.com/?p=4822'>About Hydrochlorothiazide</a>. <a href='http://elegantcode.com/?p=4728'>Ventolin australia, uk, us, usa</a>. <a href='http://elegantcode.com/?p=4694'>Human Growth Hormone interactions</a>.<br />
<b>Trackbacks from:</b> <a href='http://social-blend.com/?p=1163'>Buy Quinine Without Prescription</a>. <a href='http://www.quarterlives.com/?p=710'>Buy Quinine Without Prescription</a>. <a href='http://4realz.net/?p=1873'>Buy Quinine Without Prescription</a>. <a href='http://www.macneilbmx.com/blog/?p=6577'>Buy Quinine Without Prescription</a>. <a href='http://www.greatgreengoods.com/?p=2921'>Buy Quinine Without Prescription</a>. <a href='http://blog.farmland.org/?p=1913'>Online buy Quinine without a prescription</a>. <a href='http://reversemortgagedaily.com/?p=14688'>Is Quinine addictive</a>. <a href='http://linuxologist.com/?p=1495'>Quinine over the counter</a>. <a href='http://home.officesnapshots.com/?p=235'>Order Quinine from United States pharmacy</a>. <a href='http://evanrapoport.com/?p=720'>Generic Quinine</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Silverlight Profiling PowerShell helper.</title>
		<link>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=silverlight-profiling-powershell-helper</link>
		<comments>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/#comments</comments>
		<pubDate>Sat, 15 May 2010 16:47:22 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/</guid>
		<description><![CDATA[I was playing around with some Silverlight profiling the other night to see if I could find any obvious issues with my open source project StatLight and wound up writing a little script in PowerShell I hoped someone might find helpful. But I didn’t know you could profile a Silverlight app. I didn’t until I [...]]]></description>
			<content:encoded><![CDATA[<p>I was playing around with some Silverlight profiling the other night to see if I could find any obvious issues with my open source project <a href="http://statlight.net" target="_blank">StatLight</a> and wound up writing a little script in PowerShell I hoped someone might find helpful.</p>  <h4>But I didn’t know you could profile a Silverlight app.</h4>  <p>I didn’t until I started doing some digging online. Now, the Silverlight profiling story (at least from what I’ve seen/tried) is not near the easy of say <a href="http://www.red-gate.com/products/ants_performance_profiler/index.htm">Redgate ANTS Performance Profiler</a>. However, it’s do-able. (And with this helper script – hopefully a little simpler?)</p>  <h4>How can I profile a Silverlight Application?</h4>  <p>I would recommend you read the following blog, which explains one way of doing it very well.</p>  <p><a title="http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx" href="http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx">http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx</a></p>  <h4>So… what’s this script for?</h4>  <p>If you read the blog above, or have done this before, then you probably noticed that there was quite a series of commands you had to execute before you could wind up with a performance report. </p>  <p>I threw together a quick little PowerShell script in an attempt to automate smooth out the process.</p>  <h4>Hot do I use it?</h4>  <ol>   <li>Download the script &amp; save it somewhere. <a href="http://github.com/staxmanade/Scripts/blob/master/SilverlightProfiler.ps1"><strong>http://github.com/staxmanade/Scripts/blob/master/SilverlightProfiler.ps1</strong></a> </li>    <li>Open the PowerShell console. cd to the directory your xap/assemblies are stored.      <br />(EX: {myProject}\Bin\Debug\ ) </li>    <li>Execute:      <br />{pathToScript}\SilverlightProfiler.ps1 -urlPath &quot;{myProject}\Bin\Debug\TestPage.html&quot; </li>    <li>When your done profiling press enter to signal that your done.      <p></p> Once complete, it will print the location your profiling report was saved. You can then open it with Visual Studio.</li> </ol>  <h5>Couple of disclaimers.</h5>  <ul>   <li>Some paths are hard-coded to my x86 machine. </li>    <li>I had troubles running the built in visual studio .bat files (from powershell) that are supposed to set the environment variables. So I extracted out what vars I could find to make it work. </li>    <li>I’m not a profiling expert – just hacked this together to get it to work for me.</li> </ul>  <p>I hope this is useful, and if you know of a better way, I’m always interested in hearing your feedback.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tell me what you don&#8217;t like about TFS 2010</title>
		<link>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tell-me-what-you-dont-like-about-tfs-2010</link>
		<comments>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/#comments</comments>
		<pubDate>Sat, 15 May 2010 15:48:18 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Team System]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/</guid>
		<description><![CDATA[I know that a lot of people have had bad experiences with TFS over the years, and so does the TFS development team. The team at Microsoft is very intent on learning what it is that people find irritating, problematic, or difficult, and correcting it. Some major headway was made with the 2010 release of [...]]]></description>
			<content:encoded><![CDATA[<p>I know that a lot of people have had bad experiences with TFS over the years, and so does the TFS development team. The team at Microsoft is very intent on learning what it is that people find irritating, problematic, or difficult, and correcting it. Some major headway was made with the 2010 release of Team Foundation Server to make it easier to setup and administer, and also to improve the usability of several of its key features.</p>  <p>That said, there is still room for improvement and both the team and I understand there are still opportunities to improve. In all seriousness, the team at Microsoft wants to make TFS an approachable, no-brainer install decision for .NET teams, even small ones. This means they want to be able to compete for your attention with the likes of SVN, Git, Jira, Perforce, and anyone else making collaboration tools for developers.</p>  <p>The point of this post is for you to help me know what feedback I can give the TFS product development team as they look ahead to the next release of TFS. I am looking for legitimate feedback I can give the team on how to improve the TFS product.</p>  <p>Please bear in mind that I am interested in your feedback on TFS 2010, as TFS 2008 was improved upon 10 fold in the latest release. Also, I am not necessarily looking for feedback on Visual Studio, just the TFS side of the house. Please realize that the team who makes this product at Microsoft is just as committed and passionate about making great software as you are. They just really need your feedback to make the thing you want. In fact, they want to make a tool that every developer loves to use. Really. So what needs to change to make that the case?</p>  <p>Recall that TFS functionality is broken into the following major areas and I am looking for feedback on the 2010 version.</p>  <ul>   <li>Version Control </li>    <li>Work Item management </li>    <li>Team Foundation Build </li>    <li>SharePoint integration (optional) </li>    <li>Reporting and SSRS Integration (optional) </li> </ul>  <p>Thanks for anything you have. Thank you also for being respectful and not making this a bash-fest.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>Visual Studio: Open in Full XAML View by Default</title>
		<link>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=visual-studio-open-in-full-xaml-view-by-default</link>
		<comments>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 15:49:14 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/</guid>
		<description><![CDATA[So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane [...]]]></description>
			<content:encoded><![CDATA[<p>So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane blows.&#160; So now I have to sit and wait for VS to render my view in the preview pane, and sometimes it can take a while, if it doesn’t just completely crash.&#160; Sometimes I take the extra time to go grab a snack and beverage of my choice.&#160; </p>  <p>So here is a hidden performance increasing jewel you might find useful.&#160; We can set the default open mode to be in full XAML view.</p>  <p>First thing you need to do is in Visual Studio go to your Tools ==&gt; Options ==&gt; Text Editor ==&gt; XAML ==&gt; Miscellaneous.&#160; There you will see an option for “Always open documents in full XAML view”.&#160; Check that box.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/04/image.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="xaml options for opening in full xaml view" border="0" alt="xaml options for opening in full xaml view" src="http://elegantcode.com/wp-content/uploads/2010/04/image_thumb.png" width="244" height="146" /></a> </p>  <p>Now every time you open a XAML file it will open in full XAML view and give you one less thing to gripe about.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Looking Ahead to 2010</title>
		<link>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=looking-ahead-to-2010</link>
		<comments>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 21:02:11 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/02/09/looking-ahead-to-2010/</guid>
		<description><![CDATA[No, this isn't another prognostication post foretelling the woes of the world for the next year. This is a note to everyone who hasn't yet played with the Visual Studio ALM tools and Team Foundation Server 2010. Folks, this product is getting better. That stands to reason. After all, this is basically version 3 of [...]]]></description>
			<content:encoded><![CDATA[<p><img align="left" src="http://elegantcode.com/wp-content/uploads/2010/02/020910_2101_LookingAhea13.png" alt=""/>No, this isn't another prognostication post foretelling the woes of the world for the next year. This is a note to everyone who hasn't yet played with the Visual Studio ALM tools and Team Foundation Server 2010.
</p><p>Folks, this product is getting better. That stands to reason. After all, this is basically version 3 of the product and you know what they say! Version 3 is the one to buy. Most of the kinks are worked out now.
</p><p>Now, I won't pretend for a moment that Team Foundation Server hasn't had its challenges fitting in with agile teams. I think that has come from a history of development by a team that itself was learning and growing just like the rest of us. Now that many of the teams within Microsoft are practicing some form of iterative development with completed cycles of "all the way done", we are starting to see the influence in the tools they are producing. And the effect is not half bad.
</p><p>I have been using Visual Studio 2010 for a few months now, and with the recent release of the RC, I can see:
</p><ol><li>Performance is getting better (XAML).
</li><li>Features are getting more solid (fewer exceptions)
</li><li>The polish of the overall user experience is becoming a great example of an application I am happy to look at all day long.
</li><li>The Team Foundation Server features being added are consistent with what we are learning to be effective as an agile community.
</li></ol><p>So, where's the meat? What are these shiny features of which you speak, Mr. Starr? Well, here is a short sample because I am sitting in an airport listening to the chaos and I can't think of it all. 
</p><p>I should also say that this is a very small list of features that I personally am really excited about. The rest of the world probably has other things they care about. These are mine because I believe they have to potential to really change life on a team for the better.
</p><h2>Layer Diagrams
</h2><p>There is a major focus in this release to add UML support to Visual Studio Ultimate. OK, not a huge fan and I know some people will dog on this feature, but I am all about the Layer Diagrams. These are diagrams that we can create just like the UML diagrams that Visual Studio now supports, but the value of a Layer Diagram is that it has teeth and can bite back. 
</p><p>Here's how it works:
</p><ol><li>Create a Layer Diagram.
</li><li>Draw your favorite design pattern or desired architectural separation model using tools in the Toolbox. In a simple example, this might be to create a model of the MVP pattern. In a large example this model might show the multiple layers in my solution that uses CSLA, Silverlight with MVVM, WCF, and Entity Framework. (Hi, Scott <span style="font-family:Wingdings">J</span> You knew that was for you.)
</li><li>Add some things to it from your solution. Drop things onto the diagram and into the boxes like classes, namespaces, and Visual Studio projects.
</li><li>Now you can generate dependencies between these things and see the existing relationships. Yawn. Cool, but we get this with dependency diagrams, too.
</li><li><div>Validate the model.<br/><br/>Wait for it. . .  Grok it. . .
</div><p><br/>You got it! Yeah, that's right. Validate the LOGICAL model of your application. This is so sweet it comes on a stick. This means that not only can I verify I haven't violated my design with a bad reference or super egregious abstraction hole, but I can make this validation part of the build process and catch it if I accidently violate my own design later. Where I come from, they call that cool.
</p></li></ol><h2>Way Better Work Items
</h2><p>This is non-trivial for teams who live every day of their lives in Team Foundation Server to manage their requirements and work queues. Sure, we might all prefer note cards on the wall, but for many this is simply not possible. And for those folks who use Team Foundation Server to manage their notecards, there are some great new things to make that task easier.
</p><ol><li>Hierarchical relationships between Work Items.
</li><li>Agile planning Workbooks.
</li><li>Seamless Team Project Dashboards.
</li><li>MSF Agile 5.
</li></ol><h2>Gated Check In
</h2><p>This is a feature of Team Foundation Build that will actually build and test your software before a check-in is committed to Source Control. The mechanical effect of this is simple: Code that would break the build is never committed to Source Control. The implications are far larger, though. Think it through for a moment. What would change in your daily life if you flat out were unable to commit code that breaks the build? The short answer is, "Quality goes up." I bit more verbose answer is that I need to be more careful before committing my code.
</p><p>Yes, I know other vendors have had this feature for a while. So what? So, Team Foundation Server shouldn't have it too? It rocks and now we get it in Team Foundation Build.
</p><h2>IntelliTrace
</h2><p>I am not even sure how cool this is yet, only that it is. This feature is also known as Historical Debugging and gives the ability to step back and forth through call stacks and watched variables during a debug run. To be clear, that's <em>Back and Forth through time</em>. So, the first time I hit the breakpoint, here was the status of the code. The second time it was this. And so on. Also, I can inspect all this data on system events (like CLR events) and can therefore tap into my app at a lot of different levels.
</p><p>Now, I know that you don't need debuggers anymore because every line of code we write is Test Driven and that means we don't need debuggers, right? Yeah, sure you never need a debugger. As I said, this is just a wicked tool, but I am not yet sure how wicked. The community will definitely ferret that out over time.
</p><h2>Other Stuff
</h2><p>This only scratches the surface of what's in Visual Studio and Team Foundation Server 2010. There are a lot more things, many of them bigger and higher profile than the things I mentioned. I just happen to be in love with these particular features at the moment. As I get deeper into things, I will let you know what I see.
</p><p>One last thing, I know these tools get a lot of flak in some communities, but I feel comfortable with them. I also understand that many developers out there in the world don't get to choose their tools. Often tools are assigned. What I see is that the 2010 versions of Visual Studio and Team Foundation Server really have raised the bar. I don't feel like teams are still having to compromise on tooling to get everything they need in an integrated environment.
</p><p>Will I still run R#? Well, yeah.
</p><p>
 </p><p>
 </p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Powershell: Load assembly without locking file.</title>
		<link>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-load-assembly-without-locking-file</link>
		<comments>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 05:40:23 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/</guid>
		<description><![CDATA[I have a set of PowerShell build scripts and ran into a case where I needed to load an assembly (to get the assembly’s version) and still (at a later time) work with the assembly file on disk. A typical way to load an assembly within PowerShell is to use the Assembly.LoadFrom(filePath) # Powershell [System.Reflection.Assembly]::LoadFrom($assemblyPath) [...]]]></description>
			<content:encoded><![CDATA[<p>I have a set of PowerShell build scripts and ran into a case where I needed to load an assembly (to get the assembly’s version) and still (at a later time) work with the assembly file on disk.</p>  <p>A typical way to load an assembly within PowerShell is to use the Assembly.LoadFrom(filePath)</p>  <blockquote>   <p># Powershell</p>    <p>[System.Reflection.Assembly]::LoadFrom($assemblyPath)</p> </blockquote>  <p><a href="http://elegantcode.com/wp-content/uploads/2009/12/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2009/12/image_thumb9.png" width="690" height="391" /></a> </p>  <p>Except the problem with this (in my case) was it would <strong>lock the file for the lifespan of the PowerShell console instance</strong>. I didn’t want to have to close and re-open the PowerShell console every time I need to run a build so there had to be a work-around for this.</p>  <p>After searching the web for a solution, I couldn’t find anything that was “easy” and worth the effort to get it to work.</p>  <blockquote>   <p>EX: One solution was to create a new AppDomain, do the necessary work and the close the AppDomain which would release the lock on the file.</p>    <p>I’ve never done this myself, and even thought there is example code out there to get this accomplished, it just seemed over the top for what I was trying to do, and back to my previous criteria it wasn’t “worth the effort to get it to work”</p> </blockquote>  <p>Then I remembered in a previous life I used an overload that took an array of bytes to load the an assembly.</p>  <blockquote>   <p>[System.Reflection.Assembly]::Load($assemblyBytes)</p> </blockquote>  <p>After spiking it in PowerShell with the below test. I was quite happy with the solution, so I thought I’d throw it out there.</p>  <p>Just stream the assembly from disk into a byte array manually, and call assembly load from there.</p>  <p>Here’s my test case which shows that the file is not locked after it was loaded into the PowerShell runtime</p>  <pre>$file = &quot;.\Moq.dll&quot;
$tempFileName = &quot;.\Moq-Renamed.dll&quot;

$fileStream = ([System.IO.FileInfo] (Get-Item $file)).OpenRead();
$assemblyBytes = new-object byte[] $fileStream.Length
$fileStream.Read($assemblyBytes, 0, $fileStream.Length);
$fileStream.Close();

$assemblyLoaded = [System.Reflection.Assembly]::Load($assemblyBytes);

# notice that we can move the file on disk after 
# it's loaded into the powershell runtime
Move-Item $file $tempFileName
Move-Item $tempFileName $file 

# and display the assembly information to show we still have it in memory
echo $assemblyLoaded</pre>

<p>After that test passed, and the main reason I wanted to do this, I wrote the “get-assembly-version” PowerShell function.</p>

<pre><strike>function get-assembly-version() {
    param([string] $file)
    
    # load the assembly bytes quickly - as to not lock the file for too long
    $fileStream = ([System.IO.FileInfo] (Get-Item $file)).OpenRead()
    $assemblyBytes = new-object byte[] $fileStream.Length
    $fileStream.Read($assemblyBytes, 0, $fileStream.Length) | Out-Null #out null this because this function should only return the version &amp; this call was outputting some garbage number
    $fileStream.Close()
    
    # return the version of the assembly
    [System.Reflection.Assembly]::Load($assemblyBytes).GetName().Version;
}

$version = get-assembly-version(&quot;.\Moq.dll&quot;)

echo &quot;Loaded v$($version.Major).$($version.Minor).$($version.Build).$($version.Revision) version of $file&quot;</strike></pre>
Hope this helps someone out there! 

<p></p>

<p>&#160;</p>

<p><strong>UPDATE:</strong></p>

<p><a href="http://achuebrigens.wordpress.com">Martin</a> commented below on a much better solution to the assembly version info problem. Amazing how complicated we can make things if we don’t know the path.</p>

<pre>
function get-assembly-version() {
    param([string] $file)
    
    $version = [System.Reflection.AssemblyName]::GetAssemblyName($file).Version;
    
    #format the version and output it...
    $version
}</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Removing WSUS</title>
		<link>http://elegantcode.com/2009/12/01/removing-wsus/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=removing-wsus</link>
		<comments>http://elegantcode.com/2009/12/01/removing-wsus/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 21:53:49 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[WSUS]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/01/removing-wsus/</guid>
		<description><![CDATA[A while back, the company I work for experimented with setting up a Windows Server Update Service (WSUS).&#160; The idea is that you have one server that goes out and downloads all of the hotfixes, service packs, and so on for your network – then each of your client machines goes directly to the local [...]]]></description>
			<content:encoded><![CDATA[<p>A while back, the company I work for experimented with setting up a Windows Server Update Service (WSUS).&#160; The idea is that you have one server that goes out and downloads all of the hotfixes, service packs, and so on for your network – then each of your client machines goes directly to the local WSUS server to get the weekly dose of patches, configurable by various group policies, and with monitoring to make sure that everything is going smoothly.&#160; At the time we set it up, we were having crushing bandwidth problems – two servers downloading a service pack would pretty much disable the building…</p>  <p>Over time, the bandwidth problems were fixed, and as sometimes happens the WSUS server crumbled to dust.&#160; For the most part nobody noticed – new servers and clients were not configured with the WSUS policy, downloading their hotfixes direct from Microsoft through plentiful bandwidth.&#160; Unfortunately, older server and clients were left in the dark, sending cries out to a WSUS URL that will never respond...&#160; oops</p>  <h4>To Fix (and get your automatic updates to work again):</h4>  <p>Delete the registry key at “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate”.&#160; For fun, restart the “Windows Update” service (not sure if this is necessary).&#160; </p>  <p>I found <a href="http://www.d.umn.edu/itss/security/sus/" target="_blank">this VBS file</a> to be useful in figuring out if a server was still trying to use an old WSUS install, or if the problem was group-policy related.&#160; </p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/01/removing-wsus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PDC Notes</title>
		<link>http://elegantcode.com/2009/11/17/pdc-notes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pdc-notes</link>
		<comments>http://elegantcode.com/2009/11/17/pdc-notes/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 17:23:30 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/17/pdc-notes/</guid>
		<description><![CDATA[I am grateful to INETA to be attending PDC this year. Also, I grateful to Visual Stuart, who is letting me crash in his room. Turns out, I am a cheap skate :) I am sitting in the keynote on Tuesday and thinking about the week. In addition to the Wait? What the… Wordpress moving [...]]]></description>
			<content:encoded><![CDATA[<p>I am grateful to INETA to be attending <a href="http://microsoftpdc.com">PDC</a> this year. Also, I grateful to <a href="http://visualstuart.com">Visual Stuart</a>, who is letting me crash in his room. Turns out, I am a cheap skate :)</p>  <p>I am sitting in the keynote on Tuesday and thinking about the week. In addition to the </p>  <blockquote>   <p><font style="background-color: #ffffff">Wait? What the… Wordpress moving into the Azure cloud? Sweet!</font></p> </blockquote>  <p>volunteer sessions I am doing for INETA, I am hosting a Birds of a Feather session with Mike Vincent. Our BOF is this afternoon and is entitled, “Agile Tales of Triumph, Tribulation, Tools, and Teams”. Drop by and join the discussion to learn </p>  <blockquote>   <p><font style="background-color: #ffffff">Code name Dallas: A uniform way to access data in the cloud and mash it all up.</font></p> </blockquote>  <p>and share what really works.</p>  <p>It has been very cool to meet many of the Pluralsight instructors for the first time. We all live in different parts of the world, and PDC provides that opportunity for us to </p>  <blockquote>   <p>Everyone get your 3D glasses on! Oh, that was very anti-climactic.</p> </blockquote>  <p>all actually shake physical hands rather than electronic ones.</p>  <p>Also, drop by the Pluralsight booth and share your developer stories with me. Here’s the sneak peek as to why: <font style="background-color: #ffffff"><a href="http://www.pluralsight.com/main/pluralcast/default.aspx">Pluralcast</a>. More on that in another post. Suffice </font></p>  <blockquote>   <p><font style="background-color: #ffffff">I think that guy onstage is showing an iPhone and talking about how easy it was to write an app for it. Weird.</font></p> </blockquote>  <p><font style="background-color: #ffffff">to say </font>there will be some changes in the Elegant Code Cast.</p>  <blockquote>   <p>Did he just say, “Create applications for the good of the republic?” Seriously?</p> </blockquote>  <p>Lastly, if you see me running around the halls, please stop me and say, Hello.” It’s very cool to be able to meet people I usually only get to chat with online. If you are looking for a <a href="http://guild3.com">great developer team</a> to build your next big thing, we can talk about that, too!</p>  <blockquote>   <p>Please stop saying “3 screens in the cloud.”</p> </blockquote>  <p>Ray Ozzie final points from the keynote:</p>  <ol>   <li>Bet your next user experience on Windows 7</li>    <li>When thinking of the cloud, bet on Azure.</li>    <li>Take a moment to think about how the world is changing and the potential role of cloud in that world.</li> </ol>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/17/pdc-notes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>StructureMap and SharePoint</title>
		<link>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=structuremap-and-sharepoint</link>
		<comments>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 18:00:22 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[StructureMap]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/</guid>
		<description><![CDATA[I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; </p>  <p>I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user is authorized to use.&#160; The source of this data (names, URLs, etc.) comes from an external-to-SharePoint system, accessed through another C# assembly.&#160; Once the web part gets the data there is some more processing to be done – we need to do more than just blindly display a list of URLs.&#160; Rather than get into details I’m just going to do some handwaving here and say that “if you have access to X, then {stuff happens}, or if you have access to Y then {other stuff happens}.”&#160; You know, business logic, stuff that is good to test.</p>  <p>the first thing I need to do is get business logic out of the WebPart and into something that I can write without having to reset AppPools over and over, not to mention have some unit tests to verify I’m going in the right direction.&#160; So, I created a standard application service class which has a dependency on the external authorization system, via constructor injection.&#160; </p>  <pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> AuthorizedAppsService : IAuthorizedAppsService
{
  <span class="kwrd">private</span> <span class="kwrd">readonly</span> ExternalAuthorizeService authService;

  <span class="kwrd">public</span> AuthorizedAppsService(
    ExternalAuthorizeService authService) 
  {
    <span class="kwrd">this</span>.authService = authService;
  }

  <span class="kwrd">public</span> AuthorizedApplications GetAuthorizedApplications(
                                  <span class="kwrd">string</span> userName)
  {
    var allApps = authService.AuthorizedApplications(userName);
    <span class="rem">// business logic stuff happens here</span>
    <span class="kwrd">return</span> thoseResultsWeJustFiguredOut;
  }
}</pre>

<p>Next, I created a StructureMap Registry class to scan my assemblies, as well as adding in the details of how to create this external authorize service, using the typical method: <style type="text/css">




.csharpcode, .csharpcode pre
{
	font-size: x-small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style></p>

<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyRegistry : Registry
{
  <span class="kwrd">public</span> MyRegistry()
  {
    Scan(scanner =&gt; {
      scanner.TheCallingAssembly();
      scanner.AssemblyContainingType(<span class="kwrd">typeof</span>(MyRegistry));
      scanner.WithDefaultConventions();
      });

    ForRequestedType&lt;ExternalAuthorizeService&gt;()
      .AsSingletons()
      .TheDefault.Is.ConstructedBy(c =&gt; Provider.GetService());

    <span class="rem">// other dependency configuration...</span>
  }
  <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> InitializeForSharepoint()
  {
    ObjectFactory.Initialize(init =&gt; init.AddRegistry&lt;MyRegistry&gt;());
    ObjectFactory.AssertConfigurationIsValid();
  }
}</pre>

<p>And then, what remains is to have SharePoint call my StructureMap initialization when my SharePoint application starts up.&#160; In an MVC or WebForms app, I’d just add code to the appropriate place in Global.asax.cs, but in SharePointLand, this is looked down on.&#160; Instead, the preferred mechanism seems to be to use an HttpModule and a FeatureReceiver to plug the Module into the app’s web.config.</p>

<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyStartupModule : IHttpModule
{
  <span class="kwrd">public</span> <span class="kwrd">void</span> Init(HttpApplication context)
  {
        ConfigureOtherStuff();
        MyRegistry.InitializeForSharepoint();
  }
  <span class="kwrd">public</span> <span class="kwrd">void</span> Dispose() { }
}</pre>

<p>And then the FeatureReceiver to alter the app’s Web.Config looks something like this (note I borrowed most of this code from another sample SharePoint project:</p>

<p>&#160;</p>

<pre class="csharpcode"><span class="rem">//</span>
<span class="rem">// this is borrowing heavily from http://www.codeplex.com/SPAXO</span>
<span class="rem">// </span>
<span class="kwrd">public</span> <span class="kwrd">class</span> StartupFeatureReceiver : SPFeatureReceiver
{
  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureActivated(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    AddWebConfigEntry(webApp);
    UpdateApp(webApp);
  }

  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureDeactivating(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    RemoveWebConfigEntry(webApp);
    UpdateApp(webApp);
  }


  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> AddWebConfigEntry(SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    var existingModifications = 
             <span class="kwrd">new</span> List&lt;SPWebConfigModification&gt;(
                      webApp.WebConfigModifications);
    <span class="kwrd">if</span> (existingModifications.FindIndex(
                    <span class="kwrd">value</span> =&gt;
                        <span class="kwrd">value</span>.Name == mod.Name &amp;&amp;
                        <span class="kwrd">value</span>.Value == mod.Value &amp;&amp;
                        <span class="kwrd">value</span>.Owner == mod.Owner) == -1)
    {
      <span class="rem">// If the modifcation does not already exist </span>
      <span class="rem">// add the entry to the config</span>
      webApp.WebConfigModifications.Add(mod);
    }
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> RemoveWebConfigEntry(
            SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    webApp.WebConfigModifications.Remove(mod);
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> SPWebConfigModification GetModification()
  {
    <span class="kwrd">string</span> asmName = <span class="kwrd">typeof</span>(StartupModule).AssemblyQualifiedName;
    <span class="kwrd">string</span> typeName = <span class="kwrd">typeof</span>(StartupModule).FullName;

    <span class="kwrd">return</span> <span class="kwrd">new</span> SPWebConfigModification
      {
        Path = <span class="str">&quot;configuration/system.web/httpModules&quot;</span>,
        Name = String.Format(CultureInfo.InvariantCulture,
                <span class="str">&quot;add[@name='{0}'][@type='{1}']&quot;</span>,
                typeName, asmName),
        Sequence = 0,
        Owner = asmName,
        Type = SPWebConfigModification.
                    SPWebConfigModificationType.EnsureChildNode,
        Value = String.Format(CultureInfo.InvariantCulture,
                  <span class="str">&quot;&lt;add name='{0}' type='{1}' /&gt;&quot;</span>,
                  typeName, asmName)
      };
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> UpdateApp(SPWebApplication webApp)
  {
    <span class="rem">// Update the Web App and apply the changes </span>
    <span class="rem">// to all servers in the farm</span>
    webApp.Update();
    webApp.Farm.Services
        .GetValue&lt;SPWebService&gt;()
        .ApplyWebConfigModifications();
  }
}</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Integration Test Brought to you by Powershell &amp; NUnit &#8211; with a Little Specification Syntax for Flavoring</title>
		<link>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=looking-ahead-to-2010</link>
		<comments>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 21:02:11 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/02/09/looking-ahead-to-2010/</guid>
		<description><![CDATA[No, this isn't another prognostication post foretelling the woes of the world for the next year. This is a note to everyone who hasn't yet played with the Visual Studio ALM tools and Team Foundation Server 2010. Folks, this product is getting better. That stands to reason. After all, this is basically version 3 of [...]]]></description>
			<content:encoded><![CDATA[<p><img align="left" src="http://elegantcode.com/wp-content/uploads/2010/02/020910_2101_LookingAhea13.png" alt=""/>No, this isn't another prognostication post foretelling the woes of the world for the next year. This is a note to everyone who hasn't yet played with the Visual Studio ALM tools and Team Foundation Server 2010.
</p><p>Folks, this product is getting better. That stands to reason. After all, this is basically version 3 of the product and you know what they say! Version 3 is the one to buy. Most of the kinks are worked out now.
</p><p>Now, I won't pretend for a moment that Team Foundation Server hasn't had its challenges fitting in with agile teams. I think that has come from a history of development by a team that itself was learning and growing just like the rest of us. Now that many of the teams within Microsoft are practicing some form of iterative development with completed cycles of "all the way done", we are starting to see the influence in the tools they are producing. And the effect is not half bad.
</p><p>I have been using Visual Studio 2010 for a few months now, and with the recent release of the RC, I can see:
</p><ol><li>Performance is getting better (XAML).
</li><li>Features are getting more solid (fewer exceptions)
</li><li>The polish of the overall user experience is becoming a great example of an application I am happy to look at all day long.
</li><li>The Team Foundation Server features being added are consistent with what we are learning to be effective as an agile community.
</li></ol><p>So, where's the meat? What are these shiny features of which you speak, Mr. Starr? Well, here is a short sample because I am sitting in an airport listening to the chaos and I can't think of it all. 
</p><p>I should also say that this is a very small list of features that I personally am really excited about. The rest of the world probably has other things they care about. These are mine because I believe they have to potential to really change life on a team for the better.
</p><h2>Layer Diagrams
</h2><p>There is a major focus in this release to add UML support to Visual Studio Ultimate. OK, not a huge fan and I know some people will dog on this feature, but I am all about the Layer Diagrams. These are diagrams that we can create just like the UML diagrams that Visual Studio now supports, but the value of a Layer Diagram is that it has teeth and can bite back. 
</p><p>Here's how it works:
</p><ol><li>Create a Layer Diagram.
</li><li>Draw your favorite design pattern or desired architectural separation model using tools in the Toolbox. In a simple example, this might be to create a model of the MVP pattern. In a large example this model might show the multiple layers in my solution that uses CSLA, Silverlight with MVVM, WCF, and Entity Framework. (Hi, Scott <span style="font-family:Wingdings">J</span> You knew that was for you.)
</li><li>Add some things to it from your solution. Drop things onto the diagram and into the boxes like classes, namespaces, and Visual Studio projects.
</li><li>Now you can generate dependencies between these things and see the existing relationships. Yawn. Cool, but we get this with dependency diagrams, too.
</li><li><div>Validate the model.<br/><br/>Wait for it. . .  Grok it. . .
</div><p><br/>You got it! Yeah, that's right. Validate the LOGICAL model of your application. This is so sweet it comes on a stick. This means that not only can I verify I haven't violated my design with a bad reference or super egregious abstraction hole, but I can make this validation part of the build process and catch it if I accidently violate my own design later. Where I come from, they call that cool.
</p></li></ol><h2>Way Better Work Items
</h2><p>This is non-trivial for teams who live every day of their lives in Team Foundation Server to manage their requirements and work queues. Sure, we might all prefer note cards on the wall, but for many this is simply not possible. And for those folks who use Team Foundation Server to manage their notecards, there are some great new things to make that task easier.
</p><ol><li>Hierarchical relationships between Work Items.
</li><li>Agile planning Workbooks.
</li><li>Seamless Team Project Dashboards.
</li><li>MSF Agile 5.
</li></ol><h2>Gated Check In
</h2><p>This is a feature of Team Foundation Build that will actually build and test your software before a check-in is committed to Source Control. The mechanical effect of this is simple: Code that would break the build is never committed to Source Control. The implications are far larger, though. Think it through for a moment. What would change in your daily life if you flat out were unable to commit code that breaks the build? The short answer is, "Quality goes up." I bit more verbose answer is that I need to be more careful before committing my code.
</p><p>Yes, I know other vendors have had this feature for a while. So what? So, Team Foundation Server shouldn't have it too? It rocks and now we get it in Team Foundation Build.
</p><h2>IntelliTrace
</h2><p>I am not even sure how cool this is yet, only that it is. This feature is also known as Historical Debugging and gives the ability to step back and forth through call stacks and watched variables during a debug run. To be clear, that's <em>Back and Forth through time</em>. So, the first time I hit the breakpoint, here was the status of the code. The second time it was this. And so on. Also, I can inspect all this data on system events (like CLR events) and can therefore tap into my app at a lot of different levels.
</p><p>Now, I know that you don't need debuggers anymore because every line of code we write is Test Driven and that means we don't need debuggers, right? Yeah, sure you never need a debugger. As I said, this is just a wicked tool, but I am not yet sure how wicked. The community will definitely ferret that out over time.
</p><h2>Other Stuff
</h2><p>This only scratches the surface of what's in Visual Studio and Team Foundation Server 2010. There are a lot more things, many of them bigger and higher profile than the things I mentioned. I just happen to be in love with these particular features at the moment. As I get deeper into things, I will let you know what I see.
</p><p>One last thing, I know these tools get a lot of flak in some communities, but I feel comfortable with them. I also understand that many developers out there in the world don't get to choose their tools. Often tools are assigned. What I see is that the 2010 versions of Visual Studio and Team Foundation Server really have raised the bar. I don't feel like teams are still having to compromise on tooling to get everything they need in an integrated environment.
</p><p>Will I still run R#? Well, yeah.
</p><p>
 </p><p>
 </p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Elegant Code &#187; Microsoft</title>
	<atom:link href="http://elegantcode.com/category/microsoft/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Buy Quinine Without Prescription</title>
		<link>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=awarded-microsoft-community-contributor-award-2012</link>
		<comments>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 23:03:17 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[awards]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/</guid>
		<description><![CDATA[Buy Quinine Without Prescription, Today I received an email informing me that I have been awarded the Microsoft Community Contributor Award.&#160; This is the second time I have been awarded this particular award and it feels just as good this time as it did last time.&#160; I’m not sure how you go about getting nominated [...]]]></description>
			<content:encoded><![CDATA[<p> <p> <b>Buy Quinine Without Prescription</b>, Today I received an email informing me that I have been awarded the Microsoft Community Contributor Award.&#160; This is the second time I have been awarded this particular award and it feels just as good this time as it did last time.&#160; I’m not sure how you go about getting nominated for this award, but apparently I am doing something right.</p>  <p>I would like to thank whoever nominated me for this award and Microsoft for listening to that person.&#160; I would most of all like to thank the community.&#160; Without the support of the community I would probably still be a cop. Oh, <b>australia, uk, us, usa</b>, <b>Discount Quinine</b>, you probably didn’t know that about me.</p>  <p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="Brian Lagunas awarded Microsoft Community Contributor Award" border="0" alt="Brian Lagunas awarded Microsoft Community Contributor Award" src="http://elegantcode.com/wp-content/uploads/2012/03/MCC12_Logo_Horizontal_Full-color.jpg" width="500" height="202" /></p>.  Quinine pharmacy.  Herbal Quinine.  Order Quinine no prescription.  What is Quinine.  Buy Quinine online cod.  Quinine street price.  Quinine use.  Effects of Quinine.  Buy Quinine online no prescription.  Is Quinine safe.  Where can i cheapest Quinine online.  Order Quinine online overnight delivery no prescription.  Where to buy Quinine.  Quinine duration.  Quinine from canada.  Fast shipping Quinine.  After Quinine.  Quinine no prescription.  Quinine cost.  Quinine alternatives.  Quinine samples.  Buy Quinine from canada.  Buy Quinine no prescription.  Ordering Quinine online.  Quinine mg.  Quinine dangers.  Where can i buy Quinine online.  Purchase Quinine online.  Quinine maximum dosage.  Buy Quinine online cod.  Rx free Quinine.  Order Quinine from United States pharmacy.  Buy generic Quinine.  No prescription Quinine online.  Quinine australia, uk, us, usa.  Quinine overnight.  Buy Quinine without a prescription.  Quinine online cod.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4728'>Ventolin For Sale</a>. <a href='http://elegantcode.com/?p=4184'>Synthroid For Sale</a>. <a href='http://elegantcode.com/?p=4384'>Buy Ultram Without Prescription</a>. <a href='http://elegantcode.com/?p=4373'>Topamax For Sale</a>. <a href='http://elegantcode.com/?p=5156'>Amoxicillin For Sale</a>. <a href='http://elegantcode.com/?p=4384'>Order Ultram online overnight delivery no prescription</a>. <a href='http://elegantcode.com/?p=4683'>Inderal schedule</a>. <a href='http://elegantcode.com/?p=4822'>About Hydrochlorothiazide</a>. <a href='http://elegantcode.com/?p=4728'>Ventolin australia, uk, us, usa</a>. <a href='http://elegantcode.com/?p=4694'>Human Growth Hormone interactions</a>.<br />
<b>Trackbacks from:</b> <a href='http://social-blend.com/?p=1163'>Buy Quinine Without Prescription</a>. <a href='http://www.quarterlives.com/?p=710'>Buy Quinine Without Prescription</a>. <a href='http://4realz.net/?p=1873'>Buy Quinine Without Prescription</a>. <a href='http://www.macneilbmx.com/blog/?p=6577'>Buy Quinine Without Prescription</a>. <a href='http://www.greatgreengoods.com/?p=2921'>Buy Quinine Without Prescription</a>. <a href='http://blog.farmland.org/?p=1913'>Online buy Quinine without a prescription</a>. <a href='http://reversemortgagedaily.com/?p=14688'>Is Quinine addictive</a>. <a href='http://linuxologist.com/?p=1495'>Quinine over the counter</a>. <a href='http://home.officesnapshots.com/?p=235'>Order Quinine from United States pharmacy</a>. <a href='http://evanrapoport.com/?p=720'>Generic Quinine</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Silverlight Profiling PowerShell helper.</title>
		<link>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=silverlight-profiling-powershell-helper</link>
		<comments>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/#comments</comments>
		<pubDate>Sat, 15 May 2010 16:47:22 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/</guid>
		<description><![CDATA[I was playing around with some Silverlight profiling the other night to see if I could find any obvious issues with my open source project StatLight and wound up writing a little script in PowerShell I hoped someone might find helpful. But I didn’t know you could profile a Silverlight app. I didn’t until I [...]]]></description>
			<content:encoded><![CDATA[<p>I was playing around with some Silverlight profiling the other night to see if I could find any obvious issues with my open source project <a href="http://statlight.net" target="_blank">StatLight</a> and wound up writing a little script in PowerShell I hoped someone might find helpful.</p>  <h4>But I didn’t know you could profile a Silverlight app.</h4>  <p>I didn’t until I started doing some digging online. Now, the Silverlight profiling story (at least from what I’ve seen/tried) is not near the easy of say <a href="http://www.red-gate.com/products/ants_performance_profiler/index.htm">Redgate ANTS Performance Profiler</a>. However, it’s do-able. (And with this helper script – hopefully a little simpler?)</p>  <h4>How can I profile a Silverlight Application?</h4>  <p>I would recommend you read the following blog, which explains one way of doing it very well.</p>  <p><a title="http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx" href="http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx">http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx</a></p>  <h4>So… what’s this script for?</h4>  <p>If you read the blog above, or have done this before, then you probably noticed that there was quite a series of commands you had to execute before you could wind up with a performance report. </p>  <p>I threw together a quick little PowerShell script in an attempt to automate smooth out the process.</p>  <h4>Hot do I use it?</h4>  <ol>   <li>Download the script &amp; save it somewhere. <a href="http://github.com/staxmanade/Scripts/blob/master/SilverlightProfiler.ps1"><strong>http://github.com/staxmanade/Scripts/blob/master/SilverlightProfiler.ps1</strong></a> </li>    <li>Open the PowerShell console. cd to the directory your xap/assemblies are stored.      <br />(EX: {myProject}\Bin\Debug\ ) </li>    <li>Execute:      <br />{pathToScript}\SilverlightProfiler.ps1 -urlPath &quot;{myProject}\Bin\Debug\TestPage.html&quot; </li>    <li>When your done profiling press enter to signal that your done.      <p></p> Once complete, it will print the location your profiling report was saved. You can then open it with Visual Studio.</li> </ol>  <h5>Couple of disclaimers.</h5>  <ul>   <li>Some paths are hard-coded to my x86 machine. </li>    <li>I had troubles running the built in visual studio .bat files (from powershell) that are supposed to set the environment variables. So I extracted out what vars I could find to make it work. </li>    <li>I’m not a profiling expert – just hacked this together to get it to work for me.</li> </ul>  <p>I hope this is useful, and if you know of a better way, I’m always interested in hearing your feedback.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tell me what you don&#8217;t like about TFS 2010</title>
		<link>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tell-me-what-you-dont-like-about-tfs-2010</link>
		<comments>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/#comments</comments>
		<pubDate>Sat, 15 May 2010 15:48:18 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Team System]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/</guid>
		<description><![CDATA[I know that a lot of people have had bad experiences with TFS over the years, and so does the TFS development team. The team at Microsoft is very intent on learning what it is that people find irritating, problematic, or difficult, and correcting it. Some major headway was made with the 2010 release of [...]]]></description>
			<content:encoded><![CDATA[<p>I know that a lot of people have had bad experiences with TFS over the years, and so does the TFS development team. The team at Microsoft is very intent on learning what it is that people find irritating, problematic, or difficult, and correcting it. Some major headway was made with the 2010 release of Team Foundation Server to make it easier to setup and administer, and also to improve the usability of several of its key features.</p>  <p>That said, there is still room for improvement and both the team and I understand there are still opportunities to improve. In all seriousness, the team at Microsoft wants to make TFS an approachable, no-brainer install decision for .NET teams, even small ones. This means they want to be able to compete for your attention with the likes of SVN, Git, Jira, Perforce, and anyone else making collaboration tools for developers.</p>  <p>The point of this post is for you to help me know what feedback I can give the TFS product development team as they look ahead to the next release of TFS. I am looking for legitimate feedback I can give the team on how to improve the TFS product.</p>  <p>Please bear in mind that I am interested in your feedback on TFS 2010, as TFS 2008 was improved upon 10 fold in the latest release. Also, I am not necessarily looking for feedback on Visual Studio, just the TFS side of the house. Please realize that the team who makes this product at Microsoft is just as committed and passionate about making great software as you are. They just really need your feedback to make the thing you want. In fact, they want to make a tool that every developer loves to use. Really. So what needs to change to make that the case?</p>  <p>Recall that TFS functionality is broken into the following major areas and I am looking for feedback on the 2010 version.</p>  <ul>   <li>Version Control </li>    <li>Work Item management </li>    <li>Team Foundation Build </li>    <li>SharePoint integration (optional) </li>    <li>Reporting and SSRS Integration (optional) </li> </ul>  <p>Thanks for anything you have. Thank you also for being respectful and not making this a bash-fest.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>Visual Studio: Open in Full XAML View by Default</title>
		<link>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=visual-studio-open-in-full-xaml-view-by-default</link>
		<comments>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 15:49:14 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/</guid>
		<description><![CDATA[So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane [...]]]></description>
			<content:encoded><![CDATA[<p>So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane blows.&#160; So now I have to sit and wait for VS to render my view in the preview pane, and sometimes it can take a while, if it doesn’t just completely crash.&#160; Sometimes I take the extra time to go grab a snack and beverage of my choice.&#160; </p>  <p>So here is a hidden performance increasing jewel you might find useful.&#160; We can set the default open mode to be in full XAML view.</p>  <p>First thing you need to do is in Visual Studio go to your Tools ==&gt; Options ==&gt; Text Editor ==&gt; XAML ==&gt; Miscellaneous.&#160; There you will see an option for “Always open documents in full XAML view”.&#160; Check that box.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/04/image.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="xaml options for opening in full xaml view" border="0" alt="xaml options for opening in full xaml view" src="http://elegantcode.com/wp-content/uploads/2010/04/image_thumb.png" width="244" height="146" /></a> </p>  <p>Now every time you open a XAML file it will open in full XAML view and give you one less thing to gripe about.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Looking Ahead to 2010</title>
		<link>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=looking-ahead-to-2010</link>
		<comments>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 21:02:11 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/02/09/looking-ahead-to-2010/</guid>
		<description><![CDATA[No, this isn't another prognostication post foretelling the woes of the world for the next year. This is a note to everyone who hasn't yet played with the Visual Studio ALM tools and Team Foundation Server 2010. Folks, this product is getting better. That stands to reason. After all, this is basically version 3 of [...]]]></description>
			<content:encoded><![CDATA[<p><img align="left" src="http://elegantcode.com/wp-content/uploads/2010/02/020910_2101_LookingAhea13.png" alt=""/>No, this isn't another prognostication post foretelling the woes of the world for the next year. This is a note to everyone who hasn't yet played with the Visual Studio ALM tools and Team Foundation Server 2010.
</p><p>Folks, this product is getting better. That stands to reason. After all, this is basically version 3 of the product and you know what they say! Version 3 is the one to buy. Most of the kinks are worked out now.
</p><p>Now, I won't pretend for a moment that Team Foundation Server hasn't had its challenges fitting in with agile teams. I think that has come from a history of development by a team that itself was learning and growing just like the rest of us. Now that many of the teams within Microsoft are practicing some form of iterative development with completed cycles of "all the way done", we are starting to see the influence in the tools they are producing. And the effect is not half bad.
</p><p>I have been using Visual Studio 2010 for a few months now, and with the recent release of the RC, I can see:
</p><ol><li>Performance is getting better (XAML).
</li><li>Features are getting more solid (fewer exceptions)
</li><li>The polish of the overall user experience is becoming a great example of an application I am happy to look at all day long.
</li><li>The Team Foundation Server features being added are consistent with what we are learning to be effective as an agile community.
</li></ol><p>So, where's the meat? What are these shiny features of which you speak, Mr. Starr? Well, here is a short sample because I am sitting in an airport listening to the chaos and I can't think of it all. 
</p><p>I should also say that this is a very small list of features that I personally am really excited about. The rest of the world probably has other things they care about. These are mine because I believe they have to potential to really change life on a team for the better.
</p><h2>Layer Diagrams
</h2><p>There is a major focus in this release to add UML support to Visual Studio Ultimate. OK, not a huge fan and I know some people will dog on this feature, but I am all about the Layer Diagrams. These are diagrams that we can create just like the UML diagrams that Visual Studio now supports, but the value of a Layer Diagram is that it has teeth and can bite back. 
</p><p>Here's how it works:
</p><ol><li>Create a Layer Diagram.
</li><li>Draw your favorite design pattern or desired architectural separation model using tools in the Toolbox. In a simple example, this might be to create a model of the MVP pattern. In a large example this model might show the multiple layers in my solution that uses CSLA, Silverlight with MVVM, WCF, and Entity Framework. (Hi, Scott <span style="font-family:Wingdings">J</span> You knew that was for you.)
</li><li>Add some things to it from your solution. Drop things onto the diagram and into the boxes like classes, namespaces, and Visual Studio projects.
</li><li>Now you can generate dependencies between these things and see the existing relationships. Yawn. Cool, but we get this with dependency diagrams, too.
</li><li><div>Validate the model.<br/><br/>Wait for it. . .  Grok it. . .
</div><p><br/>You got it! Yeah, that's right. Validate the LOGICAL model of your application. This is so sweet it comes on a stick. This means that not only can I verify I haven't violated my design with a bad reference or super egregious abstraction hole, but I can make this validation part of the build process and catch it if I accidently violate my own design later. Where I come from, they call that cool.
</p></li></ol><h2>Way Better Work Items
</h2><p>This is non-trivial for teams who live every day of their lives in Team Foundation Server to manage their requirements and work queues. Sure, we might all prefer note cards on the wall, but for many this is simply not possible. And for those folks who use Team Foundation Server to manage their notecards, there are some great new things to make that task easier.
</p><ol><li>Hierarchical relationships between Work Items.
</li><li>Agile planning Workbooks.
</li><li>Seamless Team Project Dashboards.
</li><li>MSF Agile 5.
</li></ol><h2>Gated Check In
</h2><p>This is a feature of Team Foundation Build that will actually build and test your software before a check-in is committed to Source Control. The mechanical effect of this is simple: Code that would break the build is never committed to Source Control. The implications are far larger, though. Think it through for a moment. What would change in your daily life if you flat out were unable to commit code that breaks the build? The short answer is, "Quality goes up." I bit more verbose answer is that I need to be more careful before committing my code.
</p><p>Yes, I know other vendors have had this feature for a while. So what? So, Team Foundation Server shouldn't have it too? It rocks and now we get it in Team Foundation Build.
</p><h2>IntelliTrace
</h2><p>I am not even sure how cool this is yet, only that it is. This feature is also known as Historical Debugging and gives the ability to step back and forth through call stacks and watched variables during a debug run. To be clear, that's <em>Back and Forth through time</em>. So, the first time I hit the breakpoint, here was the status of the code. The second time it was this. And so on. Also, I can inspect all this data on system events (like CLR events) and can therefore tap into my app at a lot of different levels.
</p><p>Now, I know that you don't need debuggers anymore because every line of code we write is Test Driven and that means we don't need debuggers, right? Yeah, sure you never need a debugger. As I said, this is just a wicked tool, but I am not yet sure how wicked. The community will definitely ferret that out over time.
</p><h2>Other Stuff
</h2><p>This only scratches the surface of what's in Visual Studio and Team Foundation Server 2010. There are a lot more things, many of them bigger and higher profile than the things I mentioned. I just happen to be in love with these particular features at the moment. As I get deeper into things, I will let you know what I see.
</p><p>One last thing, I know these tools get a lot of flak in some communities, but I feel comfortable with them. I also understand that many developers out there in the world don't get to choose their tools. Often tools are assigned. What I see is that the 2010 versions of Visual Studio and Team Foundation Server really have raised the bar. I don't feel like teams are still having to compromise on tooling to get everything they need in an integrated environment.
</p><p>Will I still run R#? Well, yeah.
</p><p>
 </p><p>
 </p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Powershell: Load assembly without locking file.</title>
		<link>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-load-assembly-without-locking-file</link>
		<comments>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 05:40:23 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/</guid>
		<description><![CDATA[I have a set of PowerShell build scripts and ran into a case where I needed to load an assembly (to get the assembly’s version) and still (at a later time) work with the assembly file on disk. A typical way to load an assembly within PowerShell is to use the Assembly.LoadFrom(filePath) # Powershell [System.Reflection.Assembly]::LoadFrom($assemblyPath) [...]]]></description>
			<content:encoded><![CDATA[<p>I have a set of PowerShell build scripts and ran into a case where I needed to load an assembly (to get the assembly’s version) and still (at a later time) work with the assembly file on disk.</p>  <p>A typical way to load an assembly within PowerShell is to use the Assembly.LoadFrom(filePath)</p>  <blockquote>   <p># Powershell</p>    <p>[System.Reflection.Assembly]::LoadFrom($assemblyPath)</p> </blockquote>  <p><a href="http://elegantcode.com/wp-content/uploads/2009/12/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2009/12/image_thumb9.png" width="690" height="391" /></a> </p>  <p>Except the problem with this (in my case) was it would <strong>lock the file for the lifespan of the PowerShell console instance</strong>. I didn’t want to have to close and re-open the PowerShell console every time I need to run a build so there had to be a work-around for this.</p>  <p>After searching the web for a solution, I couldn’t find anything that was “easy” and worth the effort to get it to work.</p>  <blockquote>   <p>EX: One solution was to create a new AppDomain, do the necessary work and the close the AppDomain which would release the lock on the file.</p>    <p>I’ve never done this myself, and even thought there is example code out there to get this accomplished, it just seemed over the top for what I was trying to do, and back to my previous criteria it wasn’t “worth the effort to get it to work”</p> </blockquote>  <p>Then I remembered in a previous life I used an overload that took an array of bytes to load the an assembly.</p>  <blockquote>   <p>[System.Reflection.Assembly]::Load($assemblyBytes)</p> </blockquote>  <p>After spiking it in PowerShell with the below test. I was quite happy with the solution, so I thought I’d throw it out there.</p>  <p>Just stream the assembly from disk into a byte array manually, and call assembly load from there.</p>  <p>Here’s my test case which shows that the file is not locked after it was loaded into the PowerShell runtime</p>  <pre>$file = &quot;.\Moq.dll&quot;
$tempFileName = &quot;.\Moq-Renamed.dll&quot;

$fileStream = ([System.IO.FileInfo] (Get-Item $file)).OpenRead();
$assemblyBytes = new-object byte[] $fileStream.Length
$fileStream.Read($assemblyBytes, 0, $fileStream.Length);
$fileStream.Close();

$assemblyLoaded = [System.Reflection.Assembly]::Load($assemblyBytes);

# notice that we can move the file on disk after 
# it's loaded into the powershell runtime
Move-Item $file $tempFileName
Move-Item $tempFileName $file 

# and display the assembly information to show we still have it in memory
echo $assemblyLoaded</pre>

<p>After that test passed, and the main reason I wanted to do this, I wrote the “get-assembly-version” PowerShell function.</p>

<pre><strike>function get-assembly-version() {
    param([string] $file)
    
    # load the assembly bytes quickly - as to not lock the file for too long
    $fileStream = ([System.IO.FileInfo] (Get-Item $file)).OpenRead()
    $assemblyBytes = new-object byte[] $fileStream.Length
    $fileStream.Read($assemblyBytes, 0, $fileStream.Length) | Out-Null #out null this because this function should only return the version &amp; this call was outputting some garbage number
    $fileStream.Close()
    
    # return the version of the assembly
    [System.Reflection.Assembly]::Load($assemblyBytes).GetName().Version;
}

$version = get-assembly-version(&quot;.\Moq.dll&quot;)

echo &quot;Loaded v$($version.Major).$($version.Minor).$($version.Build).$($version.Revision) version of $file&quot;</strike></pre>
Hope this helps someone out there! 

<p></p>

<p>&#160;</p>

<p><strong>UPDATE:</strong></p>

<p><a href="http://achuebrigens.wordpress.com">Martin</a> commented below on a much better solution to the assembly version info problem. Amazing how complicated we can make things if we don’t know the path.</p>

<pre>
function get-assembly-version() {
    param([string] $file)
    
    $version = [System.Reflection.AssemblyName]::GetAssemblyName($file).Version;
    
    #format the version and output it...
    $version
}</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Removing WSUS</title>
		<link>http://elegantcode.com/2009/12/01/removing-wsus/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=removing-wsus</link>
		<comments>http://elegantcode.com/2009/12/01/removing-wsus/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 21:53:49 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[WSUS]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/01/removing-wsus/</guid>
		<description><![CDATA[A while back, the company I work for experimented with setting up a Windows Server Update Service (WSUS).&#160; The idea is that you have one server that goes out and downloads all of the hotfixes, service packs, and so on for your network – then each of your client machines goes directly to the local [...]]]></description>
			<content:encoded><![CDATA[<p>A while back, the company I work for experimented with setting up a Windows Server Update Service (WSUS).&#160; The idea is that you have one server that goes out and downloads all of the hotfixes, service packs, and so on for your network – then each of your client machines goes directly to the local WSUS server to get the weekly dose of patches, configurable by various group policies, and with monitoring to make sure that everything is going smoothly.&#160; At the time we set it up, we were having crushing bandwidth problems – two servers downloading a service pack would pretty much disable the building…</p>  <p>Over time, the bandwidth problems were fixed, and as sometimes happens the WSUS server crumbled to dust.&#160; For the most part nobody noticed – new servers and clients were not configured with the WSUS policy, downloading their hotfixes direct from Microsoft through plentiful bandwidth.&#160; Unfortunately, older server and clients were left in the dark, sending cries out to a WSUS URL that will never respond...&#160; oops</p>  <h4>To Fix (and get your automatic updates to work again):</h4>  <p>Delete the registry key at “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate”.&#160; For fun, restart the “Windows Update” service (not sure if this is necessary).&#160; </p>  <p>I found <a href="http://www.d.umn.edu/itss/security/sus/" target="_blank">this VBS file</a> to be useful in figuring out if a server was still trying to use an old WSUS install, or if the problem was group-policy related.&#160; </p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/01/removing-wsus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PDC Notes</title>
		<link>http://elegantcode.com/2009/11/17/pdc-notes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pdc-notes</link>
		<comments>http://elegantcode.com/2009/11/17/pdc-notes/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 17:23:30 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/17/pdc-notes/</guid>
		<description><![CDATA[I am grateful to INETA to be attending PDC this year. Also, I grateful to Visual Stuart, who is letting me crash in his room. Turns out, I am a cheap skate :) I am sitting in the keynote on Tuesday and thinking about the week. In addition to the Wait? What the… Wordpress moving [...]]]></description>
			<content:encoded><![CDATA[<p>I am grateful to INETA to be attending <a href="http://microsoftpdc.com">PDC</a> this year. Also, I grateful to <a href="http://visualstuart.com">Visual Stuart</a>, who is letting me crash in his room. Turns out, I am a cheap skate :)</p>  <p>I am sitting in the keynote on Tuesday and thinking about the week. In addition to the </p>  <blockquote>   <p><font style="background-color: #ffffff">Wait? What the… Wordpress moving into the Azure cloud? Sweet!</font></p> </blockquote>  <p>volunteer sessions I am doing for INETA, I am hosting a Birds of a Feather session with Mike Vincent. Our BOF is this afternoon and is entitled, “Agile Tales of Triumph, Tribulation, Tools, and Teams”. Drop by and join the discussion to learn </p>  <blockquote>   <p><font style="background-color: #ffffff">Code name Dallas: A uniform way to access data in the cloud and mash it all up.</font></p> </blockquote>  <p>and share what really works.</p>  <p>It has been very cool to meet many of the Pluralsight instructors for the first time. We all live in different parts of the world, and PDC provides that opportunity for us to </p>  <blockquote>   <p>Everyone get your 3D glasses on! Oh, that was very anti-climactic.</p> </blockquote>  <p>all actually shake physical hands rather than electronic ones.</p>  <p>Also, drop by the Pluralsight booth and share your developer stories with me. Here’s the sneak peek as to why: <font style="background-color: #ffffff"><a href="http://www.pluralsight.com/main/pluralcast/default.aspx">Pluralcast</a>. More on that in another post. Suffice </font></p>  <blockquote>   <p><font style="background-color: #ffffff">I think that guy onstage is showing an iPhone and talking about how easy it was to write an app for it. Weird.</font></p> </blockquote>  <p><font style="background-color: #ffffff">to say </font>there will be some changes in the Elegant Code Cast.</p>  <blockquote>   <p>Did he just say, “Create applications for the good of the republic?” Seriously?</p> </blockquote>  <p>Lastly, if you see me running around the halls, please stop me and say, Hello.” It’s very cool to be able to meet people I usually only get to chat with online. If you are looking for a <a href="http://guild3.com">great developer team</a> to build your next big thing, we can talk about that, too!</p>  <blockquote>   <p>Please stop saying “3 screens in the cloud.”</p> </blockquote>  <p>Ray Ozzie final points from the keynote:</p>  <ol>   <li>Bet your next user experience on Windows 7</li>    <li>When thinking of the cloud, bet on Azure.</li>    <li>Take a moment to think about how the world is changing and the potential role of cloud in that world.</li> </ol>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/17/pdc-notes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>StructureMap and SharePoint</title>
		<link>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=structuremap-and-sharepoint</link>
		<comments>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 18:00:22 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[StructureMap]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/</guid>
		<description><![CDATA[I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; </p>  <p>I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user is authorized to use.&#160; The source of this data (names, URLs, etc.) comes from an external-to-SharePoint system, accessed through another C# assembly.&#160; Once the web part gets the data there is some more processing to be done – we need to do more than just blindly display a list of URLs.&#160; Rather than get into details I’m just going to do some handwaving here and say that “if you have access to X, then {stuff happens}, or if you have access to Y then {other stuff happens}.”&#160; You know, business logic, stuff that is good to test.</p>  <p>the first thing I need to do is get business logic out of the WebPart and into something that I can write without having to reset AppPools over and over, not to mention have some unit tests to verify I’m going in the right direction.&#160; So, I created a standard application service class which has a dependency on the external authorization system, via constructor injection.&#160; </p>  <pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> AuthorizedAppsService : IAuthorizedAppsService
{
  <span class="kwrd">private</span> <span class="kwrd">readonly</span> ExternalAuthorizeService authService;

  <span class="kwrd">public</span> AuthorizedAppsService(
    ExternalAuthorizeService authService) 
  {
    <span class="kwrd">this</span>.authService = authService;
  }

  <span class="kwrd">public</span> AuthorizedApplications GetAuthorizedApplications(
                                  <span class="kwrd">string</span> userName)
  {
    var allApps = authService.AuthorizedApplications(userName);
    <span class="rem">// business logic stuff happens here</span>
    <span class="kwrd">return</span> thoseResultsWeJustFiguredOut;
  }
}</pre>

<p>Next, I created a StructureMap Registry class to scan my assemblies, as well as adding in the details of how to create this external authorize service, using the typical method: <style type="text/css">




.csharpcode, .csharpcode pre
{
	font-size: x-small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style></p>

<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyRegistry : Registry
{
  <span class="kwrd">public</span> MyRegistry()
  {
    Scan(scanner =&gt; {
      scanner.TheCallingAssembly();
      scanner.AssemblyContainingType(<span class="kwrd">typeof</span>(MyRegistry));
      scanner.WithDefaultConventions();
      });

    ForRequestedType&lt;ExternalAuthorizeService&gt;()
      .AsSingletons()
      .TheDefault.Is.ConstructedBy(c =&gt; Provider.GetService());

    <span class="rem">// other dependency configuration...</span>
  }
  <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> InitializeForSharepoint()
  {
    ObjectFactory.Initialize(init =&gt; init.AddRegistry&lt;MyRegistry&gt;());
    ObjectFactory.AssertConfigurationIsValid();
  }
}</pre>

<p>And then, what remains is to have SharePoint call my StructureMap initialization when my SharePoint application starts up.&#160; In an MVC or WebForms app, I’d just add code to the appropriate place in Global.asax.cs, but in SharePointLand, this is looked down on.&#160; Instead, the preferred mechanism seems to be to use an HttpModule and a FeatureReceiver to plug the Module into the app’s web.config.</p>

<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyStartupModule : IHttpModule
{
  <span class="kwrd">public</span> <span class="kwrd">void</span> Init(HttpApplication context)
  {
        ConfigureOtherStuff();
        MyRegistry.InitializeForSharepoint();
  }
  <span class="kwrd">public</span> <span class="kwrd">void</span> Dispose() { }
}</pre>

<p>And then the FeatureReceiver to alter the app’s Web.Config looks something like this (note I borrowed most of this code from another sample SharePoint project:</p>

<p>&#160;</p>

<pre class="csharpcode"><span class="rem">//</span>
<span class="rem">// this is borrowing heavily from http://www.codeplex.com/SPAXO</span>
<span class="rem">// </span>
<span class="kwrd">public</span> <span class="kwrd">class</span> StartupFeatureReceiver : SPFeatureReceiver
{
  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureActivated(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    AddWebConfigEntry(webApp);
    UpdateApp(webApp);
  }

  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureDeactivating(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    RemoveWebConfigEntry(webApp);
    UpdateApp(webApp);
  }


  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> AddWebConfigEntry(SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    var existingModifications = 
             <span class="kwrd">new</span> List&lt;SPWebConfigModification&gt;(
                      webApp.WebConfigModifications);
    <span class="kwrd">if</span> (existingModifications.FindIndex(
                    <span class="kwrd">value</span> =&gt;
                        <span class="kwrd">value</span>.Name == mod.Name &amp;&amp;
                        <span class="kwrd">value</span>.Value == mod.Value &amp;&amp;
                        <span class="kwrd">value</span>.Owner == mod.Owner) == -1)
    {
      <span class="rem">// If the modifcation does not already exist </span>
      <span class="rem">// add the entry to the config</span>
      webApp.WebConfigModifications.Add(mod);
    }
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> RemoveWebConfigEntry(
            SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    webApp.WebConfigModifications.Remove(mod);
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> SPWebConfigModification GetModification()
  {
    <span class="kwrd">string</span> asmName = <span class="kwrd">typeof</span>(StartupModule).AssemblyQualifiedName;
    <span class="kwrd">string</span> typeName = <span class="kwrd">typeof</span>(StartupModule).FullName;

    <span class="kwrd">return</span> <span class="kwrd">new</span> SPWebConfigModification
      {
        Path = <span class="str">&quot;configuration/system.web/httpModules&quot;</span>,
        Name = String.Format(CultureInfo.InvariantCulture,
                <span class="str">&quot;add[@name='{0}'][@type='{1}']&quot;</span>,
                typeName, asmName),
        Sequence = 0,
        Owner = asmName,
        Type = SPWebConfigModification.
                    SPWebConfigModificationType.EnsureChildNode,
        Value = String.Format(CultureInfo.InvariantCulture,
                  <span class="str">&quot;&lt;add name='{0}' type='{1}' /&gt;&quot;</span>,
                  typeName, asmName)
      };
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> UpdateApp(SPWebApplication webApp)
  {
    <span class="rem">// Update the Web App and apply the changes </span>
    <span class="rem">// to all servers in the farm</span>
    webApp.Update();
    webApp.Farm.Services
        .GetValue&lt;SPWebService&gt;()
        .ApplyWebConfigModifications();
  }
}</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Integration Test Brought to you by Powershell &amp; NUnit &#8211; with a Little Specification Syntax for Flavoring</title>
		<link>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-load-assembly-without-locking-file</link>
		<comments>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 05:40:23 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/</guid>
		<description><![CDATA[I have a set of PowerShell build scripts and ran into a case where I needed to load an assembly (to get the assembly’s version) and still (at a later time) work with the assembly file on disk. A typical way to load an assembly within PowerShell is to use the Assembly.LoadFrom(filePath) # Powershell [System.Reflection.Assembly]::LoadFrom($assemblyPath) [...]]]></description>
			<content:encoded><![CDATA[<p>I have a set of PowerShell build scripts and ran into a case where I needed to load an assembly (to get the assembly’s version) and still (at a later time) work with the assembly file on disk.</p>  <p>A typical way to load an assembly within PowerShell is to use the Assembly.LoadFrom(filePath)</p>  <blockquote>   <p># Powershell</p>    <p>[System.Reflection.Assembly]::LoadFrom($assemblyPath)</p> </blockquote>  <p><a href="http://elegantcode.com/wp-content/uploads/2009/12/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2009/12/image_thumb9.png" width="690" height="391" /></a> </p>  <p>Except the problem with this (in my case) was it would <strong>lock the file for the lifespan of the PowerShell console instance</strong>. I didn’t want to have to close and re-open the PowerShell console every time I need to run a build so there had to be a work-around for this.</p>  <p>After searching the web for a solution, I couldn’t find anything that was “easy” and worth the effort to get it to work.</p>  <blockquote>   <p>EX: One solution was to create a new AppDomain, do the necessary work and the close the AppDomain which would release the lock on the file.</p>    <p>I’ve never done this myself, and even thought there is example code out there to get this accomplished, it just seemed over the top for what I was trying to do, and back to my previous criteria it wasn’t “worth the effort to get it to work”</p> </blockquote>  <p>Then I remembered in a previous life I used an overload that took an array of bytes to load the an assembly.</p>  <blockquote>   <p>[System.Reflection.Assembly]::Load($assemblyBytes)</p> </blockquote>  <p>After spiking it in PowerShell with the below test. I was quite happy with the solution, so I thought I’d throw it out there.</p>  <p>Just stream the assembly from disk into a byte array manually, and call assembly load from there.</p>  <p>Here’s my test case which shows that the file is not locked after it was loaded into the PowerShell runtime</p>  <pre>$file = &quot;.\Moq.dll&quot;
$tempFileName = &quot;.\Moq-Renamed.dll&quot;

$fileStream = ([System.IO.FileInfo] (Get-Item $file)).OpenRead();
$assemblyBytes = new-object byte[] $fileStream.Length
$fileStream.Read($assemblyBytes, 0, $fileStream.Length);
$fileStream.Close();

$assemblyLoaded = [System.Reflection.Assembly]::Load($assemblyBytes);

# notice that we can move the file on disk after 
# it's loaded into the powershell runtime
Move-Item $file $tempFileName
Move-Item $tempFileName $file 

# and display the assembly information to show we still have it in memory
echo $assemblyLoaded</pre>

<p>After that test passed, and the main reason I wanted to do this, I wrote the “get-assembly-version” PowerShell function.</p>

<pre><strike>function get-assembly-version() {
    param([string] $file)
    
    # load the assembly bytes quickly - as to not lock the file for too long
    $fileStream = ([System.IO.FileInfo] (Get-Item $file)).OpenRead()
    $assemblyBytes = new-object byte[] $fileStream.Length
    $fileStream.Read($assemblyBytes, 0, $fileStream.Length) | Out-Null #out null this because this function should only return the version &amp; this call was outputting some garbage number
    $fileStream.Close()
    
    # return the version of the assembly
    [System.Reflection.Assembly]::Load($assemblyBytes).GetName().Version;
}

$version = get-assembly-version(&quot;.\Moq.dll&quot;)

echo &quot;Loaded v$($version.Major).$($version.Minor).$($version.Build).$($version.Revision) version of $file&quot;</strike></pre>
Hope this helps someone out there! 

<p></p>

<p>&#160;</p>

<p><strong>UPDATE:</strong></p>

<p><a href="http://achuebrigens.wordpress.com">Martin</a> commented below on a much better solution to the assembly version info problem. Amazing how complicated we can make things if we don’t know the path.</p>

<pre>
function get-assembly-version() {
    param([string] $file)
    
    $version = [System.Reflection.AssemblyName]::GetAssemblyName($file).Version;
    
    #format the version and output it...
    $version
}</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Elegant Code &#187; Microsoft</title>
	<atom:link href="http://elegantcode.com/category/microsoft/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Buy Quinine Without Prescription</title>
		<link>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=awarded-microsoft-community-contributor-award-2012</link>
		<comments>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 23:03:17 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[awards]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/</guid>
		<description><![CDATA[Buy Quinine Without Prescription, Today I received an email informing me that I have been awarded the Microsoft Community Contributor Award.&#160; This is the second time I have been awarded this particular award and it feels just as good this time as it did last time.&#160; I’m not sure how you go about getting nominated [...]]]></description>
			<content:encoded><![CDATA[<p> <p> <b>Buy Quinine Without Prescription</b>, Today I received an email informing me that I have been awarded the Microsoft Community Contributor Award.&#160; This is the second time I have been awarded this particular award and it feels just as good this time as it did last time.&#160; I’m not sure how you go about getting nominated for this award, but apparently I am doing something right.</p>  <p>I would like to thank whoever nominated me for this award and Microsoft for listening to that person.&#160; I would most of all like to thank the community.&#160; Without the support of the community I would probably still be a cop. Oh, <b>australia, uk, us, usa</b>, <b>Discount Quinine</b>, you probably didn’t know that about me.</p>  <p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="Brian Lagunas awarded Microsoft Community Contributor Award" border="0" alt="Brian Lagunas awarded Microsoft Community Contributor Award" src="http://elegantcode.com/wp-content/uploads/2012/03/MCC12_Logo_Horizontal_Full-color.jpg" width="500" height="202" /></p>.  Quinine pharmacy.  Herbal Quinine.  Order Quinine no prescription.  What is Quinine.  Buy Quinine online cod.  Quinine street price.  Quinine use.  Effects of Quinine.  Buy Quinine online no prescription.  Is Quinine safe.  Where can i cheapest Quinine online.  Order Quinine online overnight delivery no prescription.  Where to buy Quinine.  Quinine duration.  Quinine from canada.  Fast shipping Quinine.  After Quinine.  Quinine no prescription.  Quinine cost.  Quinine alternatives.  Quinine samples.  Buy Quinine from canada.  Buy Quinine no prescription.  Ordering Quinine online.  Quinine mg.  Quinine dangers.  Where can i buy Quinine online.  Purchase Quinine online.  Quinine maximum dosage.  Buy Quinine online cod.  Rx free Quinine.  Order Quinine from United States pharmacy.  Buy generic Quinine.  No prescription Quinine online.  Quinine australia, uk, us, usa.  Quinine overnight.  Buy Quinine without a prescription.  Quinine online cod.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4728'>Ventolin For Sale</a>. <a href='http://elegantcode.com/?p=4184'>Synthroid For Sale</a>. <a href='http://elegantcode.com/?p=4384'>Buy Ultram Without Prescription</a>. <a href='http://elegantcode.com/?p=4373'>Topamax For Sale</a>. <a href='http://elegantcode.com/?p=5156'>Amoxicillin For Sale</a>. <a href='http://elegantcode.com/?p=4384'>Order Ultram online overnight delivery no prescription</a>. <a href='http://elegantcode.com/?p=4683'>Inderal schedule</a>. <a href='http://elegantcode.com/?p=4822'>About Hydrochlorothiazide</a>. <a href='http://elegantcode.com/?p=4728'>Ventolin australia, uk, us, usa</a>. <a href='http://elegantcode.com/?p=4694'>Human Growth Hormone interactions</a>.<br />
<b>Trackbacks from:</b> <a href='http://social-blend.com/?p=1163'>Buy Quinine Without Prescription</a>. <a href='http://www.quarterlives.com/?p=710'>Buy Quinine Without Prescription</a>. <a href='http://4realz.net/?p=1873'>Buy Quinine Without Prescription</a>. <a href='http://www.macneilbmx.com/blog/?p=6577'>Buy Quinine Without Prescription</a>. <a href='http://www.greatgreengoods.com/?p=2921'>Buy Quinine Without Prescription</a>. <a href='http://blog.farmland.org/?p=1913'>Online buy Quinine without a prescription</a>. <a href='http://reversemortgagedaily.com/?p=14688'>Is Quinine addictive</a>. <a href='http://linuxologist.com/?p=1495'>Quinine over the counter</a>. <a href='http://home.officesnapshots.com/?p=235'>Order Quinine from United States pharmacy</a>. <a href='http://evanrapoport.com/?p=720'>Generic Quinine</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Silverlight Profiling PowerShell helper.</title>
		<link>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=silverlight-profiling-powershell-helper</link>
		<comments>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/#comments</comments>
		<pubDate>Sat, 15 May 2010 16:47:22 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/</guid>
		<description><![CDATA[I was playing around with some Silverlight profiling the other night to see if I could find any obvious issues with my open source project StatLight and wound up writing a little script in PowerShell I hoped someone might find helpful. But I didn’t know you could profile a Silverlight app. I didn’t until I [...]]]></description>
			<content:encoded><![CDATA[<p>I was playing around with some Silverlight profiling the other night to see if I could find any obvious issues with my open source project <a href="http://statlight.net" target="_blank">StatLight</a> and wound up writing a little script in PowerShell I hoped someone might find helpful.</p>  <h4>But I didn’t know you could profile a Silverlight app.</h4>  <p>I didn’t until I started doing some digging online. Now, the Silverlight profiling story (at least from what I’ve seen/tried) is not near the easy of say <a href="http://www.red-gate.com/products/ants_performance_profiler/index.htm">Redgate ANTS Performance Profiler</a>. However, it’s do-able. (And with this helper script – hopefully a little simpler?)</p>  <h4>How can I profile a Silverlight Application?</h4>  <p>I would recommend you read the following blog, which explains one way of doing it very well.</p>  <p><a title="http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx" href="http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx">http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx</a></p>  <h4>So… what’s this script for?</h4>  <p>If you read the blog above, or have done this before, then you probably noticed that there was quite a series of commands you had to execute before you could wind up with a performance report. </p>  <p>I threw together a quick little PowerShell script in an attempt to automate smooth out the process.</p>  <h4>Hot do I use it?</h4>  <ol>   <li>Download the script &amp; save it somewhere. <a href="http://github.com/staxmanade/Scripts/blob/master/SilverlightProfiler.ps1"><strong>http://github.com/staxmanade/Scripts/blob/master/SilverlightProfiler.ps1</strong></a> </li>    <li>Open the PowerShell console. cd to the directory your xap/assemblies are stored.      <br />(EX: {myProject}\Bin\Debug\ ) </li>    <li>Execute:      <br />{pathToScript}\SilverlightProfiler.ps1 -urlPath &quot;{myProject}\Bin\Debug\TestPage.html&quot; </li>    <li>When your done profiling press enter to signal that your done.      <p></p> Once complete, it will print the location your profiling report was saved. You can then open it with Visual Studio.</li> </ol>  <h5>Couple of disclaimers.</h5>  <ul>   <li>Some paths are hard-coded to my x86 machine. </li>    <li>I had troubles running the built in visual studio .bat files (from powershell) that are supposed to set the environment variables. So I extracted out what vars I could find to make it work. </li>    <li>I’m not a profiling expert – just hacked this together to get it to work for me.</li> </ul>  <p>I hope this is useful, and if you know of a better way, I’m always interested in hearing your feedback.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tell me what you don&#8217;t like about TFS 2010</title>
		<link>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tell-me-what-you-dont-like-about-tfs-2010</link>
		<comments>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/#comments</comments>
		<pubDate>Sat, 15 May 2010 15:48:18 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Team System]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/</guid>
		<description><![CDATA[I know that a lot of people have had bad experiences with TFS over the years, and so does the TFS development team. The team at Microsoft is very intent on learning what it is that people find irritating, problematic, or difficult, and correcting it. Some major headway was made with the 2010 release of [...]]]></description>
			<content:encoded><![CDATA[<p>I know that a lot of people have had bad experiences with TFS over the years, and so does the TFS development team. The team at Microsoft is very intent on learning what it is that people find irritating, problematic, or difficult, and correcting it. Some major headway was made with the 2010 release of Team Foundation Server to make it easier to setup and administer, and also to improve the usability of several of its key features.</p>  <p>That said, there is still room for improvement and both the team and I understand there are still opportunities to improve. In all seriousness, the team at Microsoft wants to make TFS an approachable, no-brainer install decision for .NET teams, even small ones. This means they want to be able to compete for your attention with the likes of SVN, Git, Jira, Perforce, and anyone else making collaboration tools for developers.</p>  <p>The point of this post is for you to help me know what feedback I can give the TFS product development team as they look ahead to the next release of TFS. I am looking for legitimate feedback I can give the team on how to improve the TFS product.</p>  <p>Please bear in mind that I am interested in your feedback on TFS 2010, as TFS 2008 was improved upon 10 fold in the latest release. Also, I am not necessarily looking for feedback on Visual Studio, just the TFS side of the house. Please realize that the team who makes this product at Microsoft is just as committed and passionate about making great software as you are. They just really need your feedback to make the thing you want. In fact, they want to make a tool that every developer loves to use. Really. So what needs to change to make that the case?</p>  <p>Recall that TFS functionality is broken into the following major areas and I am looking for feedback on the 2010 version.</p>  <ul>   <li>Version Control </li>    <li>Work Item management </li>    <li>Team Foundation Build </li>    <li>SharePoint integration (optional) </li>    <li>Reporting and SSRS Integration (optional) </li> </ul>  <p>Thanks for anything you have. Thank you also for being respectful and not making this a bash-fest.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>Visual Studio: Open in Full XAML View by Default</title>
		<link>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=visual-studio-open-in-full-xaml-view-by-default</link>
		<comments>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 15:49:14 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/</guid>
		<description><![CDATA[So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane [...]]]></description>
			<content:encoded><![CDATA[<p>So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane blows.&#160; So now I have to sit and wait for VS to render my view in the preview pane, and sometimes it can take a while, if it doesn’t just completely crash.&#160; Sometimes I take the extra time to go grab a snack and beverage of my choice.&#160; </p>  <p>So here is a hidden performance increasing jewel you might find useful.&#160; We can set the default open mode to be in full XAML view.</p>  <p>First thing you need to do is in Visual Studio go to your Tools ==&gt; Options ==&gt; Text Editor ==&gt; XAML ==&gt; Miscellaneous.&#160; There you will see an option for “Always open documents in full XAML view”.&#160; Check that box.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/04/image.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="xaml options for opening in full xaml view" border="0" alt="xaml options for opening in full xaml view" src="http://elegantcode.com/wp-content/uploads/2010/04/image_thumb.png" width="244" height="146" /></a> </p>  <p>Now every time you open a XAML file it will open in full XAML view and give you one less thing to gripe about.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Looking Ahead to 2010</title>
		<link>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=looking-ahead-to-2010</link>
		<comments>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 21:02:11 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/02/09/looking-ahead-to-2010/</guid>
		<description><![CDATA[No, this isn't another prognostication post foretelling the woes of the world for the next year. This is a note to everyone who hasn't yet played with the Visual Studio ALM tools and Team Foundation Server 2010. Folks, this product is getting better. That stands to reason. After all, this is basically version 3 of [...]]]></description>
			<content:encoded><![CDATA[<p><img align="left" src="http://elegantcode.com/wp-content/uploads/2010/02/020910_2101_LookingAhea13.png" alt=""/>No, this isn't another prognostication post foretelling the woes of the world for the next year. This is a note to everyone who hasn't yet played with the Visual Studio ALM tools and Team Foundation Server 2010.
</p><p>Folks, this product is getting better. That stands to reason. After all, this is basically version 3 of the product and you know what they say! Version 3 is the one to buy. Most of the kinks are worked out now.
</p><p>Now, I won't pretend for a moment that Team Foundation Server hasn't had its challenges fitting in with agile teams. I think that has come from a history of development by a team that itself was learning and growing just like the rest of us. Now that many of the teams within Microsoft are practicing some form of iterative development with completed cycles of "all the way done", we are starting to see the influence in the tools they are producing. And the effect is not half bad.
</p><p>I have been using Visual Studio 2010 for a few months now, and with the recent release of the RC, I can see:
</p><ol><li>Performance is getting better (XAML).
</li><li>Features are getting more solid (fewer exceptions)
</li><li>The polish of the overall user experience is becoming a great example of an application I am happy to look at all day long.
</li><li>The Team Foundation Server features being added are consistent with what we are learning to be effective as an agile community.
</li></ol><p>So, where's the meat? What are these shiny features of which you speak, Mr. Starr? Well, here is a short sample because I am sitting in an airport listening to the chaos and I can't think of it all. 
</p><p>I should also say that this is a very small list of features that I personally am really excited about. The rest of the world probably has other things they care about. These are mine because I believe they have to potential to really change life on a team for the better.
</p><h2>Layer Diagrams
</h2><p>There is a major focus in this release to add UML support to Visual Studio Ultimate. OK, not a huge fan and I know some people will dog on this feature, but I am all about the Layer Diagrams. These are diagrams that we can create just like the UML diagrams that Visual Studio now supports, but the value of a Layer Diagram is that it has teeth and can bite back. 
</p><p>Here's how it works:
</p><ol><li>Create a Layer Diagram.
</li><li>Draw your favorite design pattern or desired architectural separation model using tools in the Toolbox. In a simple example, this might be to create a model of the MVP pattern. In a large example this model might show the multiple layers in my solution that uses CSLA, Silverlight with MVVM, WCF, and Entity Framework. (Hi, Scott <span style="font-family:Wingdings">J</span> You knew that was for you.)
</li><li>Add some things to it from your solution. Drop things onto the diagram and into the boxes like classes, namespaces, and Visual Studio projects.
</li><li>Now you can generate dependencies between these things and see the existing relationships. Yawn. Cool, but we get this with dependency diagrams, too.
</li><li><div>Validate the model.<br/><br/>Wait for it. . .  Grok it. . .
</div><p><br/>You got it! Yeah, that's right. Validate the LOGICAL model of your application. This is so sweet it comes on a stick. This means that not only can I verify I haven't violated my design with a bad reference or super egregious abstraction hole, but I can make this validation part of the build process and catch it if I accidently violate my own design later. Where I come from, they call that cool.
</p></li></ol><h2>Way Better Work Items
</h2><p>This is non-trivial for teams who live every day of their lives in Team Foundation Server to manage their requirements and work queues. Sure, we might all prefer note cards on the wall, but for many this is simply not possible. And for those folks who use Team Foundation Server to manage their notecards, there are some great new things to make that task easier.
</p><ol><li>Hierarchical relationships between Work Items.
</li><li>Agile planning Workbooks.
</li><li>Seamless Team Project Dashboards.
</li><li>MSF Agile 5.
</li></ol><h2>Gated Check In
</h2><p>This is a feature of Team Foundation Build that will actually build and test your software before a check-in is committed to Source Control. The mechanical effect of this is simple: Code that would break the build is never committed to Source Control. The implications are far larger, though. Think it through for a moment. What would change in your daily life if you flat out were unable to commit code that breaks the build? The short answer is, "Quality goes up." I bit more verbose answer is that I need to be more careful before committing my code.
</p><p>Yes, I know other vendors have had this feature for a while. So what? So, Team Foundation Server shouldn't have it too? It rocks and now we get it in Team Foundation Build.
</p><h2>IntelliTrace
</h2><p>I am not even sure how cool this is yet, only that it is. This feature is also known as Historical Debugging and gives the ability to step back and forth through call stacks and watched variables during a debug run. To be clear, that's <em>Back and Forth through time</em>. So, the first time I hit the breakpoint, here was the status of the code. The second time it was this. And so on. Also, I can inspect all this data on system events (like CLR events) and can therefore tap into my app at a lot of different levels.
</p><p>Now, I know that you don't need debuggers anymore because every line of code we write is Test Driven and that means we don't need debuggers, right? Yeah, sure you never need a debugger. As I said, this is just a wicked tool, but I am not yet sure how wicked. The community will definitely ferret that out over time.
</p><h2>Other Stuff
</h2><p>This only scratches the surface of what's in Visual Studio and Team Foundation Server 2010. There are a lot more things, many of them bigger and higher profile than the things I mentioned. I just happen to be in love with these particular features at the moment. As I get deeper into things, I will let you know what I see.
</p><p>One last thing, I know these tools get a lot of flak in some communities, but I feel comfortable with them. I also understand that many developers out there in the world don't get to choose their tools. Often tools are assigned. What I see is that the 2010 versions of Visual Studio and Team Foundation Server really have raised the bar. I don't feel like teams are still having to compromise on tooling to get everything they need in an integrated environment.
</p><p>Will I still run R#? Well, yeah.
</p><p>
 </p><p>
 </p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Powershell: Load assembly without locking file.</title>
		<link>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-load-assembly-without-locking-file</link>
		<comments>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 05:40:23 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/</guid>
		<description><![CDATA[I have a set of PowerShell build scripts and ran into a case where I needed to load an assembly (to get the assembly’s version) and still (at a later time) work with the assembly file on disk. A typical way to load an assembly within PowerShell is to use the Assembly.LoadFrom(filePath) # Powershell [System.Reflection.Assembly]::LoadFrom($assemblyPath) [...]]]></description>
			<content:encoded><![CDATA[<p>I have a set of PowerShell build scripts and ran into a case where I needed to load an assembly (to get the assembly’s version) and still (at a later time) work with the assembly file on disk.</p>  <p>A typical way to load an assembly within PowerShell is to use the Assembly.LoadFrom(filePath)</p>  <blockquote>   <p># Powershell</p>    <p>[System.Reflection.Assembly]::LoadFrom($assemblyPath)</p> </blockquote>  <p><a href="http://elegantcode.com/wp-content/uploads/2009/12/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2009/12/image_thumb9.png" width="690" height="391" /></a> </p>  <p>Except the problem with this (in my case) was it would <strong>lock the file for the lifespan of the PowerShell console instance</strong>. I didn’t want to have to close and re-open the PowerShell console every time I need to run a build so there had to be a work-around for this.</p>  <p>After searching the web for a solution, I couldn’t find anything that was “easy” and worth the effort to get it to work.</p>  <blockquote>   <p>EX: One solution was to create a new AppDomain, do the necessary work and the close the AppDomain which would release the lock on the file.</p>    <p>I’ve never done this myself, and even thought there is example code out there to get this accomplished, it just seemed over the top for what I was trying to do, and back to my previous criteria it wasn’t “worth the effort to get it to work”</p> </blockquote>  <p>Then I remembered in a previous life I used an overload that took an array of bytes to load the an assembly.</p>  <blockquote>   <p>[System.Reflection.Assembly]::Load($assemblyBytes)</p> </blockquote>  <p>After spiking it in PowerShell with the below test. I was quite happy with the solution, so I thought I’d throw it out there.</p>  <p>Just stream the assembly from disk into a byte array manually, and call assembly load from there.</p>  <p>Here’s my test case which shows that the file is not locked after it was loaded into the PowerShell runtime</p>  <pre>$file = &quot;.\Moq.dll&quot;
$tempFileName = &quot;.\Moq-Renamed.dll&quot;

$fileStream = ([System.IO.FileInfo] (Get-Item $file)).OpenRead();
$assemblyBytes = new-object byte[] $fileStream.Length
$fileStream.Read($assemblyBytes, 0, $fileStream.Length);
$fileStream.Close();

$assemblyLoaded = [System.Reflection.Assembly]::Load($assemblyBytes);

# notice that we can move the file on disk after 
# it's loaded into the powershell runtime
Move-Item $file $tempFileName
Move-Item $tempFileName $file 

# and display the assembly information to show we still have it in memory
echo $assemblyLoaded</pre>

<p>After that test passed, and the main reason I wanted to do this, I wrote the “get-assembly-version” PowerShell function.</p>

<pre><strike>function get-assembly-version() {
    param([string] $file)
    
    # load the assembly bytes quickly - as to not lock the file for too long
    $fileStream = ([System.IO.FileInfo] (Get-Item $file)).OpenRead()
    $assemblyBytes = new-object byte[] $fileStream.Length
    $fileStream.Read($assemblyBytes, 0, $fileStream.Length) | Out-Null #out null this because this function should only return the version &amp; this call was outputting some garbage number
    $fileStream.Close()
    
    # return the version of the assembly
    [System.Reflection.Assembly]::Load($assemblyBytes).GetName().Version;
}

$version = get-assembly-version(&quot;.\Moq.dll&quot;)

echo &quot;Loaded v$($version.Major).$($version.Minor).$($version.Build).$($version.Revision) version of $file&quot;</strike></pre>
Hope this helps someone out there! 

<p></p>

<p>&#160;</p>

<p><strong>UPDATE:</strong></p>

<p><a href="http://achuebrigens.wordpress.com">Martin</a> commented below on a much better solution to the assembly version info problem. Amazing how complicated we can make things if we don’t know the path.</p>

<pre>
function get-assembly-version() {
    param([string] $file)
    
    $version = [System.Reflection.AssemblyName]::GetAssemblyName($file).Version;
    
    #format the version and output it...
    $version
}</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Removing WSUS</title>
		<link>http://elegantcode.com/2009/12/01/removing-wsus/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=removing-wsus</link>
		<comments>http://elegantcode.com/2009/12/01/removing-wsus/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 21:53:49 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[WSUS]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/01/removing-wsus/</guid>
		<description><![CDATA[A while back, the company I work for experimented with setting up a Windows Server Update Service (WSUS).&#160; The idea is that you have one server that goes out and downloads all of the hotfixes, service packs, and so on for your network – then each of your client machines goes directly to the local [...]]]></description>
			<content:encoded><![CDATA[<p>A while back, the company I work for experimented with setting up a Windows Server Update Service (WSUS).&#160; The idea is that you have one server that goes out and downloads all of the hotfixes, service packs, and so on for your network – then each of your client machines goes directly to the local WSUS server to get the weekly dose of patches, configurable by various group policies, and with monitoring to make sure that everything is going smoothly.&#160; At the time we set it up, we were having crushing bandwidth problems – two servers downloading a service pack would pretty much disable the building…</p>  <p>Over time, the bandwidth problems were fixed, and as sometimes happens the WSUS server crumbled to dust.&#160; For the most part nobody noticed – new servers and clients were not configured with the WSUS policy, downloading their hotfixes direct from Microsoft through plentiful bandwidth.&#160; Unfortunately, older server and clients were left in the dark, sending cries out to a WSUS URL that will never respond...&#160; oops</p>  <h4>To Fix (and get your automatic updates to work again):</h4>  <p>Delete the registry key at “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate”.&#160; For fun, restart the “Windows Update” service (not sure if this is necessary).&#160; </p>  <p>I found <a href="http://www.d.umn.edu/itss/security/sus/" target="_blank">this VBS file</a> to be useful in figuring out if a server was still trying to use an old WSUS install, or if the problem was group-policy related.&#160; </p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/01/removing-wsus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PDC Notes</title>
		<link>http://elegantcode.com/2009/11/17/pdc-notes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pdc-notes</link>
		<comments>http://elegantcode.com/2009/11/17/pdc-notes/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 17:23:30 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/17/pdc-notes/</guid>
		<description><![CDATA[I am grateful to INETA to be attending PDC this year. Also, I grateful to Visual Stuart, who is letting me crash in his room. Turns out, I am a cheap skate :) I am sitting in the keynote on Tuesday and thinking about the week. In addition to the Wait? What the… Wordpress moving [...]]]></description>
			<content:encoded><![CDATA[<p>I am grateful to INETA to be attending <a href="http://microsoftpdc.com">PDC</a> this year. Also, I grateful to <a href="http://visualstuart.com">Visual Stuart</a>, who is letting me crash in his room. Turns out, I am a cheap skate :)</p>  <p>I am sitting in the keynote on Tuesday and thinking about the week. In addition to the </p>  <blockquote>   <p><font style="background-color: #ffffff">Wait? What the… Wordpress moving into the Azure cloud? Sweet!</font></p> </blockquote>  <p>volunteer sessions I am doing for INETA, I am hosting a Birds of a Feather session with Mike Vincent. Our BOF is this afternoon and is entitled, “Agile Tales of Triumph, Tribulation, Tools, and Teams”. Drop by and join the discussion to learn </p>  <blockquote>   <p><font style="background-color: #ffffff">Code name Dallas: A uniform way to access data in the cloud and mash it all up.</font></p> </blockquote>  <p>and share what really works.</p>  <p>It has been very cool to meet many of the Pluralsight instructors for the first time. We all live in different parts of the world, and PDC provides that opportunity for us to </p>  <blockquote>   <p>Everyone get your 3D glasses on! Oh, that was very anti-climactic.</p> </blockquote>  <p>all actually shake physical hands rather than electronic ones.</p>  <p>Also, drop by the Pluralsight booth and share your developer stories with me. Here’s the sneak peek as to why: <font style="background-color: #ffffff"><a href="http://www.pluralsight.com/main/pluralcast/default.aspx">Pluralcast</a>. More on that in another post. Suffice </font></p>  <blockquote>   <p><font style="background-color: #ffffff">I think that guy onstage is showing an iPhone and talking about how easy it was to write an app for it. Weird.</font></p> </blockquote>  <p><font style="background-color: #ffffff">to say </font>there will be some changes in the Elegant Code Cast.</p>  <blockquote>   <p>Did he just say, “Create applications for the good of the republic?” Seriously?</p> </blockquote>  <p>Lastly, if you see me running around the halls, please stop me and say, Hello.” It’s very cool to be able to meet people I usually only get to chat with online. If you are looking for a <a href="http://guild3.com">great developer team</a> to build your next big thing, we can talk about that, too!</p>  <blockquote>   <p>Please stop saying “3 screens in the cloud.”</p> </blockquote>  <p>Ray Ozzie final points from the keynote:</p>  <ol>   <li>Bet your next user experience on Windows 7</li>    <li>When thinking of the cloud, bet on Azure.</li>    <li>Take a moment to think about how the world is changing and the potential role of cloud in that world.</li> </ol>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/17/pdc-notes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>StructureMap and SharePoint</title>
		<link>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=structuremap-and-sharepoint</link>
		<comments>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 18:00:22 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[StructureMap]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/</guid>
		<description><![CDATA[I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; </p>  <p>I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user is authorized to use.&#160; The source of this data (names, URLs, etc.) comes from an external-to-SharePoint system, accessed through another C# assembly.&#160; Once the web part gets the data there is some more processing to be done – we need to do more than just blindly display a list of URLs.&#160; Rather than get into details I’m just going to do some handwaving here and say that “if you have access to X, then {stuff happens}, or if you have access to Y then {other stuff happens}.”&#160; You know, business logic, stuff that is good to test.</p>  <p>the first thing I need to do is get business logic out of the WebPart and into something that I can write without having to reset AppPools over and over, not to mention have some unit tests to verify I’m going in the right direction.&#160; So, I created a standard application service class which has a dependency on the external authorization system, via constructor injection.&#160; </p>  <pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> AuthorizedAppsService : IAuthorizedAppsService
{
  <span class="kwrd">private</span> <span class="kwrd">readonly</span> ExternalAuthorizeService authService;

  <span class="kwrd">public</span> AuthorizedAppsService(
    ExternalAuthorizeService authService) 
  {
    <span class="kwrd">this</span>.authService = authService;
  }

  <span class="kwrd">public</span> AuthorizedApplications GetAuthorizedApplications(
                                  <span class="kwrd">string</span> userName)
  {
    var allApps = authService.AuthorizedApplications(userName);
    <span class="rem">// business logic stuff happens here</span>
    <span class="kwrd">return</span> thoseResultsWeJustFiguredOut;
  }
}</pre>

<p>Next, I created a StructureMap Registry class to scan my assemblies, as well as adding in the details of how to create this external authorize service, using the typical method: <style type="text/css">




.csharpcode, .csharpcode pre
{
	font-size: x-small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style></p>

<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyRegistry : Registry
{
  <span class="kwrd">public</span> MyRegistry()
  {
    Scan(scanner =&gt; {
      scanner.TheCallingAssembly();
      scanner.AssemblyContainingType(<span class="kwrd">typeof</span>(MyRegistry));
      scanner.WithDefaultConventions();
      });

    ForRequestedType&lt;ExternalAuthorizeService&gt;()
      .AsSingletons()
      .TheDefault.Is.ConstructedBy(c =&gt; Provider.GetService());

    <span class="rem">// other dependency configuration...</span>
  }
  <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> InitializeForSharepoint()
  {
    ObjectFactory.Initialize(init =&gt; init.AddRegistry&lt;MyRegistry&gt;());
    ObjectFactory.AssertConfigurationIsValid();
  }
}</pre>

<p>And then, what remains is to have SharePoint call my StructureMap initialization when my SharePoint application starts up.&#160; In an MVC or WebForms app, I’d just add code to the appropriate place in Global.asax.cs, but in SharePointLand, this is looked down on.&#160; Instead, the preferred mechanism seems to be to use an HttpModule and a FeatureReceiver to plug the Module into the app’s web.config.</p>

<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyStartupModule : IHttpModule
{
  <span class="kwrd">public</span> <span class="kwrd">void</span> Init(HttpApplication context)
  {
        ConfigureOtherStuff();
        MyRegistry.InitializeForSharepoint();
  }
  <span class="kwrd">public</span> <span class="kwrd">void</span> Dispose() { }
}</pre>

<p>And then the FeatureReceiver to alter the app’s Web.Config looks something like this (note I borrowed most of this code from another sample SharePoint project:</p>

<p>&#160;</p>

<pre class="csharpcode"><span class="rem">//</span>
<span class="rem">// this is borrowing heavily from http://www.codeplex.com/SPAXO</span>
<span class="rem">// </span>
<span class="kwrd">public</span> <span class="kwrd">class</span> StartupFeatureReceiver : SPFeatureReceiver
{
  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureActivated(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    AddWebConfigEntry(webApp);
    UpdateApp(webApp);
  }

  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureDeactivating(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    RemoveWebConfigEntry(webApp);
    UpdateApp(webApp);
  }


  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> AddWebConfigEntry(SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    var existingModifications = 
             <span class="kwrd">new</span> List&lt;SPWebConfigModification&gt;(
                      webApp.WebConfigModifications);
    <span class="kwrd">if</span> (existingModifications.FindIndex(
                    <span class="kwrd">value</span> =&gt;
                        <span class="kwrd">value</span>.Name == mod.Name &amp;&amp;
                        <span class="kwrd">value</span>.Value == mod.Value &amp;&amp;
                        <span class="kwrd">value</span>.Owner == mod.Owner) == -1)
    {
      <span class="rem">// If the modifcation does not already exist </span>
      <span class="rem">// add the entry to the config</span>
      webApp.WebConfigModifications.Add(mod);
    }
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> RemoveWebConfigEntry(
            SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    webApp.WebConfigModifications.Remove(mod);
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> SPWebConfigModification GetModification()
  {
    <span class="kwrd">string</span> asmName = <span class="kwrd">typeof</span>(StartupModule).AssemblyQualifiedName;
    <span class="kwrd">string</span> typeName = <span class="kwrd">typeof</span>(StartupModule).FullName;

    <span class="kwrd">return</span> <span class="kwrd">new</span> SPWebConfigModification
      {
        Path = <span class="str">&quot;configuration/system.web/httpModules&quot;</span>,
        Name = String.Format(CultureInfo.InvariantCulture,
                <span class="str">&quot;add[@name='{0}'][@type='{1}']&quot;</span>,
                typeName, asmName),
        Sequence = 0,
        Owner = asmName,
        Type = SPWebConfigModification.
                    SPWebConfigModificationType.EnsureChildNode,
        Value = String.Format(CultureInfo.InvariantCulture,
                  <span class="str">&quot;&lt;add name='{0}' type='{1}' /&gt;&quot;</span>,
                  typeName, asmName)
      };
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> UpdateApp(SPWebApplication webApp)
  {
    <span class="rem">// Update the Web App and apply the changes </span>
    <span class="rem">// to all servers in the farm</span>
    webApp.Update();
    webApp.Farm.Services
        .GetValue&lt;SPWebService&gt;()
        .ApplyWebConfigModifications();
  }
}</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Integration Test Brought to you by Powershell &amp; NUnit &#8211; with a Little Specification Syntax for Flavoring</title>
		<link>http://elegantcode.com/2009/12/01/removing-wsus/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=removing-wsus</link>
		<comments>http://elegantcode.com/2009/12/01/removing-wsus/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 21:53:49 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[WSUS]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/01/removing-wsus/</guid>
		<description><![CDATA[A while back, the company I work for experimented with setting up a Windows Server Update Service (WSUS).&#160; The idea is that you have one server that goes out and downloads all of the hotfixes, service packs, and so on for your network – then each of your client machines goes directly to the local [...]]]></description>
			<content:encoded><![CDATA[<p>A while back, the company I work for experimented with setting up a Windows Server Update Service (WSUS).&#160; The idea is that you have one server that goes out and downloads all of the hotfixes, service packs, and so on for your network – then each of your client machines goes directly to the local WSUS server to get the weekly dose of patches, configurable by various group policies, and with monitoring to make sure that everything is going smoothly.&#160; At the time we set it up, we were having crushing bandwidth problems – two servers downloading a service pack would pretty much disable the building…</p>  <p>Over time, the bandwidth problems were fixed, and as sometimes happens the WSUS server crumbled to dust.&#160; For the most part nobody noticed – new servers and clients were not configured with the WSUS policy, downloading their hotfixes direct from Microsoft through plentiful bandwidth.&#160; Unfortunately, older server and clients were left in the dark, sending cries out to a WSUS URL that will never respond...&#160; oops</p>  <h4>To Fix (and get your automatic updates to work again):</h4>  <p>Delete the registry key at “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate”.&#160; For fun, restart the “Windows Update” service (not sure if this is necessary).&#160; </p>  <p>I found <a href="http://www.d.umn.edu/itss/security/sus/" target="_blank">this VBS file</a> to be useful in figuring out if a server was still trying to use an old WSUS install, or if the problem was group-policy related.&#160; </p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/01/removing-wsus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Elegant Code &#187; Microsoft</title>
	<atom:link href="http://elegantcode.com/category/microsoft/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Buy Quinine Without Prescription</title>
		<link>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=awarded-microsoft-community-contributor-award-2012</link>
		<comments>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 23:03:17 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[awards]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/</guid>
		<description><![CDATA[Buy Quinine Without Prescription, Today I received an email informing me that I have been awarded the Microsoft Community Contributor Award.&#160; This is the second time I have been awarded this particular award and it feels just as good this time as it did last time.&#160; I’m not sure how you go about getting nominated [...]]]></description>
			<content:encoded><![CDATA[<p> <p> <b>Buy Quinine Without Prescription</b>, Today I received an email informing me that I have been awarded the Microsoft Community Contributor Award.&#160; This is the second time I have been awarded this particular award and it feels just as good this time as it did last time.&#160; I’m not sure how you go about getting nominated for this award, but apparently I am doing something right.</p>  <p>I would like to thank whoever nominated me for this award and Microsoft for listening to that person.&#160; I would most of all like to thank the community.&#160; Without the support of the community I would probably still be a cop. Oh, <b>australia, uk, us, usa</b>, <b>Discount Quinine</b>, you probably didn’t know that about me.</p>  <p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="Brian Lagunas awarded Microsoft Community Contributor Award" border="0" alt="Brian Lagunas awarded Microsoft Community Contributor Award" src="http://elegantcode.com/wp-content/uploads/2012/03/MCC12_Logo_Horizontal_Full-color.jpg" width="500" height="202" /></p>.  Quinine pharmacy.  Herbal Quinine.  Order Quinine no prescription.  What is Quinine.  Buy Quinine online cod.  Quinine street price.  Quinine use.  Effects of Quinine.  Buy Quinine online no prescription.  Is Quinine safe.  Where can i cheapest Quinine online.  Order Quinine online overnight delivery no prescription.  Where to buy Quinine.  Quinine duration.  Quinine from canada.  Fast shipping Quinine.  After Quinine.  Quinine no prescription.  Quinine cost.  Quinine alternatives.  Quinine samples.  Buy Quinine from canada.  Buy Quinine no prescription.  Ordering Quinine online.  Quinine mg.  Quinine dangers.  Where can i buy Quinine online.  Purchase Quinine online.  Quinine maximum dosage.  Buy Quinine online cod.  Rx free Quinine.  Order Quinine from United States pharmacy.  Buy generic Quinine.  No prescription Quinine online.  Quinine australia, uk, us, usa.  Quinine overnight.  Buy Quinine without a prescription.  Quinine online cod.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4728'>Ventolin For Sale</a>. <a href='http://elegantcode.com/?p=4184'>Synthroid For Sale</a>. <a href='http://elegantcode.com/?p=4384'>Buy Ultram Without Prescription</a>. <a href='http://elegantcode.com/?p=4373'>Topamax For Sale</a>. <a href='http://elegantcode.com/?p=5156'>Amoxicillin For Sale</a>. <a href='http://elegantcode.com/?p=4384'>Order Ultram online overnight delivery no prescription</a>. <a href='http://elegantcode.com/?p=4683'>Inderal schedule</a>. <a href='http://elegantcode.com/?p=4822'>About Hydrochlorothiazide</a>. <a href='http://elegantcode.com/?p=4728'>Ventolin australia, uk, us, usa</a>. <a href='http://elegantcode.com/?p=4694'>Human Growth Hormone interactions</a>.<br />
<b>Trackbacks from:</b> <a href='http://social-blend.com/?p=1163'>Buy Quinine Without Prescription</a>. <a href='http://www.quarterlives.com/?p=710'>Buy Quinine Without Prescription</a>. <a href='http://4realz.net/?p=1873'>Buy Quinine Without Prescription</a>. <a href='http://www.macneilbmx.com/blog/?p=6577'>Buy Quinine Without Prescription</a>. <a href='http://www.greatgreengoods.com/?p=2921'>Buy Quinine Without Prescription</a>. <a href='http://blog.farmland.org/?p=1913'>Online buy Quinine without a prescription</a>. <a href='http://reversemortgagedaily.com/?p=14688'>Is Quinine addictive</a>. <a href='http://linuxologist.com/?p=1495'>Quinine over the counter</a>. <a href='http://home.officesnapshots.com/?p=235'>Order Quinine from United States pharmacy</a>. <a href='http://evanrapoport.com/?p=720'>Generic Quinine</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Silverlight Profiling PowerShell helper.</title>
		<link>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=silverlight-profiling-powershell-helper</link>
		<comments>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/#comments</comments>
		<pubDate>Sat, 15 May 2010 16:47:22 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/</guid>
		<description><![CDATA[I was playing around with some Silverlight profiling the other night to see if I could find any obvious issues with my open source project StatLight and wound up writing a little script in PowerShell I hoped someone might find helpful. But I didn’t know you could profile a Silverlight app. I didn’t until I [...]]]></description>
			<content:encoded><![CDATA[<p>I was playing around with some Silverlight profiling the other night to see if I could find any obvious issues with my open source project <a href="http://statlight.net" target="_blank">StatLight</a> and wound up writing a little script in PowerShell I hoped someone might find helpful.</p>  <h4>But I didn’t know you could profile a Silverlight app.</h4>  <p>I didn’t until I started doing some digging online. Now, the Silverlight profiling story (at least from what I’ve seen/tried) is not near the easy of say <a href="http://www.red-gate.com/products/ants_performance_profiler/index.htm">Redgate ANTS Performance Profiler</a>. However, it’s do-able. (And with this helper script – hopefully a little simpler?)</p>  <h4>How can I profile a Silverlight Application?</h4>  <p>I would recommend you read the following blog, which explains one way of doing it very well.</p>  <p><a title="http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx" href="http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx">http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx</a></p>  <h4>So… what’s this script for?</h4>  <p>If you read the blog above, or have done this before, then you probably noticed that there was quite a series of commands you had to execute before you could wind up with a performance report. </p>  <p>I threw together a quick little PowerShell script in an attempt to automate smooth out the process.</p>  <h4>Hot do I use it?</h4>  <ol>   <li>Download the script &amp; save it somewhere. <a href="http://github.com/staxmanade/Scripts/blob/master/SilverlightProfiler.ps1"><strong>http://github.com/staxmanade/Scripts/blob/master/SilverlightProfiler.ps1</strong></a> </li>    <li>Open the PowerShell console. cd to the directory your xap/assemblies are stored.      <br />(EX: {myProject}\Bin\Debug\ ) </li>    <li>Execute:      <br />{pathToScript}\SilverlightProfiler.ps1 -urlPath &quot;{myProject}\Bin\Debug\TestPage.html&quot; </li>    <li>When your done profiling press enter to signal that your done.      <p></p> Once complete, it will print the location your profiling report was saved. You can then open it with Visual Studio.</li> </ol>  <h5>Couple of disclaimers.</h5>  <ul>   <li>Some paths are hard-coded to my x86 machine. </li>    <li>I had troubles running the built in visual studio .bat files (from powershell) that are supposed to set the environment variables. So I extracted out what vars I could find to make it work. </li>    <li>I’m not a profiling expert – just hacked this together to get it to work for me.</li> </ul>  <p>I hope this is useful, and if you know of a better way, I’m always interested in hearing your feedback.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tell me what you don&#8217;t like about TFS 2010</title>
		<link>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tell-me-what-you-dont-like-about-tfs-2010</link>
		<comments>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/#comments</comments>
		<pubDate>Sat, 15 May 2010 15:48:18 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Team System]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/</guid>
		<description><![CDATA[I know that a lot of people have had bad experiences with TFS over the years, and so does the TFS development team. The team at Microsoft is very intent on learning what it is that people find irritating, problematic, or difficult, and correcting it. Some major headway was made with the 2010 release of [...]]]></description>
			<content:encoded><![CDATA[<p>I know that a lot of people have had bad experiences with TFS over the years, and so does the TFS development team. The team at Microsoft is very intent on learning what it is that people find irritating, problematic, or difficult, and correcting it. Some major headway was made with the 2010 release of Team Foundation Server to make it easier to setup and administer, and also to improve the usability of several of its key features.</p>  <p>That said, there is still room for improvement and both the team and I understand there are still opportunities to improve. In all seriousness, the team at Microsoft wants to make TFS an approachable, no-brainer install decision for .NET teams, even small ones. This means they want to be able to compete for your attention with the likes of SVN, Git, Jira, Perforce, and anyone else making collaboration tools for developers.</p>  <p>The point of this post is for you to help me know what feedback I can give the TFS product development team as they look ahead to the next release of TFS. I am looking for legitimate feedback I can give the team on how to improve the TFS product.</p>  <p>Please bear in mind that I am interested in your feedback on TFS 2010, as TFS 2008 was improved upon 10 fold in the latest release. Also, I am not necessarily looking for feedback on Visual Studio, just the TFS side of the house. Please realize that the team who makes this product at Microsoft is just as committed and passionate about making great software as you are. They just really need your feedback to make the thing you want. In fact, they want to make a tool that every developer loves to use. Really. So what needs to change to make that the case?</p>  <p>Recall that TFS functionality is broken into the following major areas and I am looking for feedback on the 2010 version.</p>  <ul>   <li>Version Control </li>    <li>Work Item management </li>    <li>Team Foundation Build </li>    <li>SharePoint integration (optional) </li>    <li>Reporting and SSRS Integration (optional) </li> </ul>  <p>Thanks for anything you have. Thank you also for being respectful and not making this a bash-fest.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>Visual Studio: Open in Full XAML View by Default</title>
		<link>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=visual-studio-open-in-full-xaml-view-by-default</link>
		<comments>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 15:49:14 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/</guid>
		<description><![CDATA[So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane [...]]]></description>
			<content:encoded><![CDATA[<p>So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane blows.&#160; So now I have to sit and wait for VS to render my view in the preview pane, and sometimes it can take a while, if it doesn’t just completely crash.&#160; Sometimes I take the extra time to go grab a snack and beverage of my choice.&#160; </p>  <p>So here is a hidden performance increasing jewel you might find useful.&#160; We can set the default open mode to be in full XAML view.</p>  <p>First thing you need to do is in Visual Studio go to your Tools ==&gt; Options ==&gt; Text Editor ==&gt; XAML ==&gt; Miscellaneous.&#160; There you will see an option for “Always open documents in full XAML view”.&#160; Check that box.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/04/image.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="xaml options for opening in full xaml view" border="0" alt="xaml options for opening in full xaml view" src="http://elegantcode.com/wp-content/uploads/2010/04/image_thumb.png" width="244" height="146" /></a> </p>  <p>Now every time you open a XAML file it will open in full XAML view and give you one less thing to gripe about.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Looking Ahead to 2010</title>
		<link>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=looking-ahead-to-2010</link>
		<comments>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 21:02:11 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/02/09/looking-ahead-to-2010/</guid>
		<description><![CDATA[No, this isn't another prognostication post foretelling the woes of the world for the next year. This is a note to everyone who hasn't yet played with the Visual Studio ALM tools and Team Foundation Server 2010. Folks, this product is getting better. That stands to reason. After all, this is basically version 3 of [...]]]></description>
			<content:encoded><![CDATA[<p><img align="left" src="http://elegantcode.com/wp-content/uploads/2010/02/020910_2101_LookingAhea13.png" alt=""/>No, this isn't another prognostication post foretelling the woes of the world for the next year. This is a note to everyone who hasn't yet played with the Visual Studio ALM tools and Team Foundation Server 2010.
</p><p>Folks, this product is getting better. That stands to reason. After all, this is basically version 3 of the product and you know what they say! Version 3 is the one to buy. Most of the kinks are worked out now.
</p><p>Now, I won't pretend for a moment that Team Foundation Server hasn't had its challenges fitting in with agile teams. I think that has come from a history of development by a team that itself was learning and growing just like the rest of us. Now that many of the teams within Microsoft are practicing some form of iterative development with completed cycles of "all the way done", we are starting to see the influence in the tools they are producing. And the effect is not half bad.
</p><p>I have been using Visual Studio 2010 for a few months now, and with the recent release of the RC, I can see:
</p><ol><li>Performance is getting better (XAML).
</li><li>Features are getting more solid (fewer exceptions)
</li><li>The polish of the overall user experience is becoming a great example of an application I am happy to look at all day long.
</li><li>The Team Foundation Server features being added are consistent with what we are learning to be effective as an agile community.
</li></ol><p>So, where's the meat? What are these shiny features of which you speak, Mr. Starr? Well, here is a short sample because I am sitting in an airport listening to the chaos and I can't think of it all. 
</p><p>I should also say that this is a very small list of features that I personally am really excited about. The rest of the world probably has other things they care about. These are mine because I believe they have to potential to really change life on a team for the better.
</p><h2>Layer Diagrams
</h2><p>There is a major focus in this release to add UML support to Visual Studio Ultimate. OK, not a huge fan and I know some people will dog on this feature, but I am all about the Layer Diagrams. These are diagrams that we can create just like the UML diagrams that Visual Studio now supports, but the value of a Layer Diagram is that it has teeth and can bite back. 
</p><p>Here's how it works:
</p><ol><li>Create a Layer Diagram.
</li><li>Draw your favorite design pattern or desired architectural separation model using tools in the Toolbox. In a simple example, this might be to create a model of the MVP pattern. In a large example this model might show the multiple layers in my solution that uses CSLA, Silverlight with MVVM, WCF, and Entity Framework. (Hi, Scott <span style="font-family:Wingdings">J</span> You knew that was for you.)
</li><li>Add some things to it from your solution. Drop things onto the diagram and into the boxes like classes, namespaces, and Visual Studio projects.
</li><li>Now you can generate dependencies between these things and see the existing relationships. Yawn. Cool, but we get this with dependency diagrams, too.
</li><li><div>Validate the model.<br/><br/>Wait for it. . .  Grok it. . .
</div><p><br/>You got it! Yeah, that's right. Validate the LOGICAL model of your application. This is so sweet it comes on a stick. This means that not only can I verify I haven't violated my design with a bad reference or super egregious abstraction hole, but I can make this validation part of the build process and catch it if I accidently violate my own design later. Where I come from, they call that cool.
</p></li></ol><h2>Way Better Work Items
</h2><p>This is non-trivial for teams who live every day of their lives in Team Foundation Server to manage their requirements and work queues. Sure, we might all prefer note cards on the wall, but for many this is simply not possible. And for those folks who use Team Foundation Server to manage their notecards, there are some great new things to make that task easier.
</p><ol><li>Hierarchical relationships between Work Items.
</li><li>Agile planning Workbooks.
</li><li>Seamless Team Project Dashboards.
</li><li>MSF Agile 5.
</li></ol><h2>Gated Check In
</h2><p>This is a feature of Team Foundation Build that will actually build and test your software before a check-in is committed to Source Control. The mechanical effect of this is simple: Code that would break the build is never committed to Source Control. The implications are far larger, though. Think it through for a moment. What would change in your daily life if you flat out were unable to commit code that breaks the build? The short answer is, "Quality goes up." I bit more verbose answer is that I need to be more careful before committing my code.
</p><p>Yes, I know other vendors have had this feature for a while. So what? So, Team Foundation Server shouldn't have it too? It rocks and now we get it in Team Foundation Build.
</p><h2>IntelliTrace
</h2><p>I am not even sure how cool this is yet, only that it is. This feature is also known as Historical Debugging and gives the ability to step back and forth through call stacks and watched variables during a debug run. To be clear, that's <em>Back and Forth through time</em>. So, the first time I hit the breakpoint, here was the status of the code. The second time it was this. And so on. Also, I can inspect all this data on system events (like CLR events) and can therefore tap into my app at a lot of different levels.
</p><p>Now, I know that you don't need debuggers anymore because every line of code we write is Test Driven and that means we don't need debuggers, right? Yeah, sure you never need a debugger. As I said, this is just a wicked tool, but I am not yet sure how wicked. The community will definitely ferret that out over time.
</p><h2>Other Stuff
</h2><p>This only scratches the surface of what's in Visual Studio and Team Foundation Server 2010. There are a lot more things, many of them bigger and higher profile than the things I mentioned. I just happen to be in love with these particular features at the moment. As I get deeper into things, I will let you know what I see.
</p><p>One last thing, I know these tools get a lot of flak in some communities, but I feel comfortable with them. I also understand that many developers out there in the world don't get to choose their tools. Often tools are assigned. What I see is that the 2010 versions of Visual Studio and Team Foundation Server really have raised the bar. I don't feel like teams are still having to compromise on tooling to get everything they need in an integrated environment.
</p><p>Will I still run R#? Well, yeah.
</p><p>
 </p><p>
 </p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Powershell: Load assembly without locking file.</title>
		<link>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-load-assembly-without-locking-file</link>
		<comments>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 05:40:23 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/</guid>
		<description><![CDATA[I have a set of PowerShell build scripts and ran into a case where I needed to load an assembly (to get the assembly’s version) and still (at a later time) work with the assembly file on disk. A typical way to load an assembly within PowerShell is to use the Assembly.LoadFrom(filePath) # Powershell [System.Reflection.Assembly]::LoadFrom($assemblyPath) [...]]]></description>
			<content:encoded><![CDATA[<p>I have a set of PowerShell build scripts and ran into a case where I needed to load an assembly (to get the assembly’s version) and still (at a later time) work with the assembly file on disk.</p>  <p>A typical way to load an assembly within PowerShell is to use the Assembly.LoadFrom(filePath)</p>  <blockquote>   <p># Powershell</p>    <p>[System.Reflection.Assembly]::LoadFrom($assemblyPath)</p> </blockquote>  <p><a href="http://elegantcode.com/wp-content/uploads/2009/12/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2009/12/image_thumb9.png" width="690" height="391" /></a> </p>  <p>Except the problem with this (in my case) was it would <strong>lock the file for the lifespan of the PowerShell console instance</strong>. I didn’t want to have to close and re-open the PowerShell console every time I need to run a build so there had to be a work-around for this.</p>  <p>After searching the web for a solution, I couldn’t find anything that was “easy” and worth the effort to get it to work.</p>  <blockquote>   <p>EX: One solution was to create a new AppDomain, do the necessary work and the close the AppDomain which would release the lock on the file.</p>    <p>I’ve never done this myself, and even thought there is example code out there to get this accomplished, it just seemed over the top for what I was trying to do, and back to my previous criteria it wasn’t “worth the effort to get it to work”</p> </blockquote>  <p>Then I remembered in a previous life I used an overload that took an array of bytes to load the an assembly.</p>  <blockquote>   <p>[System.Reflection.Assembly]::Load($assemblyBytes)</p> </blockquote>  <p>After spiking it in PowerShell with the below test. I was quite happy with the solution, so I thought I’d throw it out there.</p>  <p>Just stream the assembly from disk into a byte array manually, and call assembly load from there.</p>  <p>Here’s my test case which shows that the file is not locked after it was loaded into the PowerShell runtime</p>  <pre>$file = &quot;.\Moq.dll&quot;
$tempFileName = &quot;.\Moq-Renamed.dll&quot;

$fileStream = ([System.IO.FileInfo] (Get-Item $file)).OpenRead();
$assemblyBytes = new-object byte[] $fileStream.Length
$fileStream.Read($assemblyBytes, 0, $fileStream.Length);
$fileStream.Close();

$assemblyLoaded = [System.Reflection.Assembly]::Load($assemblyBytes);

# notice that we can move the file on disk after 
# it's loaded into the powershell runtime
Move-Item $file $tempFileName
Move-Item $tempFileName $file 

# and display the assembly information to show we still have it in memory
echo $assemblyLoaded</pre>

<p>After that test passed, and the main reason I wanted to do this, I wrote the “get-assembly-version” PowerShell function.</p>

<pre><strike>function get-assembly-version() {
    param([string] $file)
    
    # load the assembly bytes quickly - as to not lock the file for too long
    $fileStream = ([System.IO.FileInfo] (Get-Item $file)).OpenRead()
    $assemblyBytes = new-object byte[] $fileStream.Length
    $fileStream.Read($assemblyBytes, 0, $fileStream.Length) | Out-Null #out null this because this function should only return the version &amp; this call was outputting some garbage number
    $fileStream.Close()
    
    # return the version of the assembly
    [System.Reflection.Assembly]::Load($assemblyBytes).GetName().Version;
}

$version = get-assembly-version(&quot;.\Moq.dll&quot;)

echo &quot;Loaded v$($version.Major).$($version.Minor).$($version.Build).$($version.Revision) version of $file&quot;</strike></pre>
Hope this helps someone out there! 

<p></p>

<p>&#160;</p>

<p><strong>UPDATE:</strong></p>

<p><a href="http://achuebrigens.wordpress.com">Martin</a> commented below on a much better solution to the assembly version info problem. Amazing how complicated we can make things if we don’t know the path.</p>

<pre>
function get-assembly-version() {
    param([string] $file)
    
    $version = [System.Reflection.AssemblyName]::GetAssemblyName($file).Version;
    
    #format the version and output it...
    $version
}</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Removing WSUS</title>
		<link>http://elegantcode.com/2009/12/01/removing-wsus/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=removing-wsus</link>
		<comments>http://elegantcode.com/2009/12/01/removing-wsus/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 21:53:49 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[WSUS]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/01/removing-wsus/</guid>
		<description><![CDATA[A while back, the company I work for experimented with setting up a Windows Server Update Service (WSUS).&#160; The idea is that you have one server that goes out and downloads all of the hotfixes, service packs, and so on for your network – then each of your client machines goes directly to the local [...]]]></description>
			<content:encoded><![CDATA[<p>A while back, the company I work for experimented with setting up a Windows Server Update Service (WSUS).&#160; The idea is that you have one server that goes out and downloads all of the hotfixes, service packs, and so on for your network – then each of your client machines goes directly to the local WSUS server to get the weekly dose of patches, configurable by various group policies, and with monitoring to make sure that everything is going smoothly.&#160; At the time we set it up, we were having crushing bandwidth problems – two servers downloading a service pack would pretty much disable the building…</p>  <p>Over time, the bandwidth problems were fixed, and as sometimes happens the WSUS server crumbled to dust.&#160; For the most part nobody noticed – new servers and clients were not configured with the WSUS policy, downloading their hotfixes direct from Microsoft through plentiful bandwidth.&#160; Unfortunately, older server and clients were left in the dark, sending cries out to a WSUS URL that will never respond...&#160; oops</p>  <h4>To Fix (and get your automatic updates to work again):</h4>  <p>Delete the registry key at “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate”.&#160; For fun, restart the “Windows Update” service (not sure if this is necessary).&#160; </p>  <p>I found <a href="http://www.d.umn.edu/itss/security/sus/" target="_blank">this VBS file</a> to be useful in figuring out if a server was still trying to use an old WSUS install, or if the problem was group-policy related.&#160; </p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/01/removing-wsus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PDC Notes</title>
		<link>http://elegantcode.com/2009/11/17/pdc-notes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pdc-notes</link>
		<comments>http://elegantcode.com/2009/11/17/pdc-notes/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 17:23:30 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/17/pdc-notes/</guid>
		<description><![CDATA[I am grateful to INETA to be attending PDC this year. Also, I grateful to Visual Stuart, who is letting me crash in his room. Turns out, I am a cheap skate :) I am sitting in the keynote on Tuesday and thinking about the week. In addition to the Wait? What the… Wordpress moving [...]]]></description>
			<content:encoded><![CDATA[<p>I am grateful to INETA to be attending <a href="http://microsoftpdc.com">PDC</a> this year. Also, I grateful to <a href="http://visualstuart.com">Visual Stuart</a>, who is letting me crash in his room. Turns out, I am a cheap skate :)</p>  <p>I am sitting in the keynote on Tuesday and thinking about the week. In addition to the </p>  <blockquote>   <p><font style="background-color: #ffffff">Wait? What the… Wordpress moving into the Azure cloud? Sweet!</font></p> </blockquote>  <p>volunteer sessions I am doing for INETA, I am hosting a Birds of a Feather session with Mike Vincent. Our BOF is this afternoon and is entitled, “Agile Tales of Triumph, Tribulation, Tools, and Teams”. Drop by and join the discussion to learn </p>  <blockquote>   <p><font style="background-color: #ffffff">Code name Dallas: A uniform way to access data in the cloud and mash it all up.</font></p> </blockquote>  <p>and share what really works.</p>  <p>It has been very cool to meet many of the Pluralsight instructors for the first time. We all live in different parts of the world, and PDC provides that opportunity for us to </p>  <blockquote>   <p>Everyone get your 3D glasses on! Oh, that was very anti-climactic.</p> </blockquote>  <p>all actually shake physical hands rather than electronic ones.</p>  <p>Also, drop by the Pluralsight booth and share your developer stories with me. Here’s the sneak peek as to why: <font style="background-color: #ffffff"><a href="http://www.pluralsight.com/main/pluralcast/default.aspx">Pluralcast</a>. More on that in another post. Suffice </font></p>  <blockquote>   <p><font style="background-color: #ffffff">I think that guy onstage is showing an iPhone and talking about how easy it was to write an app for it. Weird.</font></p> </blockquote>  <p><font style="background-color: #ffffff">to say </font>there will be some changes in the Elegant Code Cast.</p>  <blockquote>   <p>Did he just say, “Create applications for the good of the republic?” Seriously?</p> </blockquote>  <p>Lastly, if you see me running around the halls, please stop me and say, Hello.” It’s very cool to be able to meet people I usually only get to chat with online. If you are looking for a <a href="http://guild3.com">great developer team</a> to build your next big thing, we can talk about that, too!</p>  <blockquote>   <p>Please stop saying “3 screens in the cloud.”</p> </blockquote>  <p>Ray Ozzie final points from the keynote:</p>  <ol>   <li>Bet your next user experience on Windows 7</li>    <li>When thinking of the cloud, bet on Azure.</li>    <li>Take a moment to think about how the world is changing and the potential role of cloud in that world.</li> </ol>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/17/pdc-notes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>StructureMap and SharePoint</title>
		<link>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=structuremap-and-sharepoint</link>
		<comments>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 18:00:22 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[StructureMap]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/</guid>
		<description><![CDATA[I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; </p>  <p>I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user is authorized to use.&#160; The source of this data (names, URLs, etc.) comes from an external-to-SharePoint system, accessed through another C# assembly.&#160; Once the web part gets the data there is some more processing to be done – we need to do more than just blindly display a list of URLs.&#160; Rather than get into details I’m just going to do some handwaving here and say that “if you have access to X, then {stuff happens}, or if you have access to Y then {other stuff happens}.”&#160; You know, business logic, stuff that is good to test.</p>  <p>the first thing I need to do is get business logic out of the WebPart and into something that I can write without having to reset AppPools over and over, not to mention have some unit tests to verify I’m going in the right direction.&#160; So, I created a standard application service class which has a dependency on the external authorization system, via constructor injection.&#160; </p>  <pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> AuthorizedAppsService : IAuthorizedAppsService
{
  <span class="kwrd">private</span> <span class="kwrd">readonly</span> ExternalAuthorizeService authService;

  <span class="kwrd">public</span> AuthorizedAppsService(
    ExternalAuthorizeService authService) 
  {
    <span class="kwrd">this</span>.authService = authService;
  }

  <span class="kwrd">public</span> AuthorizedApplications GetAuthorizedApplications(
                                  <span class="kwrd">string</span> userName)
  {
    var allApps = authService.AuthorizedApplications(userName);
    <span class="rem">// business logic stuff happens here</span>
    <span class="kwrd">return</span> thoseResultsWeJustFiguredOut;
  }
}</pre>

<p>Next, I created a StructureMap Registry class to scan my assemblies, as well as adding in the details of how to create this external authorize service, using the typical method: <style type="text/css">




.csharpcode, .csharpcode pre
{
	font-size: x-small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style></p>

<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyRegistry : Registry
{
  <span class="kwrd">public</span> MyRegistry()
  {
    Scan(scanner =&gt; {
      scanner.TheCallingAssembly();
      scanner.AssemblyContainingType(<span class="kwrd">typeof</span>(MyRegistry));
      scanner.WithDefaultConventions();
      });

    ForRequestedType&lt;ExternalAuthorizeService&gt;()
      .AsSingletons()
      .TheDefault.Is.ConstructedBy(c =&gt; Provider.GetService());

    <span class="rem">// other dependency configuration...</span>
  }
  <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> InitializeForSharepoint()
  {
    ObjectFactory.Initialize(init =&gt; init.AddRegistry&lt;MyRegistry&gt;());
    ObjectFactory.AssertConfigurationIsValid();
  }
}</pre>

<p>And then, what remains is to have SharePoint call my StructureMap initialization when my SharePoint application starts up.&#160; In an MVC or WebForms app, I’d just add code to the appropriate place in Global.asax.cs, but in SharePointLand, this is looked down on.&#160; Instead, the preferred mechanism seems to be to use an HttpModule and a FeatureReceiver to plug the Module into the app’s web.config.</p>

<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyStartupModule : IHttpModule
{
  <span class="kwrd">public</span> <span class="kwrd">void</span> Init(HttpApplication context)
  {
        ConfigureOtherStuff();
        MyRegistry.InitializeForSharepoint();
  }
  <span class="kwrd">public</span> <span class="kwrd">void</span> Dispose() { }
}</pre>

<p>And then the FeatureReceiver to alter the app’s Web.Config looks something like this (note I borrowed most of this code from another sample SharePoint project:</p>

<p>&#160;</p>

<pre class="csharpcode"><span class="rem">//</span>
<span class="rem">// this is borrowing heavily from http://www.codeplex.com/SPAXO</span>
<span class="rem">// </span>
<span class="kwrd">public</span> <span class="kwrd">class</span> StartupFeatureReceiver : SPFeatureReceiver
{
  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureActivated(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    AddWebConfigEntry(webApp);
    UpdateApp(webApp);
  }

  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureDeactivating(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    RemoveWebConfigEntry(webApp);
    UpdateApp(webApp);
  }


  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> AddWebConfigEntry(SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    var existingModifications = 
             <span class="kwrd">new</span> List&lt;SPWebConfigModification&gt;(
                      webApp.WebConfigModifications);
    <span class="kwrd">if</span> (existingModifications.FindIndex(
                    <span class="kwrd">value</span> =&gt;
                        <span class="kwrd">value</span>.Name == mod.Name &amp;&amp;
                        <span class="kwrd">value</span>.Value == mod.Value &amp;&amp;
                        <span class="kwrd">value</span>.Owner == mod.Owner) == -1)
    {
      <span class="rem">// If the modifcation does not already exist </span>
      <span class="rem">// add the entry to the config</span>
      webApp.WebConfigModifications.Add(mod);
    }
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> RemoveWebConfigEntry(
            SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    webApp.WebConfigModifications.Remove(mod);
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> SPWebConfigModification GetModification()
  {
    <span class="kwrd">string</span> asmName = <span class="kwrd">typeof</span>(StartupModule).AssemblyQualifiedName;
    <span class="kwrd">string</span> typeName = <span class="kwrd">typeof</span>(StartupModule).FullName;

    <span class="kwrd">return</span> <span class="kwrd">new</span> SPWebConfigModification
      {
        Path = <span class="str">&quot;configuration/system.web/httpModules&quot;</span>,
        Name = String.Format(CultureInfo.InvariantCulture,
                <span class="str">&quot;add[@name='{0}'][@type='{1}']&quot;</span>,
                typeName, asmName),
        Sequence = 0,
        Owner = asmName,
        Type = SPWebConfigModification.
                    SPWebConfigModificationType.EnsureChildNode,
        Value = String.Format(CultureInfo.InvariantCulture,
                  <span class="str">&quot;&lt;add name='{0}' type='{1}' /&gt;&quot;</span>,
                  typeName, asmName)
      };
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> UpdateApp(SPWebApplication webApp)
  {
    <span class="rem">// Update the Web App and apply the changes </span>
    <span class="rem">// to all servers in the farm</span>
    webApp.Update();
    webApp.Farm.Services
        .GetValue&lt;SPWebService&gt;()
        .ApplyWebConfigModifications();
  }
}</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Integration Test Brought to you by Powershell &amp; NUnit &#8211; with a Little Specification Syntax for Flavoring</title>
		<link>http://elegantcode.com/2009/11/17/pdc-notes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pdc-notes</link>
		<comments>http://elegantcode.com/2009/11/17/pdc-notes/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 17:23:30 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/17/pdc-notes/</guid>
		<description><![CDATA[I am grateful to INETA to be attending PDC this year. Also, I grateful to Visual Stuart, who is letting me crash in his room. Turns out, I am a cheap skate :) I am sitting in the keynote on Tuesday and thinking about the week. In addition to the Wait? What the… Wordpress moving [...]]]></description>
			<content:encoded><![CDATA[<p>I am grateful to INETA to be attending <a href="http://microsoftpdc.com">PDC</a> this year. Also, I grateful to <a href="http://visualstuart.com">Visual Stuart</a>, who is letting me crash in his room. Turns out, I am a cheap skate :)</p>  <p>I am sitting in the keynote on Tuesday and thinking about the week. In addition to the </p>  <blockquote>   <p><font style="background-color: #ffffff">Wait? What the… Wordpress moving into the Azure cloud? Sweet!</font></p> </blockquote>  <p>volunteer sessions I am doing for INETA, I am hosting a Birds of a Feather session with Mike Vincent. Our BOF is this afternoon and is entitled, “Agile Tales of Triumph, Tribulation, Tools, and Teams”. Drop by and join the discussion to learn </p>  <blockquote>   <p><font style="background-color: #ffffff">Code name Dallas: A uniform way to access data in the cloud and mash it all up.</font></p> </blockquote>  <p>and share what really works.</p>  <p>It has been very cool to meet many of the Pluralsight instructors for the first time. We all live in different parts of the world, and PDC provides that opportunity for us to </p>  <blockquote>   <p>Everyone get your 3D glasses on! Oh, that was very anti-climactic.</p> </blockquote>  <p>all actually shake physical hands rather than electronic ones.</p>  <p>Also, drop by the Pluralsight booth and share your developer stories with me. Here’s the sneak peek as to why: <font style="background-color: #ffffff"><a href="http://www.pluralsight.com/main/pluralcast/default.aspx">Pluralcast</a>. More on that in another post. Suffice </font></p>  <blockquote>   <p><font style="background-color: #ffffff">I think that guy onstage is showing an iPhone and talking about how easy it was to write an app for it. Weird.</font></p> </blockquote>  <p><font style="background-color: #ffffff">to say </font>there will be some changes in the Elegant Code Cast.</p>  <blockquote>   <p>Did he just say, “Create applications for the good of the republic?” Seriously?</p> </blockquote>  <p>Lastly, if you see me running around the halls, please stop me and say, Hello.” It’s very cool to be able to meet people I usually only get to chat with online. If you are looking for a <a href="http://guild3.com">great developer team</a> to build your next big thing, we can talk about that, too!</p>  <blockquote>   <p>Please stop saying “3 screens in the cloud.”</p> </blockquote>  <p>Ray Ozzie final points from the keynote:</p>  <ol>   <li>Bet your next user experience on Windows 7</li>    <li>When thinking of the cloud, bet on Azure.</li>    <li>Take a moment to think about how the world is changing and the potential role of cloud in that world.</li> </ol>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/17/pdc-notes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Elegant Code &#187; Microsoft</title>
	<atom:link href="http://elegantcode.com/category/microsoft/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Buy Quinine Without Prescription</title>
		<link>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=awarded-microsoft-community-contributor-award-2012</link>
		<comments>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 23:03:17 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[awards]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/</guid>
		<description><![CDATA[Buy Quinine Without Prescription, Today I received an email informing me that I have been awarded the Microsoft Community Contributor Award.&#160; This is the second time I have been awarded this particular award and it feels just as good this time as it did last time.&#160; I’m not sure how you go about getting nominated [...]]]></description>
			<content:encoded><![CDATA[<p> <p> <b>Buy Quinine Without Prescription</b>, Today I received an email informing me that I have been awarded the Microsoft Community Contributor Award.&#160; This is the second time I have been awarded this particular award and it feels just as good this time as it did last time.&#160; I’m not sure how you go about getting nominated for this award, but apparently I am doing something right.</p>  <p>I would like to thank whoever nominated me for this award and Microsoft for listening to that person.&#160; I would most of all like to thank the community.&#160; Without the support of the community I would probably still be a cop. Oh, <b>australia, uk, us, usa</b>, <b>Discount Quinine</b>, you probably didn’t know that about me.</p>  <p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="Brian Lagunas awarded Microsoft Community Contributor Award" border="0" alt="Brian Lagunas awarded Microsoft Community Contributor Award" src="http://elegantcode.com/wp-content/uploads/2012/03/MCC12_Logo_Horizontal_Full-color.jpg" width="500" height="202" /></p>.  Quinine pharmacy.  Herbal Quinine.  Order Quinine no prescription.  What is Quinine.  Buy Quinine online cod.  Quinine street price.  Quinine use.  Effects of Quinine.  Buy Quinine online no prescription.  Is Quinine safe.  Where can i cheapest Quinine online.  Order Quinine online overnight delivery no prescription.  Where to buy Quinine.  Quinine duration.  Quinine from canada.  Fast shipping Quinine.  After Quinine.  Quinine no prescription.  Quinine cost.  Quinine alternatives.  Quinine samples.  Buy Quinine from canada.  Buy Quinine no prescription.  Ordering Quinine online.  Quinine mg.  Quinine dangers.  Where can i buy Quinine online.  Purchase Quinine online.  Quinine maximum dosage.  Buy Quinine online cod.  Rx free Quinine.  Order Quinine from United States pharmacy.  Buy generic Quinine.  No prescription Quinine online.  Quinine australia, uk, us, usa.  Quinine overnight.  Buy Quinine without a prescription.  Quinine online cod.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4728'>Ventolin For Sale</a>. <a href='http://elegantcode.com/?p=4184'>Synthroid For Sale</a>. <a href='http://elegantcode.com/?p=4384'>Buy Ultram Without Prescription</a>. <a href='http://elegantcode.com/?p=4373'>Topamax For Sale</a>. <a href='http://elegantcode.com/?p=5156'>Amoxicillin For Sale</a>. <a href='http://elegantcode.com/?p=4384'>Order Ultram online overnight delivery no prescription</a>. <a href='http://elegantcode.com/?p=4683'>Inderal schedule</a>. <a href='http://elegantcode.com/?p=4822'>About Hydrochlorothiazide</a>. <a href='http://elegantcode.com/?p=4728'>Ventolin australia, uk, us, usa</a>. <a href='http://elegantcode.com/?p=4694'>Human Growth Hormone interactions</a>.<br />
<b>Trackbacks from:</b> <a href='http://social-blend.com/?p=1163'>Buy Quinine Without Prescription</a>. <a href='http://www.quarterlives.com/?p=710'>Buy Quinine Without Prescription</a>. <a href='http://4realz.net/?p=1873'>Buy Quinine Without Prescription</a>. <a href='http://www.macneilbmx.com/blog/?p=6577'>Buy Quinine Without Prescription</a>. <a href='http://www.greatgreengoods.com/?p=2921'>Buy Quinine Without Prescription</a>. <a href='http://blog.farmland.org/?p=1913'>Online buy Quinine without a prescription</a>. <a href='http://reversemortgagedaily.com/?p=14688'>Is Quinine addictive</a>. <a href='http://linuxologist.com/?p=1495'>Quinine over the counter</a>. <a href='http://home.officesnapshots.com/?p=235'>Order Quinine from United States pharmacy</a>. <a href='http://evanrapoport.com/?p=720'>Generic Quinine</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Silverlight Profiling PowerShell helper.</title>
		<link>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=silverlight-profiling-powershell-helper</link>
		<comments>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/#comments</comments>
		<pubDate>Sat, 15 May 2010 16:47:22 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/</guid>
		<description><![CDATA[I was playing around with some Silverlight profiling the other night to see if I could find any obvious issues with my open source project StatLight and wound up writing a little script in PowerShell I hoped someone might find helpful. But I didn’t know you could profile a Silverlight app. I didn’t until I [...]]]></description>
			<content:encoded><![CDATA[<p>I was playing around with some Silverlight profiling the other night to see if I could find any obvious issues with my open source project <a href="http://statlight.net" target="_blank">StatLight</a> and wound up writing a little script in PowerShell I hoped someone might find helpful.</p>  <h4>But I didn’t know you could profile a Silverlight app.</h4>  <p>I didn’t until I started doing some digging online. Now, the Silverlight profiling story (at least from what I’ve seen/tried) is not near the easy of say <a href="http://www.red-gate.com/products/ants_performance_profiler/index.htm">Redgate ANTS Performance Profiler</a>. However, it’s do-able. (And with this helper script – hopefully a little simpler?)</p>  <h4>How can I profile a Silverlight Application?</h4>  <p>I would recommend you read the following blog, which explains one way of doing it very well.</p>  <p><a title="http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx" href="http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx">http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx</a></p>  <h4>So… what’s this script for?</h4>  <p>If you read the blog above, or have done this before, then you probably noticed that there was quite a series of commands you had to execute before you could wind up with a performance report. </p>  <p>I threw together a quick little PowerShell script in an attempt to automate smooth out the process.</p>  <h4>Hot do I use it?</h4>  <ol>   <li>Download the script &amp; save it somewhere. <a href="http://github.com/staxmanade/Scripts/blob/master/SilverlightProfiler.ps1"><strong>http://github.com/staxmanade/Scripts/blob/master/SilverlightProfiler.ps1</strong></a> </li>    <li>Open the PowerShell console. cd to the directory your xap/assemblies are stored.      <br />(EX: {myProject}\Bin\Debug\ ) </li>    <li>Execute:      <br />{pathToScript}\SilverlightProfiler.ps1 -urlPath &quot;{myProject}\Bin\Debug\TestPage.html&quot; </li>    <li>When your done profiling press enter to signal that your done.      <p></p> Once complete, it will print the location your profiling report was saved. You can then open it with Visual Studio.</li> </ol>  <h5>Couple of disclaimers.</h5>  <ul>   <li>Some paths are hard-coded to my x86 machine. </li>    <li>I had troubles running the built in visual studio .bat files (from powershell) that are supposed to set the environment variables. So I extracted out what vars I could find to make it work. </li>    <li>I’m not a profiling expert – just hacked this together to get it to work for me.</li> </ul>  <p>I hope this is useful, and if you know of a better way, I’m always interested in hearing your feedback.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tell me what you don&#8217;t like about TFS 2010</title>
		<link>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tell-me-what-you-dont-like-about-tfs-2010</link>
		<comments>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/#comments</comments>
		<pubDate>Sat, 15 May 2010 15:48:18 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Team System]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/</guid>
		<description><![CDATA[I know that a lot of people have had bad experiences with TFS over the years, and so does the TFS development team. The team at Microsoft is very intent on learning what it is that people find irritating, problematic, or difficult, and correcting it. Some major headway was made with the 2010 release of [...]]]></description>
			<content:encoded><![CDATA[<p>I know that a lot of people have had bad experiences with TFS over the years, and so does the TFS development team. The team at Microsoft is very intent on learning what it is that people find irritating, problematic, or difficult, and correcting it. Some major headway was made with the 2010 release of Team Foundation Server to make it easier to setup and administer, and also to improve the usability of several of its key features.</p>  <p>That said, there is still room for improvement and both the team and I understand there are still opportunities to improve. In all seriousness, the team at Microsoft wants to make TFS an approachable, no-brainer install decision for .NET teams, even small ones. This means they want to be able to compete for your attention with the likes of SVN, Git, Jira, Perforce, and anyone else making collaboration tools for developers.</p>  <p>The point of this post is for you to help me know what feedback I can give the TFS product development team as they look ahead to the next release of TFS. I am looking for legitimate feedback I can give the team on how to improve the TFS product.</p>  <p>Please bear in mind that I am interested in your feedback on TFS 2010, as TFS 2008 was improved upon 10 fold in the latest release. Also, I am not necessarily looking for feedback on Visual Studio, just the TFS side of the house. Please realize that the team who makes this product at Microsoft is just as committed and passionate about making great software as you are. They just really need your feedback to make the thing you want. In fact, they want to make a tool that every developer loves to use. Really. So what needs to change to make that the case?</p>  <p>Recall that TFS functionality is broken into the following major areas and I am looking for feedback on the 2010 version.</p>  <ul>   <li>Version Control </li>    <li>Work Item management </li>    <li>Team Foundation Build </li>    <li>SharePoint integration (optional) </li>    <li>Reporting and SSRS Integration (optional) </li> </ul>  <p>Thanks for anything you have. Thank you also for being respectful and not making this a bash-fest.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>Visual Studio: Open in Full XAML View by Default</title>
		<link>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=visual-studio-open-in-full-xaml-view-by-default</link>
		<comments>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 15:49:14 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/</guid>
		<description><![CDATA[So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane [...]]]></description>
			<content:encoded><![CDATA[<p>So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane blows.&#160; So now I have to sit and wait for VS to render my view in the preview pane, and sometimes it can take a while, if it doesn’t just completely crash.&#160; Sometimes I take the extra time to go grab a snack and beverage of my choice.&#160; </p>  <p>So here is a hidden performance increasing jewel you might find useful.&#160; We can set the default open mode to be in full XAML view.</p>  <p>First thing you need to do is in Visual Studio go to your Tools ==&gt; Options ==&gt; Text Editor ==&gt; XAML ==&gt; Miscellaneous.&#160; There you will see an option for “Always open documents in full XAML view”.&#160; Check that box.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/04/image.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="xaml options for opening in full xaml view" border="0" alt="xaml options for opening in full xaml view" src="http://elegantcode.com/wp-content/uploads/2010/04/image_thumb.png" width="244" height="146" /></a> </p>  <p>Now every time you open a XAML file it will open in full XAML view and give you one less thing to gripe about.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Looking Ahead to 2010</title>
		<link>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=looking-ahead-to-2010</link>
		<comments>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 21:02:11 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/02/09/looking-ahead-to-2010/</guid>
		<description><![CDATA[No, this isn't another prognostication post foretelling the woes of the world for the next year. This is a note to everyone who hasn't yet played with the Visual Studio ALM tools and Team Foundation Server 2010. Folks, this product is getting better. That stands to reason. After all, this is basically version 3 of [...]]]></description>
			<content:encoded><![CDATA[<p><img align="left" src="http://elegantcode.com/wp-content/uploads/2010/02/020910_2101_LookingAhea13.png" alt=""/>No, this isn't another prognostication post foretelling the woes of the world for the next year. This is a note to everyone who hasn't yet played with the Visual Studio ALM tools and Team Foundation Server 2010.
</p><p>Folks, this product is getting better. That stands to reason. After all, this is basically version 3 of the product and you know what they say! Version 3 is the one to buy. Most of the kinks are worked out now.
</p><p>Now, I won't pretend for a moment that Team Foundation Server hasn't had its challenges fitting in with agile teams. I think that has come from a history of development by a team that itself was learning and growing just like the rest of us. Now that many of the teams within Microsoft are practicing some form of iterative development with completed cycles of "all the way done", we are starting to see the influence in the tools they are producing. And the effect is not half bad.
</p><p>I have been using Visual Studio 2010 for a few months now, and with the recent release of the RC, I can see:
</p><ol><li>Performance is getting better (XAML).
</li><li>Features are getting more solid (fewer exceptions)
</li><li>The polish of the overall user experience is becoming a great example of an application I am happy to look at all day long.
</li><li>The Team Foundation Server features being added are consistent with what we are learning to be effective as an agile community.
</li></ol><p>So, where's the meat? What are these shiny features of which you speak, Mr. Starr? Well, here is a short sample because I am sitting in an airport listening to the chaos and I can't think of it all. 
</p><p>I should also say that this is a very small list of features that I personally am really excited about. The rest of the world probably has other things they care about. These are mine because I believe they have to potential to really change life on a team for the better.
</p><h2>Layer Diagrams
</h2><p>There is a major focus in this release to add UML support to Visual Studio Ultimate. OK, not a huge fan and I know some people will dog on this feature, but I am all about the Layer Diagrams. These are diagrams that we can create just like the UML diagrams that Visual Studio now supports, but the value of a Layer Diagram is that it has teeth and can bite back. 
</p><p>Here's how it works:
</p><ol><li>Create a Layer Diagram.
</li><li>Draw your favorite design pattern or desired architectural separation model using tools in the Toolbox. In a simple example, this might be to create a model of the MVP pattern. In a large example this model might show the multiple layers in my solution that uses CSLA, Silverlight with MVVM, WCF, and Entity Framework. (Hi, Scott <span style="font-family:Wingdings">J</span> You knew that was for you.)
</li><li>Add some things to it from your solution. Drop things onto the diagram and into the boxes like classes, namespaces, and Visual Studio projects.
</li><li>Now you can generate dependencies between these things and see the existing relationships. Yawn. Cool, but we get this with dependency diagrams, too.
</li><li><div>Validate the model.<br/><br/>Wait for it. . .  Grok it. . .
</div><p><br/>You got it! Yeah, that's right. Validate the LOGICAL model of your application. This is so sweet it comes on a stick. This means that not only can I verify I haven't violated my design with a bad reference or super egregious abstraction hole, but I can make this validation part of the build process and catch it if I accidently violate my own design later. Where I come from, they call that cool.
</p></li></ol><h2>Way Better Work Items
</h2><p>This is non-trivial for teams who live every day of their lives in Team Foundation Server to manage their requirements and work queues. Sure, we might all prefer note cards on the wall, but for many this is simply not possible. And for those folks who use Team Foundation Server to manage their notecards, there are some great new things to make that task easier.
</p><ol><li>Hierarchical relationships between Work Items.
</li><li>Agile planning Workbooks.
</li><li>Seamless Team Project Dashboards.
</li><li>MSF Agile 5.
</li></ol><h2>Gated Check In
</h2><p>This is a feature of Team Foundation Build that will actually build and test your software before a check-in is committed to Source Control. The mechanical effect of this is simple: Code that would break the build is never committed to Source Control. The implications are far larger, though. Think it through for a moment. What would change in your daily life if you flat out were unable to commit code that breaks the build? The short answer is, "Quality goes up." I bit more verbose answer is that I need to be more careful before committing my code.
</p><p>Yes, I know other vendors have had this feature for a while. So what? So, Team Foundation Server shouldn't have it too? It rocks and now we get it in Team Foundation Build.
</p><h2>IntelliTrace
</h2><p>I am not even sure how cool this is yet, only that it is. This feature is also known as Historical Debugging and gives the ability to step back and forth through call stacks and watched variables during a debug run. To be clear, that's <em>Back and Forth through time</em>. So, the first time I hit the breakpoint, here was the status of the code. The second time it was this. And so on. Also, I can inspect all this data on system events (like CLR events) and can therefore tap into my app at a lot of different levels.
</p><p>Now, I know that you don't need debuggers anymore because every line of code we write is Test Driven and that means we don't need debuggers, right? Yeah, sure you never need a debugger. As I said, this is just a wicked tool, but I am not yet sure how wicked. The community will definitely ferret that out over time.
</p><h2>Other Stuff
</h2><p>This only scratches the surface of what's in Visual Studio and Team Foundation Server 2010. There are a lot more things, many of them bigger and higher profile than the things I mentioned. I just happen to be in love with these particular features at the moment. As I get deeper into things, I will let you know what I see.
</p><p>One last thing, I know these tools get a lot of flak in some communities, but I feel comfortable with them. I also understand that many developers out there in the world don't get to choose their tools. Often tools are assigned. What I see is that the 2010 versions of Visual Studio and Team Foundation Server really have raised the bar. I don't feel like teams are still having to compromise on tooling to get everything they need in an integrated environment.
</p><p>Will I still run R#? Well, yeah.
</p><p>
 </p><p>
 </p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Powershell: Load assembly without locking file.</title>
		<link>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-load-assembly-without-locking-file</link>
		<comments>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 05:40:23 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/</guid>
		<description><![CDATA[I have a set of PowerShell build scripts and ran into a case where I needed to load an assembly (to get the assembly’s version) and still (at a later time) work with the assembly file on disk. A typical way to load an assembly within PowerShell is to use the Assembly.LoadFrom(filePath) # Powershell [System.Reflection.Assembly]::LoadFrom($assemblyPath) [...]]]></description>
			<content:encoded><![CDATA[<p>I have a set of PowerShell build scripts and ran into a case where I needed to load an assembly (to get the assembly’s version) and still (at a later time) work with the assembly file on disk.</p>  <p>A typical way to load an assembly within PowerShell is to use the Assembly.LoadFrom(filePath)</p>  <blockquote>   <p># Powershell</p>    <p>[System.Reflection.Assembly]::LoadFrom($assemblyPath)</p> </blockquote>  <p><a href="http://elegantcode.com/wp-content/uploads/2009/12/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2009/12/image_thumb9.png" width="690" height="391" /></a> </p>  <p>Except the problem with this (in my case) was it would <strong>lock the file for the lifespan of the PowerShell console instance</strong>. I didn’t want to have to close and re-open the PowerShell console every time I need to run a build so there had to be a work-around for this.</p>  <p>After searching the web for a solution, I couldn’t find anything that was “easy” and worth the effort to get it to work.</p>  <blockquote>   <p>EX: One solution was to create a new AppDomain, do the necessary work and the close the AppDomain which would release the lock on the file.</p>    <p>I’ve never done this myself, and even thought there is example code out there to get this accomplished, it just seemed over the top for what I was trying to do, and back to my previous criteria it wasn’t “worth the effort to get it to work”</p> </blockquote>  <p>Then I remembered in a previous life I used an overload that took an array of bytes to load the an assembly.</p>  <blockquote>   <p>[System.Reflection.Assembly]::Load($assemblyBytes)</p> </blockquote>  <p>After spiking it in PowerShell with the below test. I was quite happy with the solution, so I thought I’d throw it out there.</p>  <p>Just stream the assembly from disk into a byte array manually, and call assembly load from there.</p>  <p>Here’s my test case which shows that the file is not locked after it was loaded into the PowerShell runtime</p>  <pre>$file = &quot;.\Moq.dll&quot;
$tempFileName = &quot;.\Moq-Renamed.dll&quot;

$fileStream = ([System.IO.FileInfo] (Get-Item $file)).OpenRead();
$assemblyBytes = new-object byte[] $fileStream.Length
$fileStream.Read($assemblyBytes, 0, $fileStream.Length);
$fileStream.Close();

$assemblyLoaded = [System.Reflection.Assembly]::Load($assemblyBytes);

# notice that we can move the file on disk after 
# it's loaded into the powershell runtime
Move-Item $file $tempFileName
Move-Item $tempFileName $file 

# and display the assembly information to show we still have it in memory
echo $assemblyLoaded</pre>

<p>After that test passed, and the main reason I wanted to do this, I wrote the “get-assembly-version” PowerShell function.</p>

<pre><strike>function get-assembly-version() {
    param([string] $file)
    
    # load the assembly bytes quickly - as to not lock the file for too long
    $fileStream = ([System.IO.FileInfo] (Get-Item $file)).OpenRead()
    $assemblyBytes = new-object byte[] $fileStream.Length
    $fileStream.Read($assemblyBytes, 0, $fileStream.Length) | Out-Null #out null this because this function should only return the version &amp; this call was outputting some garbage number
    $fileStream.Close()
    
    # return the version of the assembly
    [System.Reflection.Assembly]::Load($assemblyBytes).GetName().Version;
}

$version = get-assembly-version(&quot;.\Moq.dll&quot;)

echo &quot;Loaded v$($version.Major).$($version.Minor).$($version.Build).$($version.Revision) version of $file&quot;</strike></pre>
Hope this helps someone out there! 

<p></p>

<p>&#160;</p>

<p><strong>UPDATE:</strong></p>

<p><a href="http://achuebrigens.wordpress.com">Martin</a> commented below on a much better solution to the assembly version info problem. Amazing how complicated we can make things if we don’t know the path.</p>

<pre>
function get-assembly-version() {
    param([string] $file)
    
    $version = [System.Reflection.AssemblyName]::GetAssemblyName($file).Version;
    
    #format the version and output it...
    $version
}</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Removing WSUS</title>
		<link>http://elegantcode.com/2009/12/01/removing-wsus/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=removing-wsus</link>
		<comments>http://elegantcode.com/2009/12/01/removing-wsus/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 21:53:49 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[WSUS]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/01/removing-wsus/</guid>
		<description><![CDATA[A while back, the company I work for experimented with setting up a Windows Server Update Service (WSUS).&#160; The idea is that you have one server that goes out and downloads all of the hotfixes, service packs, and so on for your network – then each of your client machines goes directly to the local [...]]]></description>
			<content:encoded><![CDATA[<p>A while back, the company I work for experimented with setting up a Windows Server Update Service (WSUS).&#160; The idea is that you have one server that goes out and downloads all of the hotfixes, service packs, and so on for your network – then each of your client machines goes directly to the local WSUS server to get the weekly dose of patches, configurable by various group policies, and with monitoring to make sure that everything is going smoothly.&#160; At the time we set it up, we were having crushing bandwidth problems – two servers downloading a service pack would pretty much disable the building…</p>  <p>Over time, the bandwidth problems were fixed, and as sometimes happens the WSUS server crumbled to dust.&#160; For the most part nobody noticed – new servers and clients were not configured with the WSUS policy, downloading their hotfixes direct from Microsoft through plentiful bandwidth.&#160; Unfortunately, older server and clients were left in the dark, sending cries out to a WSUS URL that will never respond...&#160; oops</p>  <h4>To Fix (and get your automatic updates to work again):</h4>  <p>Delete the registry key at “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate”.&#160; For fun, restart the “Windows Update” service (not sure if this is necessary).&#160; </p>  <p>I found <a href="http://www.d.umn.edu/itss/security/sus/" target="_blank">this VBS file</a> to be useful in figuring out if a server was still trying to use an old WSUS install, or if the problem was group-policy related.&#160; </p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/01/removing-wsus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PDC Notes</title>
		<link>http://elegantcode.com/2009/11/17/pdc-notes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pdc-notes</link>
		<comments>http://elegantcode.com/2009/11/17/pdc-notes/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 17:23:30 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/17/pdc-notes/</guid>
		<description><![CDATA[I am grateful to INETA to be attending PDC this year. Also, I grateful to Visual Stuart, who is letting me crash in his room. Turns out, I am a cheap skate :) I am sitting in the keynote on Tuesday and thinking about the week. In addition to the Wait? What the… Wordpress moving [...]]]></description>
			<content:encoded><![CDATA[<p>I am grateful to INETA to be attending <a href="http://microsoftpdc.com">PDC</a> this year. Also, I grateful to <a href="http://visualstuart.com">Visual Stuart</a>, who is letting me crash in his room. Turns out, I am a cheap skate :)</p>  <p>I am sitting in the keynote on Tuesday and thinking about the week. In addition to the </p>  <blockquote>   <p><font style="background-color: #ffffff">Wait? What the… Wordpress moving into the Azure cloud? Sweet!</font></p> </blockquote>  <p>volunteer sessions I am doing for INETA, I am hosting a Birds of a Feather session with Mike Vincent. Our BOF is this afternoon and is entitled, “Agile Tales of Triumph, Tribulation, Tools, and Teams”. Drop by and join the discussion to learn </p>  <blockquote>   <p><font style="background-color: #ffffff">Code name Dallas: A uniform way to access data in the cloud and mash it all up.</font></p> </blockquote>  <p>and share what really works.</p>  <p>It has been very cool to meet many of the Pluralsight instructors for the first time. We all live in different parts of the world, and PDC provides that opportunity for us to </p>  <blockquote>   <p>Everyone get your 3D glasses on! Oh, that was very anti-climactic.</p> </blockquote>  <p>all actually shake physical hands rather than electronic ones.</p>  <p>Also, drop by the Pluralsight booth and share your developer stories with me. Here’s the sneak peek as to why: <font style="background-color: #ffffff"><a href="http://www.pluralsight.com/main/pluralcast/default.aspx">Pluralcast</a>. More on that in another post. Suffice </font></p>  <blockquote>   <p><font style="background-color: #ffffff">I think that guy onstage is showing an iPhone and talking about how easy it was to write an app for it. Weird.</font></p> </blockquote>  <p><font style="background-color: #ffffff">to say </font>there will be some changes in the Elegant Code Cast.</p>  <blockquote>   <p>Did he just say, “Create applications for the good of the republic?” Seriously?</p> </blockquote>  <p>Lastly, if you see me running around the halls, please stop me and say, Hello.” It’s very cool to be able to meet people I usually only get to chat with online. If you are looking for a <a href="http://guild3.com">great developer team</a> to build your next big thing, we can talk about that, too!</p>  <blockquote>   <p>Please stop saying “3 screens in the cloud.”</p> </blockquote>  <p>Ray Ozzie final points from the keynote:</p>  <ol>   <li>Bet your next user experience on Windows 7</li>    <li>When thinking of the cloud, bet on Azure.</li>    <li>Take a moment to think about how the world is changing and the potential role of cloud in that world.</li> </ol>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/17/pdc-notes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>StructureMap and SharePoint</title>
		<link>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=structuremap-and-sharepoint</link>
		<comments>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 18:00:22 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[StructureMap]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/</guid>
		<description><![CDATA[I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; </p>  <p>I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user is authorized to use.&#160; The source of this data (names, URLs, etc.) comes from an external-to-SharePoint system, accessed through another C# assembly.&#160; Once the web part gets the data there is some more processing to be done – we need to do more than just blindly display a list of URLs.&#160; Rather than get into details I’m just going to do some handwaving here and say that “if you have access to X, then {stuff happens}, or if you have access to Y then {other stuff happens}.”&#160; You know, business logic, stuff that is good to test.</p>  <p>the first thing I need to do is get business logic out of the WebPart and into something that I can write without having to reset AppPools over and over, not to mention have some unit tests to verify I’m going in the right direction.&#160; So, I created a standard application service class which has a dependency on the external authorization system, via constructor injection.&#160; </p>  <pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> AuthorizedAppsService : IAuthorizedAppsService
{
  <span class="kwrd">private</span> <span class="kwrd">readonly</span> ExternalAuthorizeService authService;

  <span class="kwrd">public</span> AuthorizedAppsService(
    ExternalAuthorizeService authService) 
  {
    <span class="kwrd">this</span>.authService = authService;
  }

  <span class="kwrd">public</span> AuthorizedApplications GetAuthorizedApplications(
                                  <span class="kwrd">string</span> userName)
  {
    var allApps = authService.AuthorizedApplications(userName);
    <span class="rem">// business logic stuff happens here</span>
    <span class="kwrd">return</span> thoseResultsWeJustFiguredOut;
  }
}</pre>

<p>Next, I created a StructureMap Registry class to scan my assemblies, as well as adding in the details of how to create this external authorize service, using the typical method: <style type="text/css">




.csharpcode, .csharpcode pre
{
	font-size: x-small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style></p>

<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyRegistry : Registry
{
  <span class="kwrd">public</span> MyRegistry()
  {
    Scan(scanner =&gt; {
      scanner.TheCallingAssembly();
      scanner.AssemblyContainingType(<span class="kwrd">typeof</span>(MyRegistry));
      scanner.WithDefaultConventions();
      });

    ForRequestedType&lt;ExternalAuthorizeService&gt;()
      .AsSingletons()
      .TheDefault.Is.ConstructedBy(c =&gt; Provider.GetService());

    <span class="rem">// other dependency configuration...</span>
  }
  <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> InitializeForSharepoint()
  {
    ObjectFactory.Initialize(init =&gt; init.AddRegistry&lt;MyRegistry&gt;());
    ObjectFactory.AssertConfigurationIsValid();
  }
}</pre>

<p>And then, what remains is to have SharePoint call my StructureMap initialization when my SharePoint application starts up.&#160; In an MVC or WebForms app, I’d just add code to the appropriate place in Global.asax.cs, but in SharePointLand, this is looked down on.&#160; Instead, the preferred mechanism seems to be to use an HttpModule and a FeatureReceiver to plug the Module into the app’s web.config.</p>

<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyStartupModule : IHttpModule
{
  <span class="kwrd">public</span> <span class="kwrd">void</span> Init(HttpApplication context)
  {
        ConfigureOtherStuff();
        MyRegistry.InitializeForSharepoint();
  }
  <span class="kwrd">public</span> <span class="kwrd">void</span> Dispose() { }
}</pre>

<p>And then the FeatureReceiver to alter the app’s Web.Config looks something like this (note I borrowed most of this code from another sample SharePoint project:</p>

<p>&#160;</p>

<pre class="csharpcode"><span class="rem">//</span>
<span class="rem">// this is borrowing heavily from http://www.codeplex.com/SPAXO</span>
<span class="rem">// </span>
<span class="kwrd">public</span> <span class="kwrd">class</span> StartupFeatureReceiver : SPFeatureReceiver
{
  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureActivated(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    AddWebConfigEntry(webApp);
    UpdateApp(webApp);
  }

  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureDeactivating(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    RemoveWebConfigEntry(webApp);
    UpdateApp(webApp);
  }


  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> AddWebConfigEntry(SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    var existingModifications = 
             <span class="kwrd">new</span> List&lt;SPWebConfigModification&gt;(
                      webApp.WebConfigModifications);
    <span class="kwrd">if</span> (existingModifications.FindIndex(
                    <span class="kwrd">value</span> =&gt;
                        <span class="kwrd">value</span>.Name == mod.Name &amp;&amp;
                        <span class="kwrd">value</span>.Value == mod.Value &amp;&amp;
                        <span class="kwrd">value</span>.Owner == mod.Owner) == -1)
    {
      <span class="rem">// If the modifcation does not already exist </span>
      <span class="rem">// add the entry to the config</span>
      webApp.WebConfigModifications.Add(mod);
    }
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> RemoveWebConfigEntry(
            SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    webApp.WebConfigModifications.Remove(mod);
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> SPWebConfigModification GetModification()
  {
    <span class="kwrd">string</span> asmName = <span class="kwrd">typeof</span>(StartupModule).AssemblyQualifiedName;
    <span class="kwrd">string</span> typeName = <span class="kwrd">typeof</span>(StartupModule).FullName;

    <span class="kwrd">return</span> <span class="kwrd">new</span> SPWebConfigModification
      {
        Path = <span class="str">&quot;configuration/system.web/httpModules&quot;</span>,
        Name = String.Format(CultureInfo.InvariantCulture,
                <span class="str">&quot;add[@name='{0}'][@type='{1}']&quot;</span>,
                typeName, asmName),
        Sequence = 0,
        Owner = asmName,
        Type = SPWebConfigModification.
                    SPWebConfigModificationType.EnsureChildNode,
        Value = String.Format(CultureInfo.InvariantCulture,
                  <span class="str">&quot;&lt;add name='{0}' type='{1}' /&gt;&quot;</span>,
                  typeName, asmName)
      };
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> UpdateApp(SPWebApplication webApp)
  {
    <span class="rem">// Update the Web App and apply the changes </span>
    <span class="rem">// to all servers in the farm</span>
    webApp.Update();
    webApp.Farm.Services
        .GetValue&lt;SPWebService&gt;()
        .ApplyWebConfigModifications();
  }
}</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Integration Test Brought to you by Powershell &amp; NUnit &#8211; with a Little Specification Syntax for Flavoring</title>
		<link>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=structuremap-and-sharepoint</link>
		<comments>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 18:00:22 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[StructureMap]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/</guid>
		<description><![CDATA[I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; </p>  <p>I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user is authorized to use.&#160; The source of this data (names, URLs, etc.) comes from an external-to-SharePoint system, accessed through another C# assembly.&#160; Once the web part gets the data there is some more processing to be done – we need to do more than just blindly display a list of URLs.&#160; Rather than get into details I’m just going to do some handwaving here and say that “if you have access to X, then {stuff happens}, or if you have access to Y then {other stuff happens}.”&#160; You know, business logic, stuff that is good to test.</p>  <p>the first thing I need to do is get business logic out of the WebPart and into something that I can write without having to reset AppPools over and over, not to mention have some unit tests to verify I’m going in the right direction.&#160; So, I created a standard application service class which has a dependency on the external authorization system, via constructor injection.&#160; </p>  <pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> AuthorizedAppsService : IAuthorizedAppsService
{
  <span class="kwrd">private</span> <span class="kwrd">readonly</span> ExternalAuthorizeService authService;

  <span class="kwrd">public</span> AuthorizedAppsService(
    ExternalAuthorizeService authService) 
  {
    <span class="kwrd">this</span>.authService = authService;
  }

  <span class="kwrd">public</span> AuthorizedApplications GetAuthorizedApplications(
                                  <span class="kwrd">string</span> userName)
  {
    var allApps = authService.AuthorizedApplications(userName);
    <span class="rem">// business logic stuff happens here</span>
    <span class="kwrd">return</span> thoseResultsWeJustFiguredOut;
  }
}</pre>

<p>Next, I created a StructureMap Registry class to scan my assemblies, as well as adding in the details of how to create this external authorize service, using the typical method: <style type="text/css">




.csharpcode, .csharpcode pre
{
	font-size: x-small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style></p>

<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyRegistry : Registry
{
  <span class="kwrd">public</span> MyRegistry()
  {
    Scan(scanner =&gt; {
      scanner.TheCallingAssembly();
      scanner.AssemblyContainingType(<span class="kwrd">typeof</span>(MyRegistry));
      scanner.WithDefaultConventions();
      });

    ForRequestedType&lt;ExternalAuthorizeService&gt;()
      .AsSingletons()
      .TheDefault.Is.ConstructedBy(c =&gt; Provider.GetService());

    <span class="rem">// other dependency configuration...</span>
  }
  <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> InitializeForSharepoint()
  {
    ObjectFactory.Initialize(init =&gt; init.AddRegistry&lt;MyRegistry&gt;());
    ObjectFactory.AssertConfigurationIsValid();
  }
}</pre>

<p>And then, what remains is to have SharePoint call my StructureMap initialization when my SharePoint application starts up.&#160; In an MVC or WebForms app, I’d just add code to the appropriate place in Global.asax.cs, but in SharePointLand, this is looked down on.&#160; Instead, the preferred mechanism seems to be to use an HttpModule and a FeatureReceiver to plug the Module into the app’s web.config.</p>

<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyStartupModule : IHttpModule
{
  <span class="kwrd">public</span> <span class="kwrd">void</span> Init(HttpApplication context)
  {
        ConfigureOtherStuff();
        MyRegistry.InitializeForSharepoint();
  }
  <span class="kwrd">public</span> <span class="kwrd">void</span> Dispose() { }
}</pre>

<p>And then the FeatureReceiver to alter the app’s Web.Config looks something like this (note I borrowed most of this code from another sample SharePoint project:</p>

<p>&#160;</p>

<pre class="csharpcode"><span class="rem">//</span>
<span class="rem">// this is borrowing heavily from http://www.codeplex.com/SPAXO</span>
<span class="rem">// </span>
<span class="kwrd">public</span> <span class="kwrd">class</span> StartupFeatureReceiver : SPFeatureReceiver
{
  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureActivated(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    AddWebConfigEntry(webApp);
    UpdateApp(webApp);
  }

  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureDeactivating(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    RemoveWebConfigEntry(webApp);
    UpdateApp(webApp);
  }


  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> AddWebConfigEntry(SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    var existingModifications = 
             <span class="kwrd">new</span> List&lt;SPWebConfigModification&gt;(
                      webApp.WebConfigModifications);
    <span class="kwrd">if</span> (existingModifications.FindIndex(
                    <span class="kwrd">value</span> =&gt;
                        <span class="kwrd">value</span>.Name == mod.Name &amp;&amp;
                        <span class="kwrd">value</span>.Value == mod.Value &amp;&amp;
                        <span class="kwrd">value</span>.Owner == mod.Owner) == -1)
    {
      <span class="rem">// If the modifcation does not already exist </span>
      <span class="rem">// add the entry to the config</span>
      webApp.WebConfigModifications.Add(mod);
    }
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> RemoveWebConfigEntry(
            SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    webApp.WebConfigModifications.Remove(mod);
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> SPWebConfigModification GetModification()
  {
    <span class="kwrd">string</span> asmName = <span class="kwrd">typeof</span>(StartupModule).AssemblyQualifiedName;
    <span class="kwrd">string</span> typeName = <span class="kwrd">typeof</span>(StartupModule).FullName;

    <span class="kwrd">return</span> <span class="kwrd">new</span> SPWebConfigModification
      {
        Path = <span class="str">&quot;configuration/system.web/httpModules&quot;</span>,
        Name = String.Format(CultureInfo.InvariantCulture,
                <span class="str">&quot;add[@name='{0}'][@type='{1}']&quot;</span>,
                typeName, asmName),
        Sequence = 0,
        Owner = asmName,
        Type = SPWebConfigModification.
                    SPWebConfigModificationType.EnsureChildNode,
        Value = String.Format(CultureInfo.InvariantCulture,
                  <span class="str">&quot;&lt;add name='{0}' type='{1}' /&gt;&quot;</span>,
                  typeName, asmName)
      };
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> UpdateApp(SPWebApplication webApp)
  {
    <span class="rem">// Update the Web App and apply the changes </span>
    <span class="rem">// to all servers in the farm</span>
    webApp.Update();
    webApp.Farm.Services
        .GetValue&lt;SPWebService&gt;()
        .ApplyWebConfigModifications();
  }
}</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Elegant Code &#187; Microsoft</title>
	<atom:link href="http://elegantcode.com/category/microsoft/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Buy Quinine Without Prescription</title>
		<link>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=awarded-microsoft-community-contributor-award-2012</link>
		<comments>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 23:03:17 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[awards]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/</guid>
		<description><![CDATA[Buy Quinine Without Prescription, Today I received an email informing me that I have been awarded the Microsoft Community Contributor Award.&#160; This is the second time I have been awarded this particular award and it feels just as good this time as it did last time.&#160; I’m not sure how you go about getting nominated [...]]]></description>
			<content:encoded><![CDATA[<p> <p> <b>Buy Quinine Without Prescription</b>, Today I received an email informing me that I have been awarded the Microsoft Community Contributor Award.&#160; This is the second time I have been awarded this particular award and it feels just as good this time as it did last time.&#160; I’m not sure how you go about getting nominated for this award, but apparently I am doing something right.</p>  <p>I would like to thank whoever nominated me for this award and Microsoft for listening to that person.&#160; I would most of all like to thank the community.&#160; Without the support of the community I would probably still be a cop. Oh, <b>australia, uk, us, usa</b>, <b>Discount Quinine</b>, you probably didn’t know that about me.</p>  <p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="Brian Lagunas awarded Microsoft Community Contributor Award" border="0" alt="Brian Lagunas awarded Microsoft Community Contributor Award" src="http://elegantcode.com/wp-content/uploads/2012/03/MCC12_Logo_Horizontal_Full-color.jpg" width="500" height="202" /></p>.  Quinine pharmacy.  Herbal Quinine.  Order Quinine no prescription.  What is Quinine.  Buy Quinine online cod.  Quinine street price.  Quinine use.  Effects of Quinine.  Buy Quinine online no prescription.  Is Quinine safe.  Where can i cheapest Quinine online.  Order Quinine online overnight delivery no prescription.  Where to buy Quinine.  Quinine duration.  Quinine from canada.  Fast shipping Quinine.  After Quinine.  Quinine no prescription.  Quinine cost.  Quinine alternatives.  Quinine samples.  Buy Quinine from canada.  Buy Quinine no prescription.  Ordering Quinine online.  Quinine mg.  Quinine dangers.  Where can i buy Quinine online.  Purchase Quinine online.  Quinine maximum dosage.  Buy Quinine online cod.  Rx free Quinine.  Order Quinine from United States pharmacy.  Buy generic Quinine.  No prescription Quinine online.  Quinine australia, uk, us, usa.  Quinine overnight.  Buy Quinine without a prescription.  Quinine online cod.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4728'>Ventolin For Sale</a>. <a href='http://elegantcode.com/?p=4184'>Synthroid For Sale</a>. <a href='http://elegantcode.com/?p=4384'>Buy Ultram Without Prescription</a>. <a href='http://elegantcode.com/?p=4373'>Topamax For Sale</a>. <a href='http://elegantcode.com/?p=5156'>Amoxicillin For Sale</a>. <a href='http://elegantcode.com/?p=4384'>Order Ultram online overnight delivery no prescription</a>. <a href='http://elegantcode.com/?p=4683'>Inderal schedule</a>. <a href='http://elegantcode.com/?p=4822'>About Hydrochlorothiazide</a>. <a href='http://elegantcode.com/?p=4728'>Ventolin australia, uk, us, usa</a>. <a href='http://elegantcode.com/?p=4694'>Human Growth Hormone interactions</a>.<br />
<b>Trackbacks from:</b> <a href='http://social-blend.com/?p=1163'>Buy Quinine Without Prescription</a>. <a href='http://www.quarterlives.com/?p=710'>Buy Quinine Without Prescription</a>. <a href='http://4realz.net/?p=1873'>Buy Quinine Without Prescription</a>. <a href='http://www.macneilbmx.com/blog/?p=6577'>Buy Quinine Without Prescription</a>. <a href='http://www.greatgreengoods.com/?p=2921'>Buy Quinine Without Prescription</a>. <a href='http://blog.farmland.org/?p=1913'>Online buy Quinine without a prescription</a>. <a href='http://reversemortgagedaily.com/?p=14688'>Is Quinine addictive</a>. <a href='http://linuxologist.com/?p=1495'>Quinine over the counter</a>. <a href='http://home.officesnapshots.com/?p=235'>Order Quinine from United States pharmacy</a>. <a href='http://evanrapoport.com/?p=720'>Generic Quinine</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2012/03/30/awarded-microsoft-community-contributor-award-2012/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Silverlight Profiling PowerShell helper.</title>
		<link>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=silverlight-profiling-powershell-helper</link>
		<comments>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/#comments</comments>
		<pubDate>Sat, 15 May 2010 16:47:22 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/</guid>
		<description><![CDATA[I was playing around with some Silverlight profiling the other night to see if I could find any obvious issues with my open source project StatLight and wound up writing a little script in PowerShell I hoped someone might find helpful. But I didn’t know you could profile a Silverlight app. I didn’t until I [...]]]></description>
			<content:encoded><![CDATA[<p>I was playing around with some Silverlight profiling the other night to see if I could find any obvious issues with my open source project <a href="http://statlight.net" target="_blank">StatLight</a> and wound up writing a little script in PowerShell I hoped someone might find helpful.</p>  <h4>But I didn’t know you could profile a Silverlight app.</h4>  <p>I didn’t until I started doing some digging online. Now, the Silverlight profiling story (at least from what I’ve seen/tried) is not near the easy of say <a href="http://www.red-gate.com/products/ants_performance_profiler/index.htm">Redgate ANTS Performance Profiler</a>. However, it’s do-able. (And with this helper script – hopefully a little simpler?)</p>  <h4>How can I profile a Silverlight Application?</h4>  <p>I would recommend you read the following blog, which explains one way of doing it very well.</p>  <p><a title="http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx" href="http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx">http://blogs.msdn.com/profiler/archive/2010/04/26/vs2010-silverlight-4-profiling.aspx</a></p>  <h4>So… what’s this script for?</h4>  <p>If you read the blog above, or have done this before, then you probably noticed that there was quite a series of commands you had to execute before you could wind up with a performance report. </p>  <p>I threw together a quick little PowerShell script in an attempt to automate smooth out the process.</p>  <h4>Hot do I use it?</h4>  <ol>   <li>Download the script &amp; save it somewhere. <a href="http://github.com/staxmanade/Scripts/blob/master/SilverlightProfiler.ps1"><strong>http://github.com/staxmanade/Scripts/blob/master/SilverlightProfiler.ps1</strong></a> </li>    <li>Open the PowerShell console. cd to the directory your xap/assemblies are stored.      <br />(EX: {myProject}\Bin\Debug\ ) </li>    <li>Execute:      <br />{pathToScript}\SilverlightProfiler.ps1 -urlPath &quot;{myProject}\Bin\Debug\TestPage.html&quot; </li>    <li>When your done profiling press enter to signal that your done.      <p></p> Once complete, it will print the location your profiling report was saved. You can then open it with Visual Studio.</li> </ol>  <h5>Couple of disclaimers.</h5>  <ul>   <li>Some paths are hard-coded to my x86 machine. </li>    <li>I had troubles running the built in visual studio .bat files (from powershell) that are supposed to set the environment variables. So I extracted out what vars I could find to make it work. </li>    <li>I’m not a profiling expert – just hacked this together to get it to work for me.</li> </ul>  <p>I hope this is useful, and if you know of a better way, I’m always interested in hearing your feedback.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/05/15/silverlight-profiling-powershell-helper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tell me what you don&#8217;t like about TFS 2010</title>
		<link>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tell-me-what-you-dont-like-about-tfs-2010</link>
		<comments>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/#comments</comments>
		<pubDate>Sat, 15 May 2010 15:48:18 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Team System]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/</guid>
		<description><![CDATA[I know that a lot of people have had bad experiences with TFS over the years, and so does the TFS development team. The team at Microsoft is very intent on learning what it is that people find irritating, problematic, or difficult, and correcting it. Some major headway was made with the 2010 release of [...]]]></description>
			<content:encoded><![CDATA[<p>I know that a lot of people have had bad experiences with TFS over the years, and so does the TFS development team. The team at Microsoft is very intent on learning what it is that people find irritating, problematic, or difficult, and correcting it. Some major headway was made with the 2010 release of Team Foundation Server to make it easier to setup and administer, and also to improve the usability of several of its key features.</p>  <p>That said, there is still room for improvement and both the team and I understand there are still opportunities to improve. In all seriousness, the team at Microsoft wants to make TFS an approachable, no-brainer install decision for .NET teams, even small ones. This means they want to be able to compete for your attention with the likes of SVN, Git, Jira, Perforce, and anyone else making collaboration tools for developers.</p>  <p>The point of this post is for you to help me know what feedback I can give the TFS product development team as they look ahead to the next release of TFS. I am looking for legitimate feedback I can give the team on how to improve the TFS product.</p>  <p>Please bear in mind that I am interested in your feedback on TFS 2010, as TFS 2008 was improved upon 10 fold in the latest release. Also, I am not necessarily looking for feedback on Visual Studio, just the TFS side of the house. Please realize that the team who makes this product at Microsoft is just as committed and passionate about making great software as you are. They just really need your feedback to make the thing you want. In fact, they want to make a tool that every developer loves to use. Really. So what needs to change to make that the case?</p>  <p>Recall that TFS functionality is broken into the following major areas and I am looking for feedback on the 2010 version.</p>  <ul>   <li>Version Control </li>    <li>Work Item management </li>    <li>Team Foundation Build </li>    <li>SharePoint integration (optional) </li>    <li>Reporting and SSRS Integration (optional) </li> </ul>  <p>Thanks for anything you have. Thank you also for being respectful and not making this a bash-fest.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/05/15/tell-me-what-you-dont-like-about-tfs-2010/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>Visual Studio: Open in Full XAML View by Default</title>
		<link>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=visual-studio-open-in-full-xaml-view-by-default</link>
		<comments>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 15:49:14 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/</guid>
		<description><![CDATA[So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane [...]]]></description>
			<content:encoded><![CDATA[<p>So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane blows.&#160; So now I have to sit and wait for VS to render my view in the preview pane, and sometimes it can take a while, if it doesn’t just completely crash.&#160; Sometimes I take the extra time to go grab a snack and beverage of my choice.&#160; </p>  <p>So here is a hidden performance increasing jewel you might find useful.&#160; We can set the default open mode to be in full XAML view.</p>  <p>First thing you need to do is in Visual Studio go to your Tools ==&gt; Options ==&gt; Text Editor ==&gt; XAML ==&gt; Miscellaneous.&#160; There you will see an option for “Always open documents in full XAML view”.&#160; Check that box.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/04/image.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="xaml options for opening in full xaml view" border="0" alt="xaml options for opening in full xaml view" src="http://elegantcode.com/wp-content/uploads/2010/04/image_thumb.png" width="244" height="146" /></a> </p>  <p>Now every time you open a XAML file it will open in full XAML view and give you one less thing to gripe about.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Looking Ahead to 2010</title>
		<link>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=looking-ahead-to-2010</link>
		<comments>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 21:02:11 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/02/09/looking-ahead-to-2010/</guid>
		<description><![CDATA[No, this isn't another prognostication post foretelling the woes of the world for the next year. This is a note to everyone who hasn't yet played with the Visual Studio ALM tools and Team Foundation Server 2010. Folks, this product is getting better. That stands to reason. After all, this is basically version 3 of [...]]]></description>
			<content:encoded><![CDATA[<p><img align="left" src="http://elegantcode.com/wp-content/uploads/2010/02/020910_2101_LookingAhea13.png" alt=""/>No, this isn't another prognostication post foretelling the woes of the world for the next year. This is a note to everyone who hasn't yet played with the Visual Studio ALM tools and Team Foundation Server 2010.
</p><p>Folks, this product is getting better. That stands to reason. After all, this is basically version 3 of the product and you know what they say! Version 3 is the one to buy. Most of the kinks are worked out now.
</p><p>Now, I won't pretend for a moment that Team Foundation Server hasn't had its challenges fitting in with agile teams. I think that has come from a history of development by a team that itself was learning and growing just like the rest of us. Now that many of the teams within Microsoft are practicing some form of iterative development with completed cycles of "all the way done", we are starting to see the influence in the tools they are producing. And the effect is not half bad.
</p><p>I have been using Visual Studio 2010 for a few months now, and with the recent release of the RC, I can see:
</p><ol><li>Performance is getting better (XAML).
</li><li>Features are getting more solid (fewer exceptions)
</li><li>The polish of the overall user experience is becoming a great example of an application I am happy to look at all day long.
</li><li>The Team Foundation Server features being added are consistent with what we are learning to be effective as an agile community.
</li></ol><p>So, where's the meat? What are these shiny features of which you speak, Mr. Starr? Well, here is a short sample because I am sitting in an airport listening to the chaos and I can't think of it all. 
</p><p>I should also say that this is a very small list of features that I personally am really excited about. The rest of the world probably has other things they care about. These are mine because I believe they have to potential to really change life on a team for the better.
</p><h2>Layer Diagrams
</h2><p>There is a major focus in this release to add UML support to Visual Studio Ultimate. OK, not a huge fan and I know some people will dog on this feature, but I am all about the Layer Diagrams. These are diagrams that we can create just like the UML diagrams that Visual Studio now supports, but the value of a Layer Diagram is that it has teeth and can bite back. 
</p><p>Here's how it works:
</p><ol><li>Create a Layer Diagram.
</li><li>Draw your favorite design pattern or desired architectural separation model using tools in the Toolbox. In a simple example, this might be to create a model of the MVP pattern. In a large example this model might show the multiple layers in my solution that uses CSLA, Silverlight with MVVM, WCF, and Entity Framework. (Hi, Scott <span style="font-family:Wingdings">J</span> You knew that was for you.)
</li><li>Add some things to it from your solution. Drop things onto the diagram and into the boxes like classes, namespaces, and Visual Studio projects.
</li><li>Now you can generate dependencies between these things and see the existing relationships. Yawn. Cool, but we get this with dependency diagrams, too.
</li><li><div>Validate the model.<br/><br/>Wait for it. . .  Grok it. . .
</div><p><br/>You got it! Yeah, that's right. Validate the LOGICAL model of your application. This is so sweet it comes on a stick. This means that not only can I verify I haven't violated my design with a bad reference or super egregious abstraction hole, but I can make this validation part of the build process and catch it if I accidently violate my own design later. Where I come from, they call that cool.
</p></li></ol><h2>Way Better Work Items
</h2><p>This is non-trivial for teams who live every day of their lives in Team Foundation Server to manage their requirements and work queues. Sure, we might all prefer note cards on the wall, but for many this is simply not possible. And for those folks who use Team Foundation Server to manage their notecards, there are some great new things to make that task easier.
</p><ol><li>Hierarchical relationships between Work Items.
</li><li>Agile planning Workbooks.
</li><li>Seamless Team Project Dashboards.
</li><li>MSF Agile 5.
</li></ol><h2>Gated Check In
</h2><p>This is a feature of Team Foundation Build that will actually build and test your software before a check-in is committed to Source Control. The mechanical effect of this is simple: Code that would break the build is never committed to Source Control. The implications are far larger, though. Think it through for a moment. What would change in your daily life if you flat out were unable to commit code that breaks the build? The short answer is, "Quality goes up." I bit more verbose answer is that I need to be more careful before committing my code.
</p><p>Yes, I know other vendors have had this feature for a while. So what? So, Team Foundation Server shouldn't have it too? It rocks and now we get it in Team Foundation Build.
</p><h2>IntelliTrace
</h2><p>I am not even sure how cool this is yet, only that it is. This feature is also known as Historical Debugging and gives the ability to step back and forth through call stacks and watched variables during a debug run. To be clear, that's <em>Back and Forth through time</em>. So, the first time I hit the breakpoint, here was the status of the code. The second time it was this. And so on. Also, I can inspect all this data on system events (like CLR events) and can therefore tap into my app at a lot of different levels.
</p><p>Now, I know that you don't need debuggers anymore because every line of code we write is Test Driven and that means we don't need debuggers, right? Yeah, sure you never need a debugger. As I said, this is just a wicked tool, but I am not yet sure how wicked. The community will definitely ferret that out over time.
</p><h2>Other Stuff
</h2><p>This only scratches the surface of what's in Visual Studio and Team Foundation Server 2010. There are a lot more things, many of them bigger and higher profile than the things I mentioned. I just happen to be in love with these particular features at the moment. As I get deeper into things, I will let you know what I see.
</p><p>One last thing, I know these tools get a lot of flak in some communities, but I feel comfortable with them. I also understand that many developers out there in the world don't get to choose their tools. Often tools are assigned. What I see is that the 2010 versions of Visual Studio and Team Foundation Server really have raised the bar. I don't feel like teams are still having to compromise on tooling to get everything they need in an integrated environment.
</p><p>Will I still run R#? Well, yeah.
</p><p>
 </p><p>
 </p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/02/09/looking-ahead-to-2010/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Powershell: Load assembly without locking file.</title>
		<link>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-load-assembly-without-locking-file</link>
		<comments>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 05:40:23 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/</guid>
		<description><![CDATA[I have a set of PowerShell build scripts and ran into a case where I needed to load an assembly (to get the assembly’s version) and still (at a later time) work with the assembly file on disk. A typical way to load an assembly within PowerShell is to use the Assembly.LoadFrom(filePath) # Powershell [System.Reflection.Assembly]::LoadFrom($assemblyPath) [...]]]></description>
			<content:encoded><![CDATA[<p>I have a set of PowerShell build scripts and ran into a case where I needed to load an assembly (to get the assembly’s version) and still (at a later time) work with the assembly file on disk.</p>  <p>A typical way to load an assembly within PowerShell is to use the Assembly.LoadFrom(filePath)</p>  <blockquote>   <p># Powershell</p>    <p>[System.Reflection.Assembly]::LoadFrom($assemblyPath)</p> </blockquote>  <p><a href="http://elegantcode.com/wp-content/uploads/2009/12/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2009/12/image_thumb9.png" width="690" height="391" /></a> </p>  <p>Except the problem with this (in my case) was it would <strong>lock the file for the lifespan of the PowerShell console instance</strong>. I didn’t want to have to close and re-open the PowerShell console every time I need to run a build so there had to be a work-around for this.</p>  <p>After searching the web for a solution, I couldn’t find anything that was “easy” and worth the effort to get it to work.</p>  <blockquote>   <p>EX: One solution was to create a new AppDomain, do the necessary work and the close the AppDomain which would release the lock on the file.</p>    <p>I’ve never done this myself, and even thought there is example code out there to get this accomplished, it just seemed over the top for what I was trying to do, and back to my previous criteria it wasn’t “worth the effort to get it to work”</p> </blockquote>  <p>Then I remembered in a previous life I used an overload that took an array of bytes to load the an assembly.</p>  <blockquote>   <p>[System.Reflection.Assembly]::Load($assemblyBytes)</p> </blockquote>  <p>After spiking it in PowerShell with the below test. I was quite happy with the solution, so I thought I’d throw it out there.</p>  <p>Just stream the assembly from disk into a byte array manually, and call assembly load from there.</p>  <p>Here’s my test case which shows that the file is not locked after it was loaded into the PowerShell runtime</p>  <pre>$file = &quot;.\Moq.dll&quot;
$tempFileName = &quot;.\Moq-Renamed.dll&quot;

$fileStream = ([System.IO.FileInfo] (Get-Item $file)).OpenRead();
$assemblyBytes = new-object byte[] $fileStream.Length
$fileStream.Read($assemblyBytes, 0, $fileStream.Length);
$fileStream.Close();

$assemblyLoaded = [System.Reflection.Assembly]::Load($assemblyBytes);

# notice that we can move the file on disk after 
# it's loaded into the powershell runtime
Move-Item $file $tempFileName
Move-Item $tempFileName $file 

# and display the assembly information to show we still have it in memory
echo $assemblyLoaded</pre>

<p>After that test passed, and the main reason I wanted to do this, I wrote the “get-assembly-version” PowerShell function.</p>

<pre><strike>function get-assembly-version() {
    param([string] $file)
    
    # load the assembly bytes quickly - as to not lock the file for too long
    $fileStream = ([System.IO.FileInfo] (Get-Item $file)).OpenRead()
    $assemblyBytes = new-object byte[] $fileStream.Length
    $fileStream.Read($assemblyBytes, 0, $fileStream.Length) | Out-Null #out null this because this function should only return the version &amp; this call was outputting some garbage number
    $fileStream.Close()
    
    # return the version of the assembly
    [System.Reflection.Assembly]::Load($assemblyBytes).GetName().Version;
}

$version = get-assembly-version(&quot;.\Moq.dll&quot;)

echo &quot;Loaded v$($version.Major).$($version.Minor).$($version.Build).$($version.Revision) version of $file&quot;</strike></pre>
Hope this helps someone out there! 

<p></p>

<p>&#160;</p>

<p><strong>UPDATE:</strong></p>

<p><a href="http://achuebrigens.wordpress.com">Martin</a> commented below on a much better solution to the assembly version info problem. Amazing how complicated we can make things if we don’t know the path.</p>

<pre>
function get-assembly-version() {
    param([string] $file)
    
    $version = [System.Reflection.AssemblyName]::GetAssemblyName($file).Version;
    
    #format the version and output it...
    $version
}</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/22/powershell-load-assembly-without-locking-file/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Removing WSUS</title>
		<link>http://elegantcode.com/2009/12/01/removing-wsus/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=removing-wsus</link>
		<comments>http://elegantcode.com/2009/12/01/removing-wsus/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 21:53:49 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[WSUS]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/12/01/removing-wsus/</guid>
		<description><![CDATA[A while back, the company I work for experimented with setting up a Windows Server Update Service (WSUS).&#160; The idea is that you have one server that goes out and downloads all of the hotfixes, service packs, and so on for your network – then each of your client machines goes directly to the local [...]]]></description>
			<content:encoded><![CDATA[<p>A while back, the company I work for experimented with setting up a Windows Server Update Service (WSUS).&#160; The idea is that you have one server that goes out and downloads all of the hotfixes, service packs, and so on for your network – then each of your client machines goes directly to the local WSUS server to get the weekly dose of patches, configurable by various group policies, and with monitoring to make sure that everything is going smoothly.&#160; At the time we set it up, we were having crushing bandwidth problems – two servers downloading a service pack would pretty much disable the building…</p>  <p>Over time, the bandwidth problems were fixed, and as sometimes happens the WSUS server crumbled to dust.&#160; For the most part nobody noticed – new servers and clients were not configured with the WSUS policy, downloading their hotfixes direct from Microsoft through plentiful bandwidth.&#160; Unfortunately, older server and clients were left in the dark, sending cries out to a WSUS URL that will never respond...&#160; oops</p>  <h4>To Fix (and get your automatic updates to work again):</h4>  <p>Delete the registry key at “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate”.&#160; For fun, restart the “Windows Update” service (not sure if this is necessary).&#160; </p>  <p>I found <a href="http://www.d.umn.edu/itss/security/sus/" target="_blank">this VBS file</a> to be useful in figuring out if a server was still trying to use an old WSUS install, or if the problem was group-policy related.&#160; </p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/12/01/removing-wsus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PDC Notes</title>
		<link>http://elegantcode.com/2009/11/17/pdc-notes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pdc-notes</link>
		<comments>http://elegantcode.com/2009/11/17/pdc-notes/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 17:23:30 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/17/pdc-notes/</guid>
		<description><![CDATA[I am grateful to INETA to be attending PDC this year. Also, I grateful to Visual Stuart, who is letting me crash in his room. Turns out, I am a cheap skate :) I am sitting in the keynote on Tuesday and thinking about the week. In addition to the Wait? What the… Wordpress moving [...]]]></description>
			<content:encoded><![CDATA[<p>I am grateful to INETA to be attending <a href="http://microsoftpdc.com">PDC</a> this year. Also, I grateful to <a href="http://visualstuart.com">Visual Stuart</a>, who is letting me crash in his room. Turns out, I am a cheap skate :)</p>  <p>I am sitting in the keynote on Tuesday and thinking about the week. In addition to the </p>  <blockquote>   <p><font style="background-color: #ffffff">Wait? What the… Wordpress moving into the Azure cloud? Sweet!</font></p> </blockquote>  <p>volunteer sessions I am doing for INETA, I am hosting a Birds of a Feather session with Mike Vincent. Our BOF is this afternoon and is entitled, “Agile Tales of Triumph, Tribulation, Tools, and Teams”. Drop by and join the discussion to learn </p>  <blockquote>   <p><font style="background-color: #ffffff">Code name Dallas: A uniform way to access data in the cloud and mash it all up.</font></p> </blockquote>  <p>and share what really works.</p>  <p>It has been very cool to meet many of the Pluralsight instructors for the first time. We all live in different parts of the world, and PDC provides that opportunity for us to </p>  <blockquote>   <p>Everyone get your 3D glasses on! Oh, that was very anti-climactic.</p> </blockquote>  <p>all actually shake physical hands rather than electronic ones.</p>  <p>Also, drop by the Pluralsight booth and share your developer stories with me. Here’s the sneak peek as to why: <font style="background-color: #ffffff"><a href="http://www.pluralsight.com/main/pluralcast/default.aspx">Pluralcast</a>. More on that in another post. Suffice </font></p>  <blockquote>   <p><font style="background-color: #ffffff">I think that guy onstage is showing an iPhone and talking about how easy it was to write an app for it. Weird.</font></p> </blockquote>  <p><font style="background-color: #ffffff">to say </font>there will be some changes in the Elegant Code Cast.</p>  <blockquote>   <p>Did he just say, “Create applications for the good of the republic?” Seriously?</p> </blockquote>  <p>Lastly, if you see me running around the halls, please stop me and say, Hello.” It’s very cool to be able to meet people I usually only get to chat with online. If you are looking for a <a href="http://guild3.com">great developer team</a> to build your next big thing, we can talk about that, too!</p>  <blockquote>   <p>Please stop saying “3 screens in the cloud.”</p> </blockquote>  <p>Ray Ozzie final points from the keynote:</p>  <ol>   <li>Bet your next user experience on Windows 7</li>    <li>When thinking of the cloud, bet on Azure.</li>    <li>Take a moment to think about how the world is changing and the potential role of cloud in that world.</li> </ol>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/17/pdc-notes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>StructureMap and SharePoint</title>
		<link>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=structuremap-and-sharepoint</link>
		<comments>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 18:00:22 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[StructureMap]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/</guid>
		<description><![CDATA[I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve started doing some SharePoint development and have brought some of my favorite tools and practices with me.&#160; Like unit tests.&#160; And IoC.&#160; And that other SOLID stuff.&#160; </p>  <p>I’m writing a very basic WebPart to get started with SharePoint – this web part will display a list of links to other applications that the user is authorized to use.&#160; The source of this data (names, URLs, etc.) comes from an external-to-SharePoint system, accessed through another C# assembly.&#160; Once the web part gets the data there is some more processing to be done – we need to do more than just blindly display a list of URLs.&#160; Rather than get into details I’m just going to do some handwaving here and say that “if you have access to X, then {stuff happens}, or if you have access to Y then {other stuff happens}.”&#160; You know, business logic, stuff that is good to test.</p>  <p>the first thing I need to do is get business logic out of the WebPart and into something that I can write without having to reset AppPools over and over, not to mention have some unit tests to verify I’m going in the right direction.&#160; So, I created a standard application service class which has a dependency on the external authorization system, via constructor injection.&#160; </p>  <pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> AuthorizedAppsService : IAuthorizedAppsService
{
  <span class="kwrd">private</span> <span class="kwrd">readonly</span> ExternalAuthorizeService authService;

  <span class="kwrd">public</span> AuthorizedAppsService(
    ExternalAuthorizeService authService) 
  {
    <span class="kwrd">this</span>.authService = authService;
  }

  <span class="kwrd">public</span> AuthorizedApplications GetAuthorizedApplications(
                                  <span class="kwrd">string</span> userName)
  {
    var allApps = authService.AuthorizedApplications(userName);
    <span class="rem">// business logic stuff happens here</span>
    <span class="kwrd">return</span> thoseResultsWeJustFiguredOut;
  }
}</pre>

<p>Next, I created a StructureMap Registry class to scan my assemblies, as well as adding in the details of how to create this external authorize service, using the typical method: <style type="text/css">




.csharpcode, .csharpcode pre
{
	font-size: x-small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style></p>

<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyRegistry : Registry
{
  <span class="kwrd">public</span> MyRegistry()
  {
    Scan(scanner =&gt; {
      scanner.TheCallingAssembly();
      scanner.AssemblyContainingType(<span class="kwrd">typeof</span>(MyRegistry));
      scanner.WithDefaultConventions();
      });

    ForRequestedType&lt;ExternalAuthorizeService&gt;()
      .AsSingletons()
      .TheDefault.Is.ConstructedBy(c =&gt; Provider.GetService());

    <span class="rem">// other dependency configuration...</span>
  }
  <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> InitializeForSharepoint()
  {
    ObjectFactory.Initialize(init =&gt; init.AddRegistry&lt;MyRegistry&gt;());
    ObjectFactory.AssertConfigurationIsValid();
  }
}</pre>

<p>And then, what remains is to have SharePoint call my StructureMap initialization when my SharePoint application starts up.&#160; In an MVC or WebForms app, I’d just add code to the appropriate place in Global.asax.cs, but in SharePointLand, this is looked down on.&#160; Instead, the preferred mechanism seems to be to use an HttpModule and a FeatureReceiver to plug the Module into the app’s web.config.</p>

<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> MyStartupModule : IHttpModule
{
  <span class="kwrd">public</span> <span class="kwrd">void</span> Init(HttpApplication context)
  {
        ConfigureOtherStuff();
        MyRegistry.InitializeForSharepoint();
  }
  <span class="kwrd">public</span> <span class="kwrd">void</span> Dispose() { }
}</pre>

<p>And then the FeatureReceiver to alter the app’s Web.Config looks something like this (note I borrowed most of this code from another sample SharePoint project:</p>

<p>&#160;</p>

<pre class="csharpcode"><span class="rem">//</span>
<span class="rem">// this is borrowing heavily from http://www.codeplex.com/SPAXO</span>
<span class="rem">// </span>
<span class="kwrd">public</span> <span class="kwrd">class</span> StartupFeatureReceiver : SPFeatureReceiver
{
  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureActivated(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    AddWebConfigEntry(webApp);
    UpdateApp(webApp);
  }

  <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> FeatureDeactivating(
        SPFeatureReceiverProperties properties)
  {
    var webApp = properties.Feature.Parent <span class="kwrd">as</span> SPWebApplication;
    RemoveWebConfigEntry(webApp);
    UpdateApp(webApp);
  }


  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> AddWebConfigEntry(SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    var existingModifications = 
             <span class="kwrd">new</span> List&lt;SPWebConfigModification&gt;(
                      webApp.WebConfigModifications);
    <span class="kwrd">if</span> (existingModifications.FindIndex(
                    <span class="kwrd">value</span> =&gt;
                        <span class="kwrd">value</span>.Name == mod.Name &amp;&amp;
                        <span class="kwrd">value</span>.Value == mod.Value &amp;&amp;
                        <span class="kwrd">value</span>.Owner == mod.Owner) == -1)
    {
      <span class="rem">// If the modifcation does not already exist </span>
      <span class="rem">// add the entry to the config</span>
      webApp.WebConfigModifications.Add(mod);
    }
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> RemoveWebConfigEntry(
            SPWebApplication webApp)
  {
    SPWebConfigModification mod = GetModification();
    webApp.WebConfigModifications.Remove(mod);
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> SPWebConfigModification GetModification()
  {
    <span class="kwrd">string</span> asmName = <span class="kwrd">typeof</span>(StartupModule).AssemblyQualifiedName;
    <span class="kwrd">string</span> typeName = <span class="kwrd">typeof</span>(StartupModule).FullName;

    <span class="kwrd">return</span> <span class="kwrd">new</span> SPWebConfigModification
      {
        Path = <span class="str">&quot;configuration/system.web/httpModules&quot;</span>,
        Name = String.Format(CultureInfo.InvariantCulture,
                <span class="str">&quot;add[@name='{0}'][@type='{1}']&quot;</span>,
                typeName, asmName),
        Sequence = 0,
        Owner = asmName,
        Type = SPWebConfigModification.
                    SPWebConfigModificationType.EnsureChildNode,
        Value = String.Format(CultureInfo.InvariantCulture,
                  <span class="str">&quot;&lt;add name='{0}' type='{1}' /&gt;&quot;</span>,
                  typeName, asmName)
      };
  }

  <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> UpdateApp(SPWebApplication webApp)
  {
    <span class="rem">// Update the Web App and apply the changes </span>
    <span class="rem">// to all servers in the farm</span>
    webApp.Update();
    webApp.Farm.Services
        .GetValue&lt;SPWebService&gt;()
        .ApplyWebConfigModifications();
  }
}</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/11/09/structuremap-and-sharepoint/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Integration Test Brought to you by Powershell &amp; NUnit &#8211; with a Little Specification Syntax for Flavoring</title>
		<link>http://elegantcode.com/2009/10/25/integration-test-brought-to-you-by-powershell-nunit-with-a-little-specification-syntax-for-flavoring/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=integration-test-brought-to-you-by-powershell-nunit-with-a-little-specification-syntax-for-flavoring</link>
		<comments>http://elegantcode.com/2009/10/25/integration-test-brought-to-you-by-powershell-nunit-with-a-little-specification-syntax-for-flavoring/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 05:00:40 +0000</pubDate>
		<dc:creator>Jason Jarrett</dc:creator>
				<category><![CDATA[Esoterica]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/10/25/integration-test-brought-to-you-by-powershell-nunit-with-a-little-specification-syntax-for-flavoring/</guid>
		<description><![CDATA[One of the tools I’ve used the last half of a year and really enjoyed is the C# specification extension methods when writing unit test assertions. If you’re looking for a little more background on the topic, I wrote about Fluent Specification Extensions in a past blog. Recently I wanted to execute a PowerShell script [...]]]></description>
			<content:encoded><![CDATA[One of the tools I’ve used the last half of a year and really enjoyed is the C# specification extension methods when writing unit test assertions. If you’re looking for a little more background on the topic, I wrote about <a href="http://staxmanade.blogspot.com/2009/02/fluent-specification-extensions.html">Fluent Specification Extensions</a> in a past blog.

Recently I wanted to execute a PowerShell script to do some automated <a href="http://en.wikipedia.org/wiki/Functional_testing">functional testing</a>. I wanted to execute an application and apply some assertions on the output of the software(basically running a console app, parse the xml output and assert on values in the output).
<blockquote>FYI: I’m very new to PowerShell, so any suggestions on how I implemented the below are welcome…</blockquote>
I’ve seen a couple examples of writing test assertions in PowerShell out there. One example is <a href="http://www.psunit.org/">PSUnit</a>; however, this seemed a little heavy for my needs and not quite the syntactic sugar I was looking for.

Besides the syntax flavor I was desiring, another thing I wanted to do was leverage the power of NUnit.Framework’s assertion capabilities. I like the error messages generated when strings and other objects fail the assertion.
<h5>Examples of end result ShouldLookLike()…</h5>
$true.ShouldBeTrue()
$false.ShouldBeFalse()
"a".ShouldEqual("a")
"a".ShouldNotEqual("b")
<h5><strong>Step 1</strong>: Figure out how to write a C# style <a href="http://msdn.microsoft.com/en-us/library/bb383977.aspx">extension method</a> in PowerShell.</h5>
<blockquote>I found a great blog post describing how to extend any PowerShell object to add extension methods.

<a href="http://bartdesmet.net/blogs/bart/archive/2007/09/06/extension-methods-in-windows-powershell.aspx">Extension Methods in Windows PowerShell</a></blockquote>
In short, to extend types in PowerShell leveraging the <a href="http://msdn.microsoft.com/en-us/library/ms714419(VS.85).aspx">Extended Type System</a>, you need to define them in an xml file and import the method definitions into the PowerShell runtime instance.

Below is PowerShell XML definition for my NUnit Specification Extensions.
<pre class="brush: xml;">&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;Types&gt;
    &lt;Type&gt;
        &lt;Name&gt;System.Object&lt;/Name&gt;
        &lt;Members&gt;
            &lt;ScriptMethod&gt;
                &lt;Name&gt;ShouldBeFalse&lt;/Name&gt;
                &lt;Script&gt;
                    [NUnit.Framework.Assert]::IsFalse($this)
                &lt;/Script&gt;
            &lt;/ScriptMethod&gt;
            &lt;ScriptMethod&gt;
                &lt;Name&gt;ShouldBeTrue&lt;/Name&gt;
                &lt;Script&gt;
                    [NUnit.Framework.Assert]::IsTrue($this)
                &lt;/Script&gt;
            &lt;/ScriptMethod&gt;
            &lt;ScriptMethod&gt;
                &lt;Name&gt;ShouldEqual&lt;/Name&gt;
                &lt;Script&gt;
                    [NUnit.Framework.Assert]::AreEqual($args[0], $this)
                &lt;/Script&gt;
            &lt;/ScriptMethod&gt;
            &lt;ScriptMethod&gt;
                &lt;Name&gt;ShouldNotEqual&lt;/Name&gt;
                &lt;Script&gt;
                    [NUnit.Framework.Assert]::AreNotEqual($args[0], $this)
                &lt;/Script&gt;
            &lt;/ScriptMethod&gt;
        &lt;/Members&gt;
    &lt;/Type&gt;
&lt;/Types&gt;</pre>
<h4></h4>
Take the above XML and save it to a file…
<blockquote>NOTE: the file HAS to be saved with the extension <strong>.ps1xml</strong>

Ex: NunitSpecificationPowerShellExtensions<strong>.ps1xml</strong></blockquote>
<h4></h4>
<h5>Step 2: Load the extended type definition into the PowerShell runtime.</h5>
Once you’ve saved the XML extended types to a file, you need to load it into the PowerShell runtime by executing the command below.
<blockquote>
Update-TypeData -PrependPath NunitSpecificationPowerShellExtensions.ps1xml</blockquote>
Before executing the above statement…Let’s quickly look at a System.String’s members and properties – just to show you what the extension methods look like when applied inside of the runtime.<a href="http://elegantcode.com/wp-content/uploads/2009/10/image3.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://elegantcode.com/wp-content/uploads/2009/10/image_thumb2.png" border="0" alt="image" width="586" height="479" /></a>

After executing the Update-TypeData command you’ll notice there are a number of “ScriptMethod” MemberTypes added to the object.

<a href="http://elegantcode.com/wp-content/uploads/2009/10/image4.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://elegantcode.com/wp-content/uploads/2009/10/image_thumb3.png" border="0" alt="image" width="600" height="580" /></a>

Now if you try to execute one of those newly added extension methods, you may get the following error…

PS C:\&gt; $testVar.<strong>ShouldEqual</strong>("hello world")

Exception calling "ShouldEqual" with "1" argument(s): "<strong>Unable to find type [NUnit.Framework.Assert]: make sure that the

assembly containing this type is loaded.</strong>"

At line:1 char:21

+ $testVar.ShouldEqual &lt;&lt;&lt;&lt; ("hello world")

+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

+ FullyQualifiedErrorId : ScriptMethodRuntimeException

This is because we need to load the NUnit.Framework assembly into the runtime before we can leverage the extension methods.
<blockquote>[System.Reflection.Assembly]::LoadFrom("C:\Program Files\NUnit 2.5.2\bin\net-2.0\framework\nunit.framework.dll") | Out-Null</blockquote>
Now that the extension methods have been defined and loaded into the runtime, NUnit.Framework is loaded, we can now use the methods on any object that inherits from System.Object (which, as far as I know, is everything in PowerShell).

And now, everything you need in one script (if you have the xml extended type file saved somewhere…)
<pre>#
# Update-TypeData -prependPath C:\Code\NunitSpecificationPowerShellExtensions.ps1xml
#

[System.Reflection.Assembly]::LoadFrom("C:\Program Files\NUnit 2.5.2\bin\net-2.0\framework\nunit.framework.dll") | Out-Null

$true.ShouldBeTrue()

$false.ShouldBeFalse()

"a".ShouldEqual("a")

"a".ShouldNotEqual("b")</pre>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/10/25/integration-test-brought-to-you-by-powershell-nunit-with-a-little-specification-syntax-for-flavoring/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

