<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.rightpoint.com/community/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Viewpoint</title><subtitle type="html" /><id>http://www.rightpoint.com/community/blogs/viewpoint/atom.aspx</id><link rel="alternate" type="text/html" href="http://www.rightpoint.com/community/blogs/viewpoint/default.aspx" /><link rel="self" type="application/atom+xml" href="http://www.rightpoint.com/community/blogs/viewpoint/atom.aspx" /><generator uri="http://communityserver.org" version="4.1.31106.3070">Community Server</generator><updated>2010-06-22T15:20:00Z</updated><entry><title>The SUESS Lifecycle: Stage 3 - SmoothStreaming</title><link rel="alternate" type="text/html" href="/community/blogs/viewpoint/archive/2010/09/04/the-suess-lifecycle-stage-3-smoothstreaming.aspx" /><id>/community/blogs/viewpoint/archive/2010/09/04/the-suess-lifecycle-stage-3-smoothstreaming.aspx</id><published>2010-09-04T18:22:00Z</published><updated>2010-09-04T18:22:00Z</updated><content type="html">&lt;div class="text&amp;rdquo; mce_tmp="&gt;&lt;span class="Underline"&gt;The SUESS Series&lt;/span&gt;&lt;/div&gt;
&lt;div class="text&amp;rdquo; mce_tmp="&gt;&lt;a target="_blank" href="http://www.rightpoint.com/community/blogs/viewpoint/archive/2010/06/13/suess-a-silverlight-uploader-encoder-and-smooth-streamer.aspx" class="Link"&gt;Introduction&lt;/a&gt; &lt;/div&gt;
&lt;div class="text&amp;rdquo; mce_tmp="&gt;&lt;a target="_blank" href="http://www.rightpoint.com/community/blogs/viewpoint/archive/2010/07/17/the-suess-lifecycle-stage-1-upload.aspx" class="Link"&gt;Stage 1 &amp;ndash; Upload&lt;/a&gt; &lt;/div&gt;
&lt;div class="text&amp;rdquo; mce_tmp="&gt;&lt;a target="_blank" href="http://www.rightpoint.com/community/blogs/viewpoint/archive/2010/08/23/the-suess-lifecycle-stage-2-encode.aspx%20" class="Link"&gt;Stage 2 &amp;ndash; Encode&lt;/a&gt; &lt;/div&gt;
&lt;div class="text&amp;rdquo; mce_tmp="&gt;&lt;span class="Bold"&gt;Stage 3 &amp;ndash; SmoothStreaming&lt;/span&gt;&lt;/div&gt;
&lt;p class="Text"&gt;We can now upload media. We can now encode media. Sweet. Now all we need to do is be able to watch it as well! This post covers the final stage of SUESS, which is the SmoothSreaming portion: the actual delivery of content from IIS Media Services to Silverlight. I want to get into a little bit more detail about what&amp;#39;s going on both server side and client side to deliver SmoothStreaming content to our users. &lt;/p&gt;
&lt;p class="Text"&gt;There is already a lot out there that describes the basic concepts of SmoothStreaming, and outlines it with stunningly beautiful Visio diagrams. So instead of anteing up into that game, I&amp;#39;ll deal my own, giving a more practical overview of the process, and discussing some of the roadblocks I encountered along the way. &lt;/p&gt;
&lt;p class="Text"&gt;So in one sentence: SmoothStreaming, part of IIS Media Services (3.0 at this time this was written), defines a media file format that IIS can adaptively stream to Silverlight clients. Microsoft Expression Encoder allows you to define various &amp;quot;streams&amp;quot; for the media file, containing different bitrates, sizes, and resolutions. The &amp;quot;adaptation&amp;quot; means that IIS will detect your bandwidth and serve up the appropriate version of the file. &lt;/p&gt;
&lt;p class="Text"&gt;Most of the work we need to do to finish off SUESS regards configuring IIS on the media server. Here&amp;#39;s all you have to do: &lt;/p&gt;
&lt;p class="Text"&gt;&lt;ol class="Text"&gt;
&lt;li class="Text"&gt;Install IIS Media Services on your server. You can get that &lt;a target="_blank" href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;amp;FamilyID=21c12a04-7e36-4b63-b4ef-eedb6273cf54" class="Link"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li class="Text"&gt;Create a new virtual directory under the Encoder Service&amp;#39;s website (let&amp;#39;s call it &amp;quot;media&amp;quot;) that points to the destination folder that our SUESS Encoder dumps the new sparkly SmoothStreaming files into.&lt;/li&gt;
&lt;li class="Text"&gt;Set both EncoderService (website) and media (virtual directory) to only have Anonymous Authentication enabled. A clientaccesspolicy.xml file in the root of EncoderService handles security for us. &lt;/li&gt;
&lt;li class="Text"&gt;Make sure the application pool identity and the &amp;quot;Physical Path Credentials&amp;quot; of the virtual directory have sufficient I/O permissions to read from this folder. We don&amp;#39;t have to worry about the IIS Double Hop issue here, since Silverlight&amp;#39;s call to EncoderService is anonymous. So even if the media virtual directory is on a different machine, that&amp;#39;s only one bunny hop. For performance reasons, however, I have Encoder dump its files to the same server that is hosting Media Services.&lt;/li&gt;
&lt;/ol&gt;&lt;/p&gt;
&lt;p class="Text"&gt;Let&amp;#39;s see where that gets us. &lt;/p&gt;
&lt;p class="Text"&gt;
&lt;p class="Image"&gt;&lt;img src="http://chrisdomino.com/content/images/The-SUESS-Lifecycle-Stage-3-SmoothStreaming/MediaServices.png" class="Image" alt="" /&gt;&lt;/p&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;On the left, you can see &amp;quot;EncoderService&amp;quot; and its &amp;quot;media&amp;quot; virtual directory. Expression Encoder, by default, creates a folder with the following naming convention &amp;quot;&amp;lt;computer name&amp;gt; &amp;lt;timestamp&amp;gt;&amp;quot; under the destination folder. This is of course directly configurable in the API. On the right, I have the IIS &amp;quot;Content View&amp;quot; of one of these folders. &lt;/p&gt;
&lt;p class="Text"&gt;Here is what SmoothStreaming formatted media looks like in the light of day. The &amp;quot;ISMV&amp;quot; files are the actual streams that Encoder creates. To ensure again file name collusions, I prepend a Guid to the beginning of each. (This was from a beta version of SUESS that didn&amp;#39;t have Encoder create a folder for each media file, which I now like better; the aforementioned &amp;quot;-Guid&amp;quot; is therefore superfluous.) Finally, Encoder affixes an underscore plus the bitrate to the end of each stream file. &lt;/p&gt;
&lt;p class="Text"&gt;Next we have those &amp;quot;ISM&amp;quot; and &amp;quot;ISMC&amp;quot; files hanging around. These are the manifest files that the server uses to define the SmoothStreaming file and tells the requesting clients what to expect. Both are just XML. The &amp;quot;ISMC&amp;quot; one is the &amp;quot;client&amp;quot; manifest file that helps Silverlight dissect the streams into the video and audio components, and exposes the different quality levels available. &lt;/p&gt;
&lt;p class="Text"&gt;The &amp;quot;ISM&amp;quot; file is the &amp;quot;server&amp;quot; manifest that is written in a special dialect of XML called &amp;quot;&lt;a target="_blank" href="http://en.wikipedia.org/wiki/Synchronized_Multimedia_Integration_Language" class="Link"&gt;SMIL&lt;/a&gt;.&amp;quot; This is more of a file manifest that defines the physical locations of all the constituent pieces that make up the SmoothStream. Finally, the thumbnail is (optionally) created here as well, following the same naming convention. You can specify the size and image format (by way of a codec) in the API, and the appropriate image will be generated. &lt;/p&gt;
&lt;p class="Text"&gt;Something that was way more difficult than it should have been was determining the actual URL of the SmoothStreaming media! For whatever reason, the research I did yielded misleading and conflicting results, so let me explicitly show the construction of the URL that Silverlight needs to have fed to its Uri for the SmoothStreamingMediaElement&amp;#39;s SmoothStreamingSource property: &lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Bold"&gt;http(s)://&amp;lt;&amp;quot;EncoderService&amp;quot; web site&amp;gt;/&amp;lt;&amp;quot;media&amp;quot; virtual directory&amp;gt;/&amp;lt;folder(s) - if used&amp;gt;/&amp;lt;file name without extension&amp;gt;.ism/manifest&lt;/span&gt; &lt;/p&gt;
&lt;p class="Text"&gt;And guess what? That&amp;#39;s it. Even though there&amp;#39;s a new section called &amp;quot;Media Services&amp;quot; in the &amp;quot;Features View&amp;quot; of each IIS site, you don&amp;#39;t need to mess with anything there. Encoder gives us so much control over the format of the SmootheStreaming files that we don&amp;#39;t need to tell IIS to do anything else; it just servers the file, and Media Services and Silverlight high-five each other and tag team to show it. &lt;/p&gt;
&lt;p class="Text"&gt;On the client side, Silverlight can play these files by way of the &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/microsoft.web.media.smoothstreaming.smoothstreamingmediaelement(VS.90).aspx" class="Link"&gt;SmoothStreamingMediaElement&lt;/a&gt;. This was one of the points that tripped me up: the standard &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.windows.controls.mediaelement.aspx" class="Link"&gt;MediaElement&lt;/a&gt; doesn&amp;#39;t know what to do with these files. Instead, you have to get your hands on Microsoft.Web.Media.SmoothStreaming.dll, which can be found in &amp;quot;C:\Program Files (x86)\Microsoft SDKs\IIS Smooth Streaming Client\v1.0&amp;quot; after you install IIS Media Services. &lt;/p&gt;
&lt;p class="Text"&gt;Drop this DLL into your Media Player Silverlight project, and you can then use the SmoothStreamingMediaElement the same as a MediaElement. The only major different is that this control has a &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/microsoft.web.media.smoothstreaming.smoothstreamingmediaelement.smoothstreamingsource(VS.90).aspx" class="Link"&gt;SmoothStreamingSource&lt;/a&gt; &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.uri.aspx" class="Link"&gt;Uri&lt;/a&gt; property in addition to the standard &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/microsoft.web.media.smoothstreaming.smoothstreamingmediaelement.source(VS.90).aspx/" class="Link"&gt;Source&lt;/a&gt; property. Just set this to a Uri pointing at your SUESS media server and code up the rest of your player all the same. SmoothStreamingMediaElement also has support for &amp;quot;Live&amp;quot; Encoding, so you can broadcast source from a web cam down to Silverlight clients. &lt;/p&gt;
&lt;p class="Text"&gt;That&amp;#39;s really all there is to discuss in terms of SmoothStreaming. Like I said, most of the magic is within the Encoder itself, as it converts raw media into this format. IIS Media Services just sort of knows what to do with it server side, and Silverlight controls with SmoothStreamingMediaElement players just sort of know what to do with it client side. &lt;/p&gt;
&lt;p class="Text"&gt;It just works. &lt;/p&gt;
&lt;p class="Text"&gt;Well, that closes the book on SUESS! Hopefully, as you&amp;#39;ve trudged through this series with me, there has been some enlightenment not only in terms of creating a Web 2.0 media stack for your clients in general, but also specifically to the new generation of .NET technologies. Silverlight 4, WCF/.Net 4, Microsoft Expression 3.0, and IIS Media Services 3.0 all wrap around the concept of SmoothStreaming and add their own functionality to the paradigm. My goal with SUESS was to bring these separate technologies together in a cohesive, media-centric way. &lt;/p&gt;
&lt;p class="Text"&gt;Have fun! &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.rightpoint.com/community/aggbug.aspx?PostID=2819" width="1" height="1"&gt;</content><author><name>cdomino</name><uri>http://www.rightpoint.com/community/members/cdomino/default.aspx</uri></author><category term="WCF" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/WCF/default.aspx" /><category term="IIS SmoothStreaming" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/IIS+SmoothStreaming/default.aspx" /><category term="Expression Encoder" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/Expression+Encoder/default.aspx" /><category term="Silverlight 4" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/Silverlight+4/default.aspx" /><category term="IIS Media Service 3.0" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/IIS+Media+Service+3.0/default.aspx" /></entry><entry><title>Configuring Custom Providers Using SharePoint 2010 Claims Based Authentication</title><link rel="alternate" type="text/html" href="/community/blogs/viewpoint/archive/2010/09/02/configuring-custom-providers-using-sharepoint-2010-claims-based-authentication.aspx" /><id>/community/blogs/viewpoint/archive/2010/09/02/configuring-custom-providers-using-sharepoint-2010-claims-based-authentication.aspx</id><published>2010-09-02T16:21:00Z</published><updated>2010-09-02T16:21:00Z</updated><content type="html">&lt;p class="Text"&gt;
&lt;div class="SectionHeader"&gt;Introduction&lt;/div&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;For those of you who have been with me since the beginning, you&amp;#39;ll remember the first major accomplishment I made in the SharePoint space: &lt;a target="_blank" href="http://chrisdomino.com/blog/post/The-Hybrid-Provider-Authenticating-Both-AD-And-SQL-Users-In-SharePoint-2007" class="Link"&gt;The Hybrid Provider&lt;/a&gt;. This little puppy is a custom authentication provider for SharePoint 2007 that allows simultaneous authentication, authorization, and profiles for both Active Directory and Forms (SQL) users against the same web application. This made a big splash, as not only was the ASP.NET provider infrastructure new in the 2.0 timeframe, but making it work with SharePoint was a very difficult challenge. &lt;/p&gt;
&lt;p class="Text"&gt;And as we all migrate over to 2010, we explore the familiar paradigm of transitioning our expertise from the old tried-and-true techniques to the new and exciting ones. I am always interested to see functionality that used to require a ton of customization to work the way you wanted it to now magically working out of the box. Would custom authentication be gobbled up by SharePoint 2010, thus rendering the Hybrid Provider retired? &lt;/p&gt;
&lt;p class="Text"&gt;Well the answer is...sort of. There&amp;#39;s this new &amp;quot;Claims&amp;quot; thing, replacing, at least semantically, &amp;quot;Forms&amp;quot; authentication, and bringing with it a new architecture for authentication. Gone are the days of having to extent your web app to another zone if you wanted to implement an out of the box extranet. What happens now is a &amp;quot;pre-login&amp;quot; page that gives you a drop down to select the authentication mechanism (namely, Windows or Forms), and based on that selection, the &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listcontrol.autopostback.aspx" class="Link"&gt;AutoPostBack&lt;/a&gt; on the drop down will either pop up the Windows NTML dialog or redirect you to the login page. &lt;/p&gt;
&lt;p class="Text"&gt;Although it&amp;#39;s cool to see &amp;quot;first class citizen&amp;quot; support for dual authentication, this extra step is still a kludge, and therefore there&amp;#39;s still room for the Hybrid Provider. However, this post isn&amp;#39;t about the Hybrid Provider, mainly since the &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.web.security.membershipprovider.aspx" class="Link"&gt;MembershipProvider&lt;/a&gt; abstract class hasn&amp;#39;t changed in .NET 4.0; the old code will still work in SharePoint 2010. The difference, however, is in the configuration and architecture that a custom authentication has to adhere to in the new environment. Therefore, I instead want to talk about how to get this stuff working in general, weather you&amp;#39;re using the out of the box &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.web.security.sqlmembershipprovider.aspx" class="Link"&gt;SqlMembershipProvider&lt;/a&gt;, the Hybrid Provider, or your own creation. &lt;/p&gt;
&lt;p class="Text"&gt;This gives us two topics to discuss. First, we need to understand the new Claims-based Authentication at a high level, and then dig into the nitty-gritty details of what you need to do to get your provider all wired up. &lt;/p&gt;
&lt;p class="Text"&gt;
&lt;div class="SectionHeader"&gt;SharePoint 2010 Claims Authentication&lt;/div&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;Following the paradigm shift from SSPs to Service Applications, authentication has been &amp;quot;offloaded&amp;quot; to the &amp;quot;Security Token Service Application.&amp;quot; The &amp;quot;STS&amp;quot; (as it&amp;#39;s known) is one of those service applications that has no configurable properties. (When you select it in Central Admin, the &amp;quot;Properties&amp;quot; and other Ribbon options are disabled.) This is, as far as I&amp;#39;m concerned, both good and bad: good because there&amp;#39;s nothing extra there to break; bad because there&amp;#39;s nowhere to go to fix it when it indeed is broken. &lt;/p&gt;
&lt;p class="Text"&gt;Behind these ominous scenes, the STS is just a WCF service, hanging out in &amp;quot;14\WebServices\SecurityToken.&amp;quot; They way this works is that SharePoint routes all authentication through this service. Whenever anyone logs into anything, STS is the mechanism giving users the nod. Now, the web applications are still operating as normal ASP.NET sites; authentication, authorization, forms, etc. (in terms of configuration) don&amp;#39;t change. It&amp;#39;s just that instead of code running the web app to do the work, a service call is made instead. &lt;/p&gt;
&lt;p class="Text"&gt;So architecturally, this is really the only big change. In 2007, each web app (Central Admin included) did its own thing for auth. 2010 has now integrated this into its service application layer, with all web apps plug into. &lt;/p&gt;
&lt;p class="Text"&gt;However there is one caveat that will lead us into the second part of this post which covers implementation. Even though the STS handles authentication, web apps are still on their own to implement all other user-centric functionality. The best example is the PeoplePicker. Despite the PeoplePicker depending on the very same mechanics as the STS&amp;#39; authentication and authorization do, it&amp;#39;s not actually &lt;span class="Italic"&gt;doing&lt;/span&gt; authentication or authorization; it&amp;#39;s simply &lt;span class="Italic"&gt;querying&lt;/span&gt; into these interfaces against our user store (weather it&amp;#39;s AD, SQL, etc.). &lt;/p&gt;
&lt;p class="Text"&gt;What does this mean to us? Basically, when implementing custom authentication or authorization, the STS is what needs to be configured to talk to the ASP.NET MembershipProvider. However, any web app that needs to interact with these users, be it searching within a PeoplePicker, adding users to a group, or granting people Site Collection Administrator permissions in Central Admin, needs to be configured to use the authentication provider as well. &lt;/p&gt;
&lt;p class="Text"&gt;Just &lt;span class="Italic"&gt;not&lt;/span&gt; for authentication. &lt;/p&gt;
&lt;p class="Text"&gt;So in SharePoint 2010 Claims-based Authentication, there are now three places you need to go to configure a custom authentication provider (verses just two in 2007): the web application itself (to allow permission and security functionality to work), Central Admin (to implement the provisioning of Site Collection Administrators and other more global user management tasks), and STS (which, again, is doing the actual authentication). &lt;/p&gt;
&lt;p class="Text"&gt;Before we move on to the implementation, I want to briefly discuss some semantics. As it stands, offloading authentication across the farm to the STS does not constitute &amp;quot;claims&amp;quot; authentication all the way. In claims (with a lower-case &amp;quot;C&amp;quot;) auth, you provide your credentials to a third party &amp;quot;issuer&amp;quot; who authenticates you and gives you (or your session) a token. It is this token that you give to the actual site or application. &lt;/p&gt;
&lt;p class="Text"&gt;So STS is the first &amp;quot;half&amp;quot; of this paradigm. What about the token? That is abstracted to us, and SharePoint wires up its own &amp;quot;claims&amp;quot; provider that does this work for us. We&amp;#39;re using claims auth without having to worry about anything beyond forms auth! &lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Underline"&gt;To summarize:&lt;/span&gt; &lt;/p&gt;
&lt;p class="Text"&gt;&lt;ol class="Text"&gt;
&lt;li class="Text"&gt;Forms authentication is configured for the web app, so it knows to provide a login page to you.&lt;/li&gt;
&lt;li class="Text"&gt;The login page passes your credentials to STS.&lt;/li&gt;
&lt;li class="Text"&gt;STS uses our custom provider to authenticate you and issues back a token.&lt;/li&gt;
&lt;li class="Text"&gt;This token is sent to the web app, which uses the &lt;a target="_blank" href="http://www.rightpointconsulting.com/community/controlpanel/blogs/posteditor.aspx/Microsoft.SharePoint.Administration.Claims.SPClaimsAuthMembershipProvider" class="Link"&gt;SPClaimsAuthMembershipProvider&lt;/a&gt; and &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.claims.spclaimsauthroleprovider.aspx" class="Link"&gt;SPClaimsAuthRoleProvider&lt;/a&gt; to process the token and use it for final authentication and authorization respectively.&lt;/li&gt;
&lt;li class="Text"&gt;The web app then uses the custom provider &lt;span class="Bold"&gt;directly&lt;/span&gt; to power user-centric functionality, such as the PeoplePicker.&lt;/li&gt;
&lt;/ol&gt;&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;div class="SectionHeader"&gt;Implementing a Custom Claims Authentication Provider&lt;/div&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;So what do we have to do? Here&amp;#39;s the good news: not much, from a technical perspective, has actually changed! Like I said in the previous section, the code is identical, so if you&amp;#39;re migrating from 2007, just GAC your DLLs. As far as Central Admin is concerned, configuring the Authentication Provider for your web app basically mirrors what you had to do in SharePoint 2007. In fact, other than having to deal with a third web.config file, you still wire up your custom provider in pretty much the same way. &lt;/p&gt;
&lt;p class="Text"&gt;So the only new task we have is dealing with some of the nuances of what SharePoint 2010 needs. In 2007, once you got one web.config wired, you could copy-and-paste it around. The major difference here is that each web.config file (STS, Central Admin, and each web app) varies slightly in what you have to do. So let&amp;#39;s dive into that. &lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Rant"&gt;&amp;lt;Important Note&amp;gt;&lt;/span&gt; &lt;/p&gt;
&lt;p class="Text"&gt;Take very careful notice of the usage of &amp;lt;clear /&amp;gt; in the following web.config snippits. This is very important, and SharePoint 2010 requires it in certain scenarios. &lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Rant"&gt;&amp;lt;/Important Note&amp;gt;&lt;/span&gt; &lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Underline"&gt;Web.config for Web Applications (In virtual directory)&lt;/span&gt; &lt;/p&gt;
&lt;p class="Text"&gt;
&lt;ul class="Text"&gt;
&lt;li class="Text"&gt;Membership
&lt;ul class="Text"&gt;
&lt;li class="Text"&gt;Clear&lt;/li&gt;
&lt;li class="Text"&gt;Add SPClaimsAuthMembershipProvider&lt;/li&gt;
&lt;li class="Text"&gt;Add Custom Membership Provider&lt;/li&gt;
&lt;li class="Text"&gt;Set SPClaimsAuthMembershipProvider as the default&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class="Text"&gt;Role Manager
&lt;ul class="Text"&gt;
&lt;li class="Text"&gt;Clear&lt;/li&gt;
&lt;li class="Text"&gt;Add SPClaimsAuthRoleProvider&lt;/li&gt;
&lt;li class="Text"&gt;Add Custom Role Provider&lt;/li&gt;
&lt;li class="Text"&gt;Set SPClaimsAuthRoleProvider as the default&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;ul&gt;
&lt;/ul&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;table cellpadding="0" cellspacing="0" class="CodeLayout"&gt;
&lt;tbody&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellTopLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;
&lt;div class="CodeContainer"&gt;
&lt;div class="CodeLayout"&gt;&lt;ol class="Code"&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;membership&lt;/span&gt;&lt;span class="ClassName"&gt; defaultProvider&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;i&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;providers&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;clear&lt;/span&gt; &lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;add&lt;/span&gt;&lt;span class="ClassName"&gt; name&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;i&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; type&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;Microsoft.SharePoint.Administration.Claims.SPClaimsAuthMembershipProvider, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt; &lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;add&lt;/span&gt;&lt;span class="ClassName"&gt; connectionStringName&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;AspNetSqlProvider&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; passwordAttemptWindow&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;10&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; enablePasswordRetrieval&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;false&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; enablePasswordReset&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;true&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; requiresQuestionAndAnswer&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;true&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; applicationName&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;/&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; requiresUniqueEmail&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;false&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; passwordFormat&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;Hashed&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; description&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;Stores and retrieves membership data from the Microsoft SQL Server database&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; name&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;AspNetSqlMembershipProvider&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; type&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&lt;span class="Operator"&gt;&amp;quot; /&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;providers&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;membership&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;roleManager&lt;/span&gt;&lt;span class="ClassName"&gt; defaultProvider&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;c&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; enabled&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;true&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; cacheRolesInCookie&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;false&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; cookieName&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;.ASPROLES&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; cookieTimeout&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;30&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; cookiePath&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;/&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; cookieRequireSSL&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;false&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; cookieSlidingExpiration&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;true&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; cookieProtection&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;All&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;providers&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;clear&lt;/span&gt; &lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;add&lt;/span&gt;&lt;span class="ClassName"&gt; name&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;c&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; type&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;Microsoft.SharePoint.Administration.Claims.SPClaimsAuthRoleProvider, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt; &lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;add&lt;/span&gt;&lt;span class="ClassName"&gt; name&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;AspNetSqlRoleProvider&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; type&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;System.Web.Security.SqlRoleProvider&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; connectionStringName&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;AspNetSqlProvider&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; applicationName&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;/&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt; &lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;providers&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;roleManager&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;connectionStrings&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;add&lt;/span&gt;&lt;span class="ClassName"&gt; name&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;AspNetSqlProvider&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; connectionString&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;Data Source=SHAREPOINT2010;Initial Catalog=TestProvider;Integrated Security=True&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; providerName&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;System.Data.SqlClient&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt; &lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;connectionStrings&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellBottomLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Underline"&gt;Web.config for Central Administration (In virtual directory)&lt;/span&gt; &lt;/p&gt;
&lt;p class="Text"&gt;
&lt;ul class="Text"&gt;
&lt;li class="Text"&gt;Membership
&lt;ul class="Text"&gt;
&lt;li class="Text"&gt;Clear&lt;/li&gt;
&lt;li class="Text"&gt;Add Custom Membership Provider&lt;/li&gt;
&lt;li class="Text"&gt;Set Custom Membership Provider as the default&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class="Text"&gt;&lt;span class="Bold"&gt;(NO Role Manager) &lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;table cellpadding="0" cellspacing="0" class="CodeLayout"&gt;
&lt;tbody&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellTopLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;
&lt;div class="CodeContainer"&gt;
&lt;div class="CodeLayout"&gt;&lt;ol class="Code"&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;membership&lt;/span&gt;&lt;span class="ClassName"&gt; defaultProvider&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;AspNetSqlMembershipProvider&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;providers&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;clear&lt;/span&gt; &lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;add&lt;/span&gt;&lt;span class="ClassName"&gt; connectionStringName&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;AspNetSqlProvider&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; passwordAttemptWindow&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;10&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; enablePasswordRetrieval&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;false&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; enablePasswordReset&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;true&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; requiresQuestionAndAnswer&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;true&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; applicationName&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;/&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; requiresUniqueEmail&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;false&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; passwordFormat&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;Hashed&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; description&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;Stores and retrieves membership data from the Microsoft SQL Server database&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; name&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;AspNetSqlMembershipProvider&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; type&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt; &lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;providers&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;membership&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;connectionStrings&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;add&lt;/span&gt;&lt;span class="ClassName"&gt; name&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;AspNetSqlProvider&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; connectionString&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;Data Source=SHAREPOINT2010;Initial Catalog=TestProvider;Integrated Security=True&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; providerName&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;System.Data.SqlClient&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt; &lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;connectionStrings&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellBottomLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;Why no Role Manager in Central Admin? Well, because it doesn&amp;#39;t work. The behavior I&amp;#39;ve seen is that, when you have a role provider configured in Central Admin, although you can log in to the site, certain links to interior pages challenge you for credentials, which then always fail. Take the role provider out and everything works again. &lt;/p&gt;
&lt;p class="Text"&gt;I don&amp;#39;t have any good technical reasons why this is the case, but the only thing I can think of at all is that the role manager interferes somehow with the Windows auth. In the custom provider scenario, Central Admin is the only web app actually using OOTB authentication, so at least that makes sense given it&amp;#39;s the only web app with no role manager configured. &lt;/p&gt;
&lt;p class="Text"&gt;Either way, this isn&amp;#39;t a big deal, since we are not using a custom provider to log into Central Admin, and all user-centric functionality you&amp;#39;d do there doesn&amp;#39;t really need a role manager. Personally, I only use Central Admin to grant the first SQL user Site Collection Administration permissions, so I can log into the actual web app as that user, and go all my group stuff there. &lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Underline"&gt;Web.config for STS (In 14\WebServices\SecurityToken)&lt;/span&gt; &lt;/p&gt;
&lt;p class="Text"&gt;
&lt;ul class="Text"&gt;
&lt;li class="Text"&gt;Membership
&lt;ul class="Text"&gt;
&lt;li class="Text"&gt;Clear&lt;/li&gt;
&lt;li class="Text"&gt;Add Custom Membership Provider&lt;/li&gt;
&lt;li class="Text"&gt;Set Custom Membership Provider as the default&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class="Text"&gt;Role Manager
&lt;ul class="Text"&gt;
&lt;li class="Text"&gt;Clear&lt;/li&gt;
&lt;li class="Text"&gt;Add Custom Role Provider&lt;/li&gt;
&lt;li class="Text"&gt;Set Custom Role Provider as the default&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;table cellpadding="0" cellspacing="0" class="CodeLayout"&gt;
&lt;tbody&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellTopLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;
&lt;div class="CodeContainer"&gt;
&lt;div class="CodeLayout"&gt;&lt;ol class="Code"&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;membership&lt;/span&gt;&lt;span class="ClassName"&gt; defaultProvider&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;AspNetSqlMembershipProvider&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;providers&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;clear&lt;/span&gt; &lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;add&lt;/span&gt;&lt;span class="ClassName"&gt; connectionStringName&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;AspNetSqlProvider&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; passwordAttemptWindow&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;10&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; enablePasswordRetrieval&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;false&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; enablePasswordReset&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;true&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; requiresQuestionAndAnswer&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;true&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; applicationName&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;/&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; requiresUniqueEmail&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;false&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; passwordFormat&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;Hashed&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; description&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;Stores and retrieves membership data from the Microsoft SQL Server database&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; name&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;AspNetSqlMembershipProvider&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; type&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;YMCAProvider.YMCAMembershipProvider, YMCAProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bf6b2d725b284803&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt; &lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;providers&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;membership&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;roleManager&lt;/span&gt;&lt;span class="ClassName"&gt; defaultProvider&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;c&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; enabled&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;true&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; cacheRolesInCookie&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;false&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; cookieName&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;.ASPROLES&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; cookieTimeout&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;30&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; cookiePath&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;/&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; cookieRequireSSL&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;false&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; cookieSlidingExpiration&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;true&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; cookieProtection&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;All&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;providers&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;clear&lt;/span&gt; &lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;add&lt;/span&gt;&lt;span class="ClassName"&gt; name&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;AspNetSqlRoleProvider&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; type&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;System.Web.Security.SqlRoleProvider&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; connectionStringName&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;AspNetSqlProvider&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; applicationName&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;/&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt; &lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;providers&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;roleManager&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;connectionStrings&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;add&lt;/span&gt;&lt;span class="ClassName"&gt; name&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;AspNetSqlProvider&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; connectionString&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;Data Source=SHAREPOINT2010;Initial Catalog=TestProvider;Integrated Security=True&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; providerName&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;System.Data.SqlClient&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt; &lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;connectionStrings&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellBottomLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;Note that the connection strings are added for reference only; they do not belong in the System.Web section of course. Also, I used the SQL Membership Provider here as an example. You can do whatever is necessary to wire up your own provider. But that&amp;#39;s about it! Hopefully this helps demystify not only one of the most intense configurations involved in a custom SharePoint component, but Claims authentication in general. &lt;/p&gt;
&lt;p class="Text"&gt;Have fun! &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.rightpoint.com/community/aggbug.aspx?PostID=2818" width="1" height="1"&gt;</content><author><name>cdomino</name><uri>http://www.rightpoint.com/community/members/cdomino/default.aspx</uri></author><category term="SharePoint 2010" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/SharePoint+2010/default.aspx" /><category term="Hybrid Provider" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/Hybrid+Provider/default.aspx" /><category term="Claims Based Authentication" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/Claims+Based+Authentication/default.aspx" /></entry><entry><title>The Truth About How Daily SharePoint Alerts Actually Work</title><link rel="alternate" type="text/html" href="/community/blogs/viewpoint/archive/2010/08/26/the-truth-about-how-daily-sharepoint-alerts-actually-work.aspx" /><id>/community/blogs/viewpoint/archive/2010/08/26/the-truth-about-how-daily-sharepoint-alerts-actually-work.aspx</id><published>2010-08-26T16:26:00Z</published><updated>2010-08-26T16:26:00Z</updated><content type="html">&lt;p class="Text"&gt;A document changes. &lt;/p&gt;
&lt;p class="Text"&gt;An Email gets sent. &lt;/p&gt;
&lt;p class="Text"&gt;What could be easier? &lt;/p&gt;
&lt;p class="Text"&gt;Well, off the top of my head: open-heart surgery, underwater basket-weaving, and giraffe tooth-brushing to name a few things. SharePoint alerting architecture is a powerful communications tool that provides a convenient mechanism for users to consume information from around the site. &lt;/p&gt;
&lt;p class="Text"&gt;That is, if you don&amp;#39;t mess with them. &lt;/p&gt;
&lt;p class="Text"&gt;But of course, we are going to mess with them. We want to control the time, frequency, and appearance of the Emails. The default out-of-the-box settings work, but not quite well enough. All that my client wanted to do was simplify (&lt;span class="Italic"&gt;not&lt;/span&gt; go nuts, but &lt;span class="Italic"&gt;simplify &lt;/span&gt;) the standard digest (daily) Email template, and have the notifications shoot out at 9:00 AM. I estimated about a day to do this. &lt;/p&gt;
&lt;p class="Text"&gt;All we had to do was comment out some CAML from the alerttemplates.xml file (located in 12\TEMPLATE\XML) and run an STSADM command, right? Remove the links and columns that they didn&amp;#39;t want in the template, and set the time when alerts go out. RIGHT? &lt;/p&gt;
&lt;p class="Text"&gt;WRONG! &lt;/p&gt;
&lt;p class="Text"&gt;To make a story that is longer than it is interesting shorter and more interesting, we went from OOTB alerts to a custom template to a custom handler using &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.ialertnotifyhandler.aspx" class="Link"&gt;IAlertNotifyHandler&lt;/a&gt; to alerts not working for a month to users getting Email bombs of duplicate alerts. We went through three different solutions, two different Microsoft support representatives, and one scary spelunk into the SharePoint database. However, we came out safe and sound on the other side, with a cathartic clarity around how SharePoint daily alerts &lt;span class="Italic"&gt;actually&lt;/span&gt; work. It wasn&amp;#39;t a perfect outcome; there was quite a bit of drama, but a happy client is a happy client. &lt;/p&gt;
&lt;p class="Text"&gt;What I&amp;#39;m not going to do is take you through all the steps required to either customize an alert template, or wire up a code handler to build the Email from scratch (which is what I opted for, since alerttemplate.xml is 10,211 lines long and besides I really like writing code). Someone already did a good enough job of that &lt;a target="_blank" href="http://blogs.msdn.com/b/sharepointdeveloperdocs/archive/2007/12/07/customizing-alert-notifications-and-alert-templates-in-windows-sharepoint-services-3-0.aspx" class="Link"&gt;here&lt;/a&gt;. &lt;/p&gt;
&lt;p class="Text"&gt;Instead, I want to provide a high level description of how SharePoint 2007 alerting infrastructure is put together. As I dug though the dumpsters of the Internet looking for any clues to this end, I heard a lot of rumors and false positives and frightening tales. I also came across a new golden nuggets, either from dependable sources, my own research, or the words from Microsoft&amp;#39;s mouth itself. So what I&amp;#39;m going to do is simply list out the pieces that work together to make alerts work, having already scrubbed out all the wrong turns I made while traversing down this path. &lt;/p&gt;
&lt;p class="Text"&gt;So here are the truths about daily alerts, in Q &amp;amp; A form... &lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Underline"&gt;Which timer job executes daily alerts?&lt;/span&gt; &lt;/p&gt;
&lt;p class="Text"&gt;The &amp;quot;Immediate Alerts&amp;quot; job.&lt;br /&gt;&lt;br /&gt;&lt;span class="Underline"&gt;Wait isn&amp;#39;t that job that runs the immediate alerts?&lt;/span&gt; &lt;/p&gt;
&lt;p class="Text"&gt;Yes. &lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Underline"&gt;So the one job handles all alert notifications? &lt;/span&gt;&lt;/p&gt;
&lt;p class="Text"&gt;Yes. &lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Underline"&gt;There is no &amp;quot;Daily Alerts&amp;quot; job? &lt;/span&gt;&lt;/p&gt;
&lt;p class="Text"&gt;No. &lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Underline"&gt;Promise? &lt;/span&gt;&lt;/p&gt;
&lt;p class="Text"&gt;Promise. &lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Underline"&gt;Which server physically executes this job?&lt;/span&gt; &lt;/p&gt;
&lt;p class="Text"&gt;Officially: All timer jobs run on all front end servers. So any web front end (or indexer, as I&amp;#39;ve seen) that has the proper assets deployed to it for a particular timer job (DLLs, XML files, etc.) can execute it successfully. Unofficially: not really; even though Central Administration -&amp;gt; Operations -&amp;gt; Timer Job Status &lt;span class="Italic"&gt;reports&lt;/span&gt; that the Immediate Alerts job runs on all servers, only one is actually doing the work. &lt;/p&gt;
&lt;p class="Text"&gt;To determine which one, you have to dive into the database. I know. It&amp;#39;s ugly; it hurts. Shush. Run the following query against the content database for your web application: &lt;/p&gt;
&lt;p class="Text"&gt;
&lt;table cellpadding="0" cellspacing="0" class="CodeLayout"&gt;
&lt;tbody&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellTopLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;
&lt;div class="CodeContainer"&gt;
&lt;div class="CodeLayout"&gt;&lt;ol class="Code"&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;SELECT &lt;/span&gt;&lt;span class="Operator"&gt;*&lt;/span&gt;&lt;span class="Keyword"&gt; FROM &lt;/span&gt;TimerLock&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellBottomLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;What this does is return the one and only row there will ever be from this table. The two columns are a name of a server, and a date. All we really care about is the name of the server: this is the one that&amp;#39;s going to do the notification work. If you want to change it to another server, stop the &amp;quot;Windows SharePoint Services Timer&amp;quot; service on this box, and wait for another server to jump in and acquire this lock. &lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Underline"&gt;When do daily alerts get sent?&lt;/span&gt; &lt;/p&gt;
&lt;p class="Text"&gt;OOTB, alerts are enabled, and the Immediate Alerts job runs every five minutes. What these runs do is ask the question: Are there any alerts that want to be sent out, but haven&amp;#39;t been? All alerts that answer &amp;quot;Yes!&amp;quot; get sent out. &lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Underline"&gt;So how do daily alerts know that they want to be sent?&lt;/span&gt; &lt;/p&gt;
&lt;p class="Text"&gt;Every alert has a time. For daily alerts, this time defaults to one day (or, more accurately, 24 hours) from the instant they are created. If you create an alert OOTB, you can select an hour on the UI, and the alert will be sent 24 hours from that time. In either case, this &amp;quot;Alert Time&amp;quot; is stored as a real, absolute time, not a &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.timespan.aspx" class="Link"&gt;TimeSpan&lt;/a&gt;. &lt;/p&gt;
&lt;p class="Text"&gt;So every time the Immediate Alerts job runs, it checks for alerts whose time is less than the current time. For each one, it fires the Email, and increments this time by another 24 hours. &lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Underline"&gt;What about the job-immediate-alerts property?&lt;/span&gt; &lt;/p&gt;
&lt;p class="Text"&gt;All this does is regulates how often the Immediate Alerts job runs. This has no effect if alerts are disabled (the &amp;quot;alerts-enabled&amp;quot; property is set to false). Remember, these properties are specific to a web application. &lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Underline"&gt;And what about the job-daily-alerts property?&lt;/span&gt; &lt;/p&gt;
&lt;p class="Text"&gt;The main purpose of this property is to confuse the hell out of everyone. This command has been deprecated since SharePoint 2003, but was never removed from the command line. &lt;/p&gt;
&lt;p class="Text"&gt;It has &lt;span class="Bold"&gt;NO&lt;/span&gt; effect. &lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Underline"&gt;On anything?&lt;/span&gt; &lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Bold"&gt;NOTHING.&lt;/span&gt; Don&amp;#39;t ever think about it. Ever. &lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Underline"&gt;So in summary?&lt;/span&gt; &lt;/p&gt;
&lt;p class="Text"&gt;In summary, alerts store the &lt;span class="Italic"&gt;next&lt;/span&gt; time they want to be sent. Every execution of the Immediate Alerts timer job on the server that has acquired the &amp;quot;TimerLock&amp;quot; (for that content database) will send any daily alerts whose time is in the past. Finally, it will increment these times by 24 hours. &lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Underline"&gt;Anything else?&lt;/span&gt; &lt;/p&gt;
&lt;p class="Text"&gt;Now, there&amp;#39;s one other phenomena that I&amp;#39;ve observed with all this alert stuff: duplicates. And just duplications, but DUPLICATES - as many as a half dozen extra Emails per each unique notification. The most bizarre case we saw was when a user had an alert against a document library that saw five changes in one day, and he received five Emails: one with all five changes listed, one with only the first four, and so on, down to one Email advertising just one change. &lt;/p&gt;
&lt;p class="Text"&gt;What was causing the duplication? The prime suspect was of course the customization of the template, which, admittedly, had a bug, and was broken for some time: there were no alerts for weeks. But eventually I fixed it, and proved it by writing to the ULS logs each time the handler was invoked. And indeed, it was called exactly once for each Email the aforementioned user received. So why was one alert sending out so many notifications? &lt;/p&gt;
&lt;p class="Text"&gt;The most bizarre aspect of this problem was how it was solved, because it solved itself. It was as though the SharePoint alerting infrastructure had a cold: it got worse and worse, barfed, and then started to get better and better. Seriously. My user reported that he got fewer and fewer duplicates each day, until it completely worked itself out and only sent out one notification per alert; each Email containing a list of changes that that document library had experienced over those last 24 hours. &lt;/p&gt;
&lt;p class="Text"&gt;Of course this is unsettling; problems that solve themselves usually have the propensity to start themselves back up. I had a hunch, and I don&amp;#39;t blog about hunches. However, I will blog about hunches that Microsoft Premier Support endorses! &lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Rant"&gt;&amp;lt;HUNCH&amp;gt;&lt;/span&gt; &lt;/p&gt;
&lt;p class="Text"&gt;First, a bit of background: there is another database table that people seem to get their hands dirty with when it comes to fixing alerts: EventCache. What from I can tell, this is the backlog of all changes made to all document libraries. We can then think of alerts as sort of queries into this table. Once an alert gobbles up a change, that change is marked as processed and won&amp;#39;t be alerted against again. &lt;/p&gt;
&lt;p class="Text"&gt;Therefore, a daily alert notification is actually the intersection of all unique changes that an alert (which is welded to a document library) &amp;quot;finds.&amp;quot; What happens if those changes in EventCache are never processed? They are dangling there, like icicles, waiting to melt back down to the ground. If alerts are broken, these changes seem to just stack up. &lt;/p&gt;
&lt;p class="Text"&gt;Eventually, when alerts are fixed, that stack will topple. It will be like unclogging a drain. However, that&amp;#39;s not what happened. The Email duplications diminished slowly, as if each alert could only pull changes from &lt;span class="Italic"&gt;one&lt;/span&gt; day at a time. In other words, the alert, when activated by the Immediate Alerts job, doesn&amp;#39;t seem to blindly ask EventCache for &amp;quot;all unprocessed changes for this document library&amp;quot; (as I would assume) but rather for &amp;quot;some 24 hour block of changes.&amp;quot; Maybe it&amp;#39;s that timeframe that gets out of whack, and changes from two different days are processed in the same batch. Or perhaps the logic is flawed, and times aren&amp;#39;t updated properly if the notification system is malfunctioning due to a bug somewhere in the template customization. &lt;/p&gt;
&lt;p class="Text"&gt;It still makes more sense to me that, once repaired, all notifications will be shot out in the next batch. Furthermore, I think it&amp;#39;s counterintuitive that &amp;quot;old&amp;quot; changes should be notified at all. If a user hooks up an alert, they want new information - new content. The apropos availability of old news isn&amp;#39;t new news. &lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Rant"&gt;&amp;lt;/HUNCH&amp;gt;&lt;/span&gt; &lt;/p&gt;
&lt;p class="Text"&gt;Each day as the alerts were &amp;quot;worsening&amp;quot; and then &amp;quot;healing&amp;quot; themselves, my client user forward me all the Emails he got. So did another user, who only had one alert, and only got dups sometimes. The point is that there were no discernable patterns. I poured over the frequencies among alerts, number of Emails, and number of changes in each Email, but came up with nothing. I spent hours digging though verbose ULS logs, only to further validate that my custom handler was called exactly once per whatever it was that SharePoint was detecting as a notification. &lt;/p&gt;
&lt;p class="Text"&gt;When my Microsoft rep backed up the above hunch, I was encouraged, but not satisfied. Unfortunately, this remains a mystery to this day. Microsoft closed the case without any more discussion. My client closed the bug without any more discussion. It&amp;#39;s like everyone but is happy that this one little bug - which was only supposed to take a day to implement - has magically disappeared. &lt;/p&gt;
&lt;p class="Text"&gt;Well it&amp;#39;s time for me to join their ranks, as there is no more time, money, calories, or sanity to invest into the duplicate alert issue. Usually my posts have happy endings, but alerts are emo like that. If anyone out there has any ideas, please don&amp;#39;t hold back. Hopefully I was able to at least help a little bit in terms of cracking open the black box of enigmatic SharePoint 2007 daily alerts. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.rightpoint.com/community/aggbug.aspx?PostID=2817" width="1" height="1"&gt;</content><author><name>cdomino</name><uri>http://www.rightpoint.com/community/members/cdomino/default.aspx</uri></author><category term="SharePoint 2007" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/SharePoint+2007/default.aspx" /><category term="Alerts" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/Alerts/default.aspx" /></entry><entry><title>The SUESS Lifecycle: Stage 2 - Encode</title><link rel="alternate" type="text/html" href="/community/blogs/viewpoint/archive/2010/08/23/the-suess-lifecycle-stage-2-encode.aspx" /><id>/community/blogs/viewpoint/archive/2010/08/23/the-suess-lifecycle-stage-2-encode.aspx</id><published>2010-08-23T21:09:00Z</published><updated>2010-08-23T21:09:00Z</updated><content type="html">&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;span class="Underline"&gt;The SUESS Series&lt;br /&gt;&lt;/span&gt;&lt;a target="_blank" href="http://chrisdomino.com/blog/post/SUESS-A-Silverlight-Uploader-Encoder-and-Smooth-Streamer" class="Link"&gt;Introduction&lt;/a&gt;&amp;nbsp;&lt;br /&gt;&lt;a target="_blank" href="http://chrisdomino.com/blog/post/The-SUESS-Lifecycle-Stage-1-Upload" class="Link"&gt;Stage 1 - Upload&lt;/a&gt;&amp;nbsp;&lt;br /&gt;&lt;span class="Bold"&gt;Stage 2 - Encode&lt;/span&gt;&amp;nbsp;&lt;br /&gt;&lt;a target="_blank" href="http://chrisdomino.com/blog/post/The-SUESS-Lifecycle-Stage-3-SmoothStreaming" class="Link"&gt;Stage 3 - SmoothStreaming&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;div class="SectionHeader"&gt;Introduction&amp;nbsp;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Anatomically speaking, Encoding is the heart of SUESS. (I guess, to stretch out the metaphor, that makes Silverlight the head, SmoothStreaming the eyes and ears, and I guess Uploading the digestive system.) Encoding, implemented via Expression Encoder, is what makes the process of media uploading feasible to end users. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;By &amp;quot;feasible&amp;quot; I really mean &amp;quot;usable&amp;quot; - people want online functionality to be really easy to understand. Usability 101 tells us that the more hoops people have to jump through, the less inclined they will be to use your site, regardless of how pretty the UI is. The hoops here are presented by the fact that Silverlight does not support every media format under the sun. We can&amp;#39;t simply upload a random file and then watch it; Silverlight has to &amp;quot;know&amp;quot; how to play it. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;Do you think if people could only upload Flash media to YouTube it would have been nearly as popular? Of course not. I&amp;#39;m surprised that abilities like uploading media and capturing live web cam feeds are exoteric enough for the general Internet-goer. But encoding a movie or image? Not only is it an extra hoop, but it&amp;#39;s simply too much to expect from a user. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;By automating the encoding process, we can enable people to provide IIS SmoothStreaming media to their website&amp;#39;s audience with just as much effort as it would take to upload an image. SmoothStreaming itself is the other side of the coin: we need to encode &lt;span class="Italic"&gt;anyway&lt;/span&gt; if we want to take advantage of this new media streaming technology! So by putting in all this effort to solve these intrinsic media usability problems (large files, wide arrays of formats, etc.) we are awarded by having the otherwise heavily-guarded SmoothStreaming gate automatically unlocked for us! (See the final post on SUESS for more information about IIS SmoothStreaming; we still need to open the gate, of course!) &lt;/p&gt;
&lt;p class="Text"&gt;Those are the two reasons &lt;span class="Italic"&gt;why&lt;/span&gt; we encode. The next question, which leads us into our architectural discussion, is of course: how? I went with Microsoft Expression Encoder 3.0 (4.0 was still in beta during development). Here are some of the determining factors that lead me to this decision: &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul class="Text"&gt;
&lt;li class="Text"&gt;.NET API that exposes progress events&lt;/li&gt;
&lt;li class="Text"&gt;Much wider file support than native Silverlight&lt;/li&gt;
&lt;li class="Text"&gt;Explicitly supports encoding to the IIS SmoothStreaming format&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;And, I didn&amp;#39;t feel like dealing with the Media Player SDK, buying and kluding a third party control, or reverting back to a &amp;quot;Web 1.0&amp;quot; paradigm of an upload screen that says something like &amp;quot;Thank you for uploading your media. Please try back later to see it when it&amp;#39;s done because we couldn&amp;#39;t figure out a more elegant way to implement our site&amp;#39;s media administration.&amp;quot; &lt;/p&gt;
&lt;p class="Text"&gt;I wanted this to be first class. &lt;/p&gt;
&lt;p class="Text"&gt;Architecture&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Let&amp;#39;s start by first taking a look at the detailed architecture of the Encoder. Back to everyone&amp;#39;s favorite Visio diagram:&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Image"&gt;&lt;img src="http://chrisdomino.com/content/images/The-SUESS-Lifecycle-Stage-2-Encode/Encoder.png" class="Image" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Basically, there are three major sub components running on the Media Server tier of SUESS. (And boy am I ever excited to have built something complex enough to have &amp;quot;sub components!&amp;quot;) The first one is the Media Service WCF endpoint. This is a standard WCF service that, after the Silverlight client completes the Uploading phase of SUESS, it calls to kick off the encoding process. &lt;/p&gt;
&lt;p class="Text"&gt;The interface for the Media Service is very simple, containing only two methods: Encode and Cancel. I tried to choose really intuitive names here; &amp;quot;Encode&amp;quot; performs the encoding, and &amp;quot;Cancel&amp;quot; cancels it. Encode wraps the Expression APIs and does all the work needed to get our media into the IIS SmoothStreaming format. &lt;/p&gt;
&lt;p class="Text"&gt;There is also a web.config file that goes along with the Media Service to store the application settings (along with all the WCF goo). These dictate the size of the thumbnail images, and the locations of both the temporary upload path for our raw media files as well as the destination for the IIS SmoothStreaming-formatted files. These settings, combined with the file name passed in from the Uploader, is all the Encoder needs to do its thing. &lt;/p&gt;
&lt;p class="Text"&gt;There is one more quite architectural consideration to point out before we jump into code. The Expression Encoder APIs are 32-bit only. This is generally not an issue if you are hanging out in 2007 or earlier, because starting with Windows Server 2008, 64-bit has become the de facto standard in making developers crazy. That&amp;#39;s not to say that 32-bit applications won&amp;#39;t work; .NET handles all of that &amp;quot;&lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/aa384249(VS.85).aspx" class="Link"&gt;WOW&lt;/a&gt;&amp;quot; stuff for us. &lt;/p&gt;
&lt;p class="Text"&gt;However, when you try to have a 64 bit process (such as a Windows Service, or an ASP.NET app like SharePoint) call into the 32 bit Encoder DLLs, things die. If your first instinct (like mine) was to compile the Media Service using Visual Studio&amp;#39;s &amp;quot;x86&amp;quot; or &amp;quot;Any CPU&amp;quot; configurations, you won&amp;#39;t get there. The problem isn&amp;#39;t that one piece of code can&amp;#39;t talk to another; it&amp;#39;s that the entire process needs to be in the same architecture. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;So to circumvent this, we need to be running our entire stack in 32-bit mode. Whether it&amp;#39;s a Windows Service set explicitly to compile to x86 or a 64-bit IIS application pool that has 32-bit support enabled, since Encoder requires us to be in 32-bit world, we need a 32-bit process. The clear choice here is to use IIS and flip one setting (App Pool -&amp;gt; Advanced Settings -&amp;gt; Enable 32-Bit Applications -&amp;gt; True) verses going through all the hell of building, deploying, and configuring a Windows Service. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Rant"&gt;&amp;lt;RANT&amp;gt;&lt;/span&gt; &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Windows Services suck. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Rant"&gt;&amp;lt;/RANT&amp;gt;&lt;/span&gt; &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;div class="SectionHeader"&gt;Media Encoding&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;The second sub component is the Encoder API itself. Let&amp;#39;s look at the Encode method first to get an idea of everything that&amp;#39;s going on programmatically. Then, we&amp;#39;re going to jump back to the WCF side of things are discuss the bi-directional communication (awesome). &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;table cellpadding="0" cellspacing="0" class="CodeLayout"&gt;
&lt;tbody&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellTopLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;
&lt;div class="CodeContainer"&gt;
&lt;div class="CodeLayout"&gt;&lt;ol class="Code"&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;public&lt;/span&gt; &lt;span class="Keyword"&gt;void&lt;/span&gt; Encode&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;string&lt;/span&gt; fileName&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;string&lt;/span&gt; quality&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//initialization&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;string&lt;/span&gt; uploadPath &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;string&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Empty&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_client &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;OperationContext&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Current&lt;span class="Operator"&gt;.&lt;/span&gt;GetCallbackChannel&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="ClassName"&gt;IEncoderClient&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;try&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//create new encoder job&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_job &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;Job&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_job&lt;span class="Operator"&gt;.&lt;/span&gt;CreateSubfolder &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;true&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;int&lt;/span&gt; size &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;GetThumbmailSize&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_job&lt;span class="Operator"&gt;.&lt;/span&gt;SaveJobFileToOutputDirectory &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;false&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_job&lt;span class="Operator"&gt;.&lt;/span&gt;OutputDirectory &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;GetMediaPath&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;uploadPath &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;Path&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Combine&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;GetUploadPath&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt; fileName&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//complexity&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;VideoComplexity&lt;/span&gt; vc &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;VideoComplexity&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;switch&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;quality&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//determine quality&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;case&lt;/span&gt; &lt;span class="Constant"&gt;&amp;quot;Best Quality (Slowest Upload)&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;vc &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;VideoComplexity&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Best&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;break&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;case&lt;/span&gt; &lt;span class="Constant"&gt;&amp;quot;Better&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;vc &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;VideoComplexity&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Better&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;break&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;case&lt;/span&gt; &lt;span class="Constant"&gt;&amp;quot;Good&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;vc &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;VideoComplexity&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Good&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;break&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;case&lt;/span&gt; &lt;span class="Constant"&gt;&amp;quot;Normal&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;vc &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;VideoComplexity&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Normal&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;break&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;case&lt;/span&gt; &lt;span class="Constant"&gt;&amp;quot;Low&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;vc &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;VideoComplexity&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Fast&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;break&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;case&lt;/span&gt; &lt;span class="Constant"&gt;&amp;quot;Lowest Quality (Fastest Upload)&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;vc &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;VideoComplexity&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Fastest&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;break&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;default&lt;/span&gt;&lt;span class="Operator"&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;vc &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;VideoComplexity&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Normal&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;break&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//smooth streaming video&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;AdvancedVC1VideoProfile&lt;/span&gt; videoProfile &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;AdvancedVC1VideoProfile&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;Complexity &lt;span class="Operator"&gt;=&lt;/span&gt; vc&lt;span class="Operator"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;AdaptiveGop &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;false&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;SmoothStreaming &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;true&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//streams&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;videoProfile&lt;span class="Operator"&gt;.&lt;/span&gt;Streams&lt;span class="Operator"&gt;.&lt;/span&gt;RemoveAt&lt;span class="Operator"&gt;(&lt;/span&gt;0&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;videoProfile&lt;span class="Operator"&gt;.&lt;/span&gt;Streams&lt;span class="Operator"&gt;.&lt;/span&gt;Add&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;ConstantBitrate&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;600&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;false&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;Size&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;400&lt;span class="Operator"&gt;,&lt;/span&gt; 300&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;videoProfile&lt;span class="Operator"&gt;.&lt;/span&gt;Streams&lt;span class="Operator"&gt;.&lt;/span&gt;Add&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;ConstantBitrate&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;1050&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;false&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;Size&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;640&lt;span class="Operator"&gt;,&lt;/span&gt; 480&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;videoProfile&lt;span class="Operator"&gt;.&lt;/span&gt;Streams&lt;span class="Operator"&gt;.&lt;/span&gt;Add&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;ConstantBitrate&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;1450&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;false&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;Size&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;800&lt;span class="Operator"&gt;,&lt;/span&gt; 600&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//crappy aduio&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;WmaAudioProfile&lt;/span&gt; audioProfile &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;WmaAudioProfile&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;Channels &lt;span class="Operator"&gt;=&lt;/span&gt; 2&lt;span class="Operator"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;BitsPerSample &lt;span class="Operator"&gt;=&lt;/span&gt; 16&lt;span class="Operator"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;SamplesPerSecond &lt;span class="Operator"&gt;=&lt;/span&gt; 44100&lt;span class="Operator"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;Bitrate &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;ConstantBitrate&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;64&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;false&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//create media item&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;MediaItem&lt;/span&gt; mi &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;MediaItem&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;uploadPath&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;ThumbnailCodec &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;ImageFormat&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Jpeg&lt;span class="Operator"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;ThumbnailMode &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;ThumbnailMode&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;FirstFrame&lt;span class="Operator"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;ThumbnailSize &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;Size&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;size&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="ClassName"&gt;Convert&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;ToInt32&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;size &lt;span class="Operator"&gt;/&lt;/span&gt; 1&lt;span class="Operator"&gt;.&lt;/span&gt;3&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;OutputFormat &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;WindowsMediaOutputFormat&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;VideoProfile &lt;span class="Operator"&gt;=&lt;/span&gt; videoProfile&lt;span class="Operator"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;AudioProfile &lt;span class="Operator"&gt;=&lt;/span&gt; audioProfile&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//hook events&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_job&lt;span class="Operator"&gt;.&lt;/span&gt;EncodeProgress &lt;span class="Operator"&gt;+&lt;/span&gt;&lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;EventHandler&lt;/span&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="ClassName"&gt;EncodeProgressEventArgs&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Job_EncodeProgress&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_job&lt;span class="Operator"&gt;.&lt;/span&gt;EncodeCompleted &lt;span class="Operator"&gt;+&lt;/span&gt;&lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;EventHandler&lt;/span&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="ClassName"&gt;EncodeCompletedEventArgs&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Job_EncodeCompleted&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_job&lt;span class="Operator"&gt;.&lt;/span&gt;StartFileEncoding &lt;span class="Operator"&gt;+&lt;/span&gt;&lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;EventHandler&lt;/span&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="ClassName"&gt;StartFileEncodingEventArgs&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Job_StartFileEncoding&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//encode&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_job&lt;span class="Operator"&gt;.&lt;/span&gt;MediaItems&lt;span class="Operator"&gt;.&lt;/span&gt;Add&lt;span class="Operator"&gt;(&lt;/span&gt;mi&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_job&lt;span class="Operator"&gt;.&lt;/span&gt;Encode&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;catch&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;Exception&lt;/span&gt; ex&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//error&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;string&lt;/span&gt; error &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;string&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Format&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Constant"&gt;&amp;quot;The following error occured while encoding {0}: {1}&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;string&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;IsNullOrEmpty&lt;span class="Operator"&gt;(&lt;/span&gt;uploadPath&lt;span class="Operator"&gt;)&lt;/span&gt; &lt;span class="Operator"&gt;?&lt;/span&gt; fileName &lt;span class="Operator"&gt;:&lt;/span&gt; uploadPath&lt;span class="Operator"&gt;,&lt;/span&gt; ex&lt;span class="Operator"&gt;.&lt;/span&gt;ToString&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;EventLog&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;WriteEntry&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Constant"&gt;&amp;quot;EncoderService.Encode&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt; error&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="ClassName"&gt;EventLogEntryType&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Error&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_client&lt;span class="Operator"&gt;.&lt;/span&gt;EncodingError&lt;span class="Operator"&gt;(&lt;/span&gt;error&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;finally&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//clean&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_job&lt;span class="Operator"&gt;.&lt;/span&gt;Dispose&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellBottomLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;The main workhorse of the Expression Encoder API is the Job object. I couldn&amp;#39;t find any formal documentation on the API, so I sort of reverse engineered it by mapping class names in Visual Studio to menu options in the Encoder product. Whenever you encode something using the application, you create a new &amp;quot;Job&amp;quot; and set a bunch of options on it. This is pretty much the same way I learned SharePoint many years ago; the Encoder API, although undocumented, is more intuitive than SharePoint&amp;#39;s, so I was able to hack my way though it a little easier. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;So let&amp;#39;s take a look. Line #5 is the WFC bi-directional stuff, which we&amp;#39;ll look at in a bit. Line #9 instantiates our Job object. It&amp;#39;s global in the service because, skipping down to Lines #75-77, where we hook the events, we need to refer back to properties on the Job object. Again, we&amp;#39;ll look at the event handlers themselves when we move back from the Encoder to the WCF/Silverlight communication logic. Lines #10-14 round out the Job initialization code, calling helper methods that simply grab values from the web.config file. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Starting at Line #16, we get into the meat and potatoes of media side of the Encoder API. Encoder allows you control a vast array of characteristics of an encoding process. The first one here is the video complexity (which I covered in the &lt;a target="_blank" href="http://chrisdomino.com/blog/post/The-SUESS-Lifecycle-Stage-1-Upload" class="Link"&gt;Uploader&lt;/a&gt; post). Basically, this enumeration dictates an arbitrary ratio between video quality and encoding speed. While this particular property is a bit black-box-ish, (I couldn&amp;#39;t track it down in Reflector) the rest that we&amp;#39;re going to look at really show how much control you have over your users&amp;#39; viewing experiences. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Basically, an Encoder Job needs three pieces of information to encode media: a VideoProfile, an AudioProfile, and a MediaItem. The VideoProfile has information of the &amp;quot;target&amp;quot; video properties; same deal with the AudioProfile. The MediaItem combines the two profiles, as well as contains a myriad of properties pertaining to things such as thumbnail information, markers, general media settings, audio overlays, and on and on. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Let&amp;#39;s pick back up with the code at Line #43. An AdvancedVC1VideoProfile is one of many classes that is derived from a deep inheritance tree originating with VideoProfile. All of these classes correspond to options available in Expression Encoder&amp;#39;s UI. Without going into too much detail, the type initializer made up of Lines #45-47 basically tells the Encoder API to encode into the IIS SmoothStreaming format using the &amp;quot;Advanced&amp;quot; VC1 codec presets. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Each class derived from VideoProfile adds lots of different options that allow you to tweak your output video format according to your requirements. If we were supporting &amp;quot;straight&amp;quot; HD Silverlight video, we&amp;#39;d probably use the MainH264VideoProfile instead. Note that setting the &amp;quot;SmoothStreaming&amp;quot; property to true on any VideoProfile derivation simply &amp;quot;enables&amp;quot; the IIS SmoothStreaming output format; the files themselves will adhere to which ever video codec you assign them, based on the profile you select and properties you set. And if you enable SmoothStreaming, there are other properties that need to be set a certain way. I haven&amp;#39;t dug too deeply on this, but don&amp;#39;t worry: the exception details you&amp;#39;ll get are description enough to guide you through the programmatic configuration of your video profiles. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;With the profile out of the way, we now need to tackle the SmoothStreaming aspect of the video. Check out Lines #50-54. This is great example of what IIS SmoothStreaming is all about. If I had to describe this format in one sentence, it would be thus: The focus is on dynamically assessing the bandwidth of the connection between the Silverlight client and IIS Media Services 3.0 server, and selecting the correct quality version of the requested media. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;The aforementioned lines of code determine how many different options we are giving IIS Media Services to work with when it determines quality, and what each option, or &amp;quot;Stream,&amp;quot; can deliver. First, Line #50 clears out the &amp;quot;default&amp;quot; stream that &amp;quot;comes with&amp;quot; the AdvancedVC1VideoProfile instance. This is a best practice. Next we need to define our own streams. As you can see from the code, a stream is made up of a bitrate and a size. The next three lines then each define streams of increasing sizes (and therefore qualities) while maintaining a native 4:3 aspect ratio. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;So let&amp;#39;s dig, taking the second parameter fist. The &amp;quot;Size&amp;quot; portion of a stream is easy enough to understand: a movie that&amp;#39;s 800x600 natively will look better in a standardly-sized player than one that&amp;#39;s 400x300. But since more pixels are crammed into the same space, the file is denser, and therefore larger on disk. This requires more bandwidth to be pushed down in a timely manner that keeps up with the bitrate. The smaller file has fewer pixels and less quality, and requires less bandwidth to deliver. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Cool. So what&amp;#39;s a bitrate? Well, that&amp;#39;s a &amp;quot;bit&amp;quot; more complicated. Sorry. There are two types in the Encoder API: &lt;a target="_blank" href="http://en.wikipedia.org/wiki/Variable_bitrate" class="Link"&gt;VariableBitRate&lt;/a&gt; (with its few derivations) and &lt;a target="_blank" href="http://en.wikipedia.org/wiki/Constant_bitrate" class="Link"&gt;ConstantBitRate&lt;/a&gt;. I&amp;#39;ll let Wikipedia do the honors here, but at a high level, different segments of a media file have different complexities. If the movie starts out blank with no sound for a few seconds, those frames are very &amp;quot;small&amp;quot; compared to frames later in the movie that have high-speed motion or explosions. These portions of the file have a lot more detail. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;A variable bitrate allows the file to sort of throttle itself, so that &amp;quot;easy&amp;quot; portions (like all black intro frames) can transmit over the wire at lower speeds, but more &amp;quot;complicated&amp;quot; segments can start sprinting and stream and higher rates. The drawbacks? Larger files and longer time needed to encode. By comparison, a constant bitrate &amp;quot;forces&amp;quot; every segment of the file to have the same quality. Of course, this is much simpler logic, and transfers at a constant speed making IIS Media Services&amp;#39; life easier, but those aforementioned &amp;quot;more complicated&amp;quot; portions of the film will be scaled back to meet the constant bitrate. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;So when you choose the bitrate that works for your situation, you can choose from goodies such as: VariableUnconstrainedBitrate, VariableConstrainedBitrate, VariableQualityBitrate, and ConstantBitrate. You can discern among these by the parameter that each class takes. The code sample uses ConstantBitrate, because SUESS was first created for a SharePoint intranet, where we had complete control over network bandwidth. IIS SmoothStreaming was key in general because the client had offices all over the world, but beyond that, we pushed for speed over quality. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Once thing to note about ConstantBitrate: even though it yields a leaner, faster format, it &lt;span class="Italic"&gt;could&lt;/span&gt; take longer to encode! By default, Encoder will make &lt;span class="Bold"&gt;TWO&lt;/span&gt; passes through the file, essentially doubling the time it takes to encode. The first pass determines the average bitrate across the file, and the second pass actually does the work with the correct average. That&amp;#39;s what the false parameter in the ConstantBitRate constructor in Lines #51-53 controls; it tells Encoder to use the BitRate passed in and to not worry about being too fancy about it. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;And that&amp;#39;s just the video; audio is a separate story in the media world. When watching any modern media (Film, DVD, Web, etc.) you&amp;#39;re actually watching a video track and listening to an audio track - separate from each other - that both started at the same time. In much the same way video was configured with bit rates and quality settings, you can customize the audio portion of SUESS to the same extent. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;I won&amp;#39;t go into nearly as much detail for audio, because it&amp;#39;s really the same idea. In fact, the concepts of profiles, bitrates, and customizable quality settings all work exactly the same; there&amp;#39;s just different types (and actually, the bitrates are identical). So you can play around with these settings the same way we played around WAV files ripped from CDs back in Windows 95! &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;In this example, (which again was for an intranet project) I sacrificed audio quality so I could push as much video through the pipes as possible. What&amp;#39;s interesting is that the same audio settings are applied to each video stream; in other words, SmoothStreaming only considers video, and pushes the same audio profile irrespective to which quality it detects. Lines #55-61 configure the audio in the above code example. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Finally we have the MediaItem, which acts as a single encoding &amp;quot;task&amp;quot; for our Job object to perform. If you add multiple MediaItems to the Job (or even if our service gets a request while another encoding operation is in progress) they will queue up and finish in series, so that your processor doesn&amp;#39;t have a heart attack. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;As I alluded to before, the MediaItem houses the video and audio profiles and collects the rest of the data that tells the Job exactly what to do. For my purposes, which was more to the end of allowing pervasive formats and maximum performance verses actual media processing (I&amp;#39;m a developer, not a DeeJay) I was able to configure everything I needed media-wise in my profiles. However, I again encourage you to experiment with the vast array of options available on MediaItem; the API is extremely powerful! &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;The only additional customization I needed to do on the MediaItem was to define how to pull a thumbnail from the uploaded media. I new up my object on Line #63, passing it the string path of the final upload destination for the file. Then, Lines #65-67 define how I want my thumbnail to be generated. In this example, it&amp;#39;s a 4:3 JPEG of the first frame. The file will be saved in the same directory as the SmoothStream files. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;And that&amp;#39;s about it! Lines #68-72 pull my video and audio profiles together into an OutputFormat. I&amp;#39;m using WindowsMediaOutputFormat because that&amp;#39;s the one directly compatible with Silverlight. There are a few others you can play with, primarily if you are doing Live encoding. This is a bit confusing, since we&amp;#39;ve been talking about SmoothStreaming this whole time, but now we&amp;#39;re telling the Job to dump out a WMV? Think of it this way: we are encoding for Silverlight, so Windows Media is the best option. SmoothStreaming is special type of format &lt;span class="Italic"&gt;for&lt;/span&gt; WMV that IIS knows how do all the fancy streaming with. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;The code block ends with hooking the events, adding our MediaItem, and then calling Encode! We&amp;#39;ll check in with our events in the next section. One quick thing to note is that some operations around MediaItem can take a while (seconds or longer) to execute, so plan your progress bars as necessary. Watch how the Expression Encoder product does its thing. When you select a new file to encode, it chugs for a bit as it pulls thumbnails, applies default profiles, etc. So if you don&amp;#39;t start your progress bars until the first progress event fires, your users might think you app is hung while they wait for the Encoder API to warm up! &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;div class="SectionHeader"&gt;Silverlight 4 / WCF Bi-Directional Communication&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;.NET RIA Services is cool. Web cam integration is fun. File drag &amp;amp; drop is neat. But as someone who pays for his drinks by building business applications, I have to say that support for the WCF bi-directional HTTP Polling Duplex binding is my favorite new Silverlight 4 toy. AJAX greatly improved UX by eliminating post backs and making it easy to implement &amp;quot;please wait&amp;quot; functionality while the page churned. Silverlight takes us further by allowing real time progress bars during long-running processes. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Finally, we can do serious work on the web. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;So how does this bi-directional stuff work? First of all, it&amp;#39;s still straight WCF: contracts on the server, proxies on the client, and tons of glue in the web.config file. The &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.servicemodel.servicecontractattribute.aspx" class="Link"&gt;ServiceContract&lt;/a&gt; works the same way, exact that you add a reference to a second ServiceContract that acts as the &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.servicemodel.servicecontractattribute.callbackcontract.aspx" class="Link"&gt;CallbackContract&lt;/a&gt;. What this means is that we have a normal ServiceContact that guarantees certain methods are available on the server. The second ServiceContact (which is a separate interface) defines certain events that the client can handle; in other words, the server can basically call methods on the client! &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Well, not really: when the client makes the first call, it keeps a channel open with the server, through which it &amp;quot;polls&amp;quot; [hence the name] - asking the server constantly if something has occurred. When the server raises notification that something has indeed happened, the corresponding event is fired. The cool thing about this is how WCF abstracts away the hairy details, and lets us work in the comfortable event-driven programming model. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Let&amp;#39;s look at some code. First, here are the contracts: &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;table cellpadding="0" cellspacing="0" class="CodeLayout"&gt;
&lt;tbody&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellTopLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;
&lt;div class="CodeContainer"&gt;
&lt;div class="CodeLayout"&gt;&lt;ol class="Code"&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;#region&lt;/span&gt; Server&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;[&lt;/span&gt;&lt;span class="ClassName"&gt;ServiceContract&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;CallbackContract &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;typeof&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;IEncoderClient&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;public&lt;/span&gt; &lt;span class="Keyword"&gt;interface&lt;/span&gt; IEncoderService&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;[&lt;/span&gt;&lt;span class="ClassName"&gt;OperationContract&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;IsOneWay &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;true&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;void&lt;/span&gt; &lt;span class="ClassName"&gt;Encode&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;string&lt;/span&gt; fileName&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;string&lt;/span&gt; quality&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;[&lt;/span&gt;&lt;span class="ClassName"&gt;OperationContract&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;IsOneWay &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;true&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;void&lt;/span&gt; &lt;span class="ClassName"&gt;Cancel&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;#endregion&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;#region&lt;/span&gt; Client&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;[&lt;/span&gt;&lt;span class="ClassName"&gt;ServiceContract&lt;/span&gt;&lt;span class="Operator"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;public&lt;/span&gt; &lt;span class="Keyword"&gt;interface&lt;/span&gt; IEncoderClient&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;[&lt;/span&gt;&lt;span class="ClassName"&gt;OperationContract&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;IsOneWay &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;true&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;void&lt;/span&gt; &lt;span class="ClassName"&gt;EncodingProgress&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;double&lt;/span&gt; progress&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;string&lt;/span&gt; timeRemaining&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;[&lt;/span&gt;&lt;span class="ClassName"&gt;OperationContract&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;IsOneWay &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;true&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;void&lt;/span&gt; &lt;span class="ClassName"&gt;EncodingStarted&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;[&lt;/span&gt;&lt;span class="ClassName"&gt;OperationContract&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;IsOneWay &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;true&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;void&lt;/span&gt; &lt;span class="ClassName"&gt;EncodingCompleted&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;string&lt;/span&gt; jobId&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;[&lt;/span&gt;&lt;span class="ClassName"&gt;OperationContract&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;IsOneWay &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;true&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;void&lt;/span&gt; &lt;span class="ClassName"&gt;EncodingError&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;string&lt;/span&gt; errorText&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;#endregion&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellBottomLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Like I said this is pretty much straight WCF. The only additions are in the attribution. The main &amp;quot;new&amp;quot; concept is the &amp;quot;CallbackClient&amp;quot; in Line #2. This basically tells the service what &amp;quot;methods&amp;quot; it can &amp;quot;call&amp;quot; on the client. You&amp;#39;ll also notice a lot of attribution setting the &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.servicemodel.operationcontractattribute.isoneway.aspx" class="Link"&gt;IsOneWay&lt;/a&gt; switch to true. This enables the &amp;quot;event-driven&amp;quot; style we discussed earlier. Even if methods return voids, if IsOneWay is false, the server is still expecting a reply message form the client. This behavior is more client/server than event-driven, and breaks the duplex model. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Next, let&amp;#39;s look at how we define our &amp;quot;global variables.&amp;quot; The first one in the code below is our Encoder Job object, which like I said is &amp;quot;global&amp;quot; so that I can more easily reference it in its events. The second one is our Encoder client interface (of type, well, IEncoderClient of course). Line #6 (which is an excerpt from the Encode method in the first code sample [Line #5 there]) shows how we can grab a proxy to our client using the &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.servicemodel.operationcontext.aspx" class="Link"&gt;OperationContext&lt;/a&gt;. This is a magical call that, when invoked inside a method corresponding to one of our service&amp;#39;s operation contracts, &amp;quot;knows&amp;quot; about the client who called it. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;table cellpadding="0" cellspacing="0" class="CodeLayout"&gt;
&lt;tbody&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellTopLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;
&lt;div class="CodeContainer"&gt;
&lt;div class="CodeLayout"&gt;&lt;ol class="Code"&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;#region&lt;/span&gt; Members&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;private&lt;/span&gt; &lt;span class="ClassName"&gt;Job&lt;/span&gt; _job&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;private&lt;/span&gt; &lt;span class="ClassName"&gt;IEncoderClient&lt;/span&gt; _client&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;#endregion&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//this next line is at the beginning of the Encode method from the first code listing in this post&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_client &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;OperationContext&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Current&lt;span class="Operator"&gt;.&lt;/span&gt;GetCallbackChannel&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="ClassName"&gt;IEncoderClient&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellBottomLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Now that we have a solid reference to our client, we can call methods on the global _client interface, and the corresponding events will be raised and handled as normal WCF service events down on our Silverlight clients. Beautiful. Finally, let&amp;#39;s look at one of these duplex method calls from both the server&amp;#39;s and client&amp;#39;s perspective. The example I&amp;#39;ll use here is the Encoder API&amp;#39;s &amp;quot;EncodeProgress&amp;quot; event. First, the event handler to what we hooked in Line #75 from the first code listing in this post: &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;table cellpadding="0" cellspacing="0" class="CodeLayout"&gt;
&lt;tbody&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellTopLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;
&lt;div class="CodeContainer"&gt;
&lt;div class="CodeLayout"&gt;&lt;ol class="Code"&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;private&lt;/span&gt; &lt;span class="Keyword"&gt;void&lt;/span&gt; Job_EncodeProgress&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;object&lt;/span&gt; sender&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="ClassName"&gt;EncodeProgressEventArgs&lt;/span&gt; e&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//get progress time&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;TimeSpan&lt;/span&gt; sp &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_job&lt;span class="Operator"&gt;.&lt;/span&gt;MediaItems&lt;span class="Operator"&gt;[&lt;/span&gt;0&lt;span class="Operator"&gt;]&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;FileDuration&lt;span class="Operator"&gt;.&lt;/span&gt;Subtract&lt;span class="Operator"&gt;(&lt;/span&gt;e&lt;span class="Operator"&gt;.&lt;/span&gt;CurrentPosition&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//call client&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_client&lt;span class="Operator"&gt;.&lt;/span&gt;EncodingProgress&lt;span class="Operator"&gt;(&lt;/span&gt;e&lt;span class="Operator"&gt;.&lt;/span&gt;Progress&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;string&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Format&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Constant"&gt;&amp;quot;{0}:{1}:{2}&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt; sp&lt;span class="Operator"&gt;.&lt;/span&gt;Hours&lt;span class="Operator"&gt;.&lt;/span&gt;ToString&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Constant"&gt;&amp;quot;00&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt; sp&lt;span class="Operator"&gt;.&lt;/span&gt;Minutes&lt;span class="Operator"&gt;.&lt;/span&gt;ToString&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Constant"&gt;&amp;quot;00&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt; sp&lt;span class="Operator"&gt;.&lt;/span&gt;Seconds&lt;span class="Operator"&gt;.&lt;/span&gt;ToString&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Constant"&gt;&amp;quot;00&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellBottomLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;The Encoder API gives us a lot of information in the EncodeProgressEventArgs parameter. However, as I defined my IEncoderClient interface, I&amp;#39;m only interesting in the percentage done and the time remaining. So Line #3 subtracts the current time position of the Job from the total duration of the first (and always only) MediaItem and that&amp;#39;s the time remaining. I pass the progress straight through to Line #6, which actually fires this event on the client. Speaking of the client, let&amp;#39;s see what&amp;#39;s going on in the Silverlight side of things to bring this full circle. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;table cellpadding="0" cellspacing="0" class="CodeLayout"&gt;
&lt;tbody&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellTopLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;
&lt;div class="CodeContainer"&gt;
&lt;div class="CodeLayout"&gt;&lt;ol class="Code"&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;private&lt;/span&gt; &lt;span class="Keyword"&gt;void&lt;/span&gt; svc_EncodingProgressReceived&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;object&lt;/span&gt; sender&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="ClassName"&gt;EncodingProgressReceivedEventArgs&lt;/span&gt; e&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//animate value&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;Utilities&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;AnimateDouble&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;pbUpload&lt;span class="Operator"&gt;,&lt;/span&gt; e&lt;span class="Operator"&gt;.&lt;/span&gt;Progress&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Constant"&gt;&amp;quot;Value&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Begin&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//update text&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;tbProgress&lt;span class="Operator"&gt;.&lt;/span&gt;Text &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;string&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Format&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Constant"&gt;&amp;quot;Encoding file... {0}%&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="ClassName"&gt;Math&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Round&lt;span class="Operator"&gt;(&lt;/span&gt;e&lt;span class="Operator"&gt;.&lt;/span&gt;Progress&lt;span class="Operator"&gt;,&lt;/span&gt; 1&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;ToString&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Constant"&gt;&amp;quot;#0.0&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellBottomLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;As you can see, this is very standard WCF/Silverlight functionality. The UI is updated with values that the server sends down. And since this event is hooked the same exact way as any other WCF method (just get a reference to the service proxy object and wire up an event handler) we are guaranteed to be on the UI thread when we update controls. It&amp;#39;s...and I&amp;#39;m getting emotional here...just beautiful... &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;The last thing we need to talk about is the configuration. Did you think we&amp;#39;d talk about anything WCF related and not have to dig into a web.config file? Actually, like everything else we&amp;#39;ve discussed on Silverlight side of the Encoder stage, there&amp;#39;s nothing new, per se; just additional. Since the Polling Duplex binding didn&amp;#39;t ship with Silverlight 4, (and if your service is still in .NET 3.5.1) we need to manually reference it. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;First, we need to get the correct WCF assembly. Once you install all the latest bits for the Silverlight 4 developer run time, go to this folder on your development box (assuming it&amp;#39;s an x64 OS): C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\Libraries (and then either the \Client or \Server folder). Grab the appropriate DLL (System.ServiceModel.PollingDuplex.dll) and reference the &amp;quot;client&amp;quot; version in your Silverlight project and the &amp;quot;server&amp;quot; one in the WCF project. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Now, let&amp;#39;s look at the server side web.config file: &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;table cellpadding="0" cellspacing="0" class="CodeLayout"&gt;
&lt;tbody&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellTopLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;
&lt;div class="CodeContainer"&gt;
&lt;div class="CodeLayout"&gt;&lt;ol class="Code"&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;?&lt;/span&gt;&lt;span class="Keyword"&gt;xml&lt;/span&gt;&lt;span class="ClassName"&gt; version&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;1.0&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;configuration&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;appSettings&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;add&lt;/span&gt;&lt;span class="ClassName"&gt; key&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;ThumbnailSize&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; value&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;400&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;add&lt;/span&gt;&lt;span class="ClassName"&gt; key&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;MediaPath&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; value&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;\\DatabaseServer\Media&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;add&lt;/span&gt;&lt;span class="ClassName"&gt; key&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;UploadPath&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; value&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;\\DatabaseServer\Temp Uploads&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;appSettings&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;system.serviceModel&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;extensions&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;bindingExtensions&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;add&lt;/span&gt;&lt;span class="ClassName"&gt; name&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;pollingDuplexHttpBinding&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; type&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement,System.ServiceModel.PollingDuplex, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;bindingExtensions&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;extensions&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;bindings&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;pollingDuplexHttpBinding&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;binding&lt;/span&gt;&lt;span class="ClassName"&gt; name&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;multipleMessagesPerPollPollingDuplexHttpBinding&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; duplexMode&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;MultipleMessagesPerPoll&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; maxBufferSize&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;2147483647&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; maxReceivedMessageSize&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;2147483647&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; receiveTimeout&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;01:00:00&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; closeTimeout&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;01:00:00&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; openTimeout&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;01:00:00&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; sendTimeout&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;01:00:00&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; inactivityTimeout&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;01:00:00&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt; &lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;pollingDuplexHttpBinding&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;bindings&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;services&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;service&lt;/span&gt;&lt;span class="ClassName"&gt; behaviorConfiguration&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;Services.Media.EncoderServiceBehavior&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; name&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;Services.Media.EncoderService&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;endpoint&lt;/span&gt;&lt;span class="ClassName"&gt; address&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; binding&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;pollingDuplexHttpBinding&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; bindingConfiguration&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;multipleMessagesPerPollPollingDuplexHttpBinding&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; contract&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;Services.Media.IEncoderService&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;endpoint&lt;/span&gt;&lt;span class="ClassName"&gt; address&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;mex&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; binding&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;mexHttpBinding&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="ClassName"&gt; contract&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;IMetadataExchange&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;service&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;services&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;behaviors&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;serviceBehaviors&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;behavior&lt;/span&gt;&lt;span class="ClassName"&gt; name&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;Services.Media.EncoderServiceBehavior&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:50px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;serviceMetadata&lt;/span&gt;&lt;span class="ClassName"&gt; httpGetEnabled&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;false&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:50px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;serviceDebug&lt;/span&gt;&lt;span class="ClassName"&gt; includeExceptionDetailInFaults&lt;/span&gt;&lt;span class="Operator"&gt;=&amp;quot;&lt;/span&gt;false&lt;span class="Operator"&gt;&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;behavior&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;serviceBehaviors&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;behaviors&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;system.serviceModel&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Operator"&gt;/&lt;/span&gt;&lt;span class="Keyword"&gt;configuration&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellBottomLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;In Lines #9-14, we reference the aforementioned assembly as a valid binding. Then, in Lines #14-18, we wire up the binding like another WCF service. Note that Visual Studio will complain, since the &amp;quot;pollingDuplexHttpBinding&amp;quot; isn&amp;#39;t part of the out-of-the-box schema. On the Silverlight side, I programmatically create my binding objects so I don&amp;#39;t have to worry about updating client-side configuration files. Here&amp;#39;s the code for that (refer to the &lt;a target="_blank" href="http://chrisdomino.com/blog/post/The-SUESS-Lifecycle-Stage-1-Upload" class="Link"&gt;Uploader&lt;/a&gt; post for the details). &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;table cellpadding="0" cellspacing="0" class="CodeLayout"&gt;
&lt;tbody&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellTopLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;
&lt;div class="CodeContainer"&gt;
&lt;div class="CodeLayout"&gt;&lt;ol class="Code"&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;private&lt;/span&gt; &lt;span class="ClassName"&gt;EncoderServiceClient&lt;/span&gt; GetEncoderClient&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//get binding&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;PollingDuplexHttpBinding&lt;/span&gt; binding &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;PollingDuplexHttpBinding&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;MaxBufferSize &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;int&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;MaxValue&lt;span class="Operator"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;OpenTimeout &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;TimeSpan&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;FromHours&lt;span class="Operator"&gt;(&lt;/span&gt;1&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;SendTimeout &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;TimeSpan&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;FromHours&lt;span class="Operator"&gt;(&lt;/span&gt;1&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;CloseTimeout &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;TimeSpan&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;FromHours&lt;span class="Operator"&gt;(&lt;/span&gt;1&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;MaxReceivedMessageSize &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;int&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;MaxValue&lt;span class="Operator"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;ReceiveTimeout &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;TimeSpan&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;FromHours&lt;span class="Operator"&gt;(&lt;/span&gt;1&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;InactivityTimeout &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;TimeSpan&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;FromHours&lt;span class="Operator"&gt;(&lt;/span&gt;1&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;DuplexMode &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;PollingDuplexMode&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;MultipleMessagesPerPoll&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//return&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;return&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;EncoderServiceClient&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;binding&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;EndpointAddress&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;string&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Format&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Constant"&gt;&amp;quot;{0}EncoderService.svc&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_parameters&lt;span class="Operator"&gt;[&lt;/span&gt;&lt;span class="Constant"&gt;&amp;quot;MediaServerURL&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;]&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellBottomLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;It is against the object that this method returns that you can hook the &amp;quot;polling&amp;quot; events to enable bi-directional communitcation. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;That closes the book on the Encoding phase of SUESS. As you can see, there&amp;#39;s a lot going on, but all of the pieces are very straightforward. It&amp;#39;s taking all of the cutting edge functionality from Encoder, IIS, WCF, and Silverlight, and gluing them all together. The hardest thing I ran into when built all of this is finding the right glue...and knowing when to use a lot and when to use a little. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Onto the final stage: SmoothStreaming! &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.rightpoint.com/community/aggbug.aspx?PostID=2816" width="1" height="1"&gt;</content><author><name>cdomino</name><uri>http://www.rightpoint.com/community/members/cdomino/default.aspx</uri></author><category term="WCF" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/WCF/default.aspx" /><category term="IIS SmoothStreaming" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/IIS+SmoothStreaming/default.aspx" /><category term="Expression Encoder" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/Expression+Encoder/default.aspx" /><category term="Silverlight 4" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/Silverlight+4/default.aspx" /></entry><entry><title>Overriding SharePoint 2010 RTE CSS classes</title><link rel="alternate" type="text/html" href="/community/blogs/viewpoint/archive/2010/08/16/overriding-sharepoint-2010-rte-css-classes.aspx" /><id>/community/blogs/viewpoint/archive/2010/08/16/overriding-sharepoint-2010-rte-css-classes.aspx</id><published>2010-08-16T12:00:00Z</published><updated>2010-08-16T12:00:00Z</updated><content type="html">&lt;p&gt;I’m going to shift gears a bit from my normal posts and jump into a little bit of the nuances of SharePoint’s CSS…&amp;#160; SharePoint’s Rich Text Editor (RTE) is a great tool as it gives your content authors the freedom to modify the look and feel of their text.&amp;#160; Granted, this laizze-faire approach is okay in certain environments, and in others a bit more control is required.&amp;#160; One way of controlling user’s markup is to give them specific styles that they can use.&amp;#160; For the uninitiated, these styles live under the ‘Markup Styles’ button as shown here:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_4ED6A61D.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" class="wlDisabledImage" title="image" border="0" alt="image" src="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb_5F00_2B5A01B8.png" width="504" height="192" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;br /&gt;  &lt;p&gt;Of course, to make these your own, all you have to do is override the appropriate classes.&amp;#160; For instance, if I wanted to change Heading 2 to display in gray font, I would simply add the following class to my custom CSS (or theme, or masterpage, or content editor web part; you get the idea, just put it wherever you’re referencing your CSS)&amp;#160; [Also, I should note that you can match the names from SharePoint’s GUI in the CSS with the ‘-ms-name’ reference].&amp;#160; &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;H2.ms-rteElement-H2 {color: #CCCCCC;}&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Likewise, if I wanted to change ‘Colored Heading 2’ to display in red it would be:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;H2.ms-rteElement-H2b {color: #FF0000;}&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Seems easy and straightforward, and it’s not a trap or a trick, it’s really that easy!&amp;#160; However, our astute-readers will notice that when I select either of these headings, the font-size is in percent.&amp;#160; While that method of sizing may make perfect sense to a designer or developer, to the end user that isn’t very helpful.. How are they supposed to know what that 150% is even based off of?&amp;#160; Alright, so let’s go ahead and make this a nice pixel-size based font, so my class changes would be these right?&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;H2.ms-rteElement-H2 {font-size: 16px;}&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font face="Courier New"&gt;H2.ms-rteElement-H2b {font-size:16px;}&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Wrong…Silly CSS and tons of Microsoft classes everywhere.&amp;#160; As it would turn out, Microsoft has a bit of&amp;#160; a web created with these rte classes.&amp;#160; So to make all of the changes I’ve discussed in this post, my final code would be:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;h2,       &lt;br /&gt;.ms-WPBody H2,        &lt;br /&gt;.ms-WPBody H2.ms-rteElement-H2,         &lt;br /&gt;.ms-rteElement-H2        &lt;br /&gt;{        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; -ms-name:&amp;quot;Heading 2&amp;quot;;        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; font-size: 16px;         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; font-weight: normal;        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; text-align:left;        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; color:#cccccc;        &lt;br /&gt;}        &lt;br /&gt;.ms-WPBody H2,        &lt;br /&gt;.ms-WPBody H2.ms-rteElement-H2b,         &lt;br /&gt;.ms-rteElement-H2b        &lt;br /&gt;{        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; -ms-name:&amp;quot;Colored Heading 2&amp;quot;;        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; font-size: 16px;        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; font-weight: normal;        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; text-align:left;        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; color:#ff0000;        &lt;br /&gt;}&lt;/font&gt;      &lt;br /&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Granted, that’s a few more selectors than you were probably expecting, but there’s quite a bit going on with all of the different CSS sheets and classes floating around out there.&amp;#160; You’ll also notice that this code will ‘match’ against most web parts and the use of Header classes.&amp;#160; This isn’t necessary to get the rte bits to work, but I included it as it will keep all of my ‘heading’ elements consistent.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_3134A551.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" class="wlDisabledImage" title="image" border="0" alt="image" src="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb_5F00_74BC30A6.png" width="504" height="348" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;br /&gt;  &lt;p&gt;Following a similar formula, you could also add your own classes, like ‘Heading 5’ and ‘Colored Heading 5’.&amp;#160; Simply copy/paste my more recent code snippet above and modify the 4’s to 5’s.&amp;#160; Please note, these new classes will appear at the bottom of the RTE styles list (in other words, they would display beneath Heading 4/Colored Heading 4.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.rightpoint.com/community/aggbug.aspx?PostID=2815" width="1" height="1"&gt;</content><author><name>jeremyw</name><uri>http://www.rightpoint.com/community/members/jeremyw/default.aspx</uri></author><category term="SharePoint Designer" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/SharePoint+Designer/default.aspx" /><category term="SharePoint 2010" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/SharePoint+2010/default.aspx" /></entry><entry><title>InfoPath Browser Enabled Forms and Crossing Web Applications</title><link rel="alternate" type="text/html" href="/community/blogs/viewpoint/archive/2010/08/13/infopath-browser-enabled-forms-and-crossing-web-applications.aspx" /><id>/community/blogs/viewpoint/archive/2010/08/13/infopath-browser-enabled-forms-and-crossing-web-applications.aspx</id><published>2010-08-13T17:09:15Z</published><updated>2010-08-13T17:09:15Z</updated><content type="html">&lt;h2&gt;&lt;strong&gt;Scenario&lt;/strong&gt;: &lt;/h2&gt;  &lt;p&gt;A browser-enabled InfoPath form was to be built that allowed users to fill out a form, email it to themselves, attach a document to be uploaded to SharePoint, and then sent to an individual that understands SharePoint.&amp;#160; Sure, the easy answer here is to make the user upload the file directly and just classify it there.&amp;#160; The problem is that many users are unwilling to be trained on SharePoint, so this was elected as a compromise to fully utilizing SharePoint.&amp;#160; There’s some other border-cases that this form solves, but this is neither here nor there.&amp;#160; &lt;/p&gt;  &lt;h2&gt;&lt;strong&gt;Challenge&lt;/strong&gt;: &lt;/h2&gt;  &lt;p&gt;The form has a number of drop-downs in it, some are SharePoint ‘choice’ fields, and two are SharePoint ‘lookup’ fields.&amp;#160; The choice fields all function just fine since I’m using a nice little XML file to specify those dropdowns (they rarely change and it’s much quicker to load than querying all of the lists).&amp;#160; The lookup lists do need to be refreshed on each form load, since those are subject to additions.&amp;#160; However, InfoPath Browser forms have a nasty habit of ordering SharePoint-list-data source values by ID rather than Title.&amp;#160; [To add further insult to injury, the full-blown InfoPath client orders by Title..]&amp;#160; Users wouldn’t go for that on lists that contain upwards of 500 choices, so I had to find a way to order by Title…&lt;/p&gt;  &lt;p&gt;After reading some great articles on using owssvr.dll to get a XML output for a particular list, I figured I had the problem licked.&amp;#160; This method would allow me to return live data (on form-load), required no code-behind, and &lt;em&gt;seemed &lt;/em&gt;straight-forward.&amp;#160; So I followed the instructions (&lt;a title="http://blogs.msdn.com/b/infopath/archive/2007/01/15/populating-form-data-from-sharepoint-list-views.aspx" href="http://blogs.msdn.com/b/infopath/archive/2007/01/15/populating-form-data-from-sharepoint-list-views.aspx"&gt;http://blogs.msdn.com/b/infopath/archive/2007/01/15/populating-form-data-from-sharepoint-list-views.aspx&lt;/a&gt;), and then pressed enter to get a plain-white IE window (no XML as promised).&amp;#160; After verifying that this wasn’t some obscure browser setting, I looked at the lists I was referencing and they were (both) custom lists that also had lookup columns contained within.&amp;#160; I then suspected that the lookup column (especially one that allowed multi-select) wasn’t supported by the owssvr.dll method.&amp;#160; Luckily for me, we are running a nifty little master-list data synchronization on this environment.&amp;#160; The custom code basically reads a list (considered the ‘master’) on Web Application A, Site Collection A, and then writes any add/update/delete actions to copy-lists stored other Site Collections under Web Application B.&amp;#160; Anyways, the ‘synchronized’ lists don’t contain the lookup columns, just the ‘ID’ and ‘Title’ values.&amp;#160; Effectively, this allowed me to test owssvr.dll reading a ‘simple’ list…&lt;/p&gt;  &lt;p&gt;After running a quick test, I discovered that owssvr.dll worked famously with the sync-lists!&amp;#160; So, I rebuilt my form data connections, redeployed the form, and then BAM! Yet another error about SharePoint not being able to access data sources [Error ID 6932](and all of my dropdowns of lookup lists were blank).&amp;#160; After some poking around, I surmised that InfoPath form services (even with cross-domain enabled) doesn’t like crossing SharePoint web applications, even though the user account I was using had permissions to both web applications.&lt;/p&gt;  &lt;h2&gt;&lt;strong&gt;&lt;strong&gt;&lt;strike&gt;Fix&lt;/strike&gt;…Workaround&lt;/strong&gt;: &lt;/strong&gt;&lt;/h2&gt;  &lt;p&gt;So, to get the form to play nice, I simply deployed my form and associated data sources in a site under Web Application B.&amp;#160; By doing this, my owssvr.dll XML files could reference the appropriate sync-lists correctly and in the same web application.&amp;#160; After I did this, the form worked as advertised and I simply changed all of the applicable links to point to the new form location.&lt;/p&gt;  &lt;p&gt;I realize that this is a fairly unique scenario, but I think there are a couple of important takeaways.&amp;#160; First of all, for users that are running into the blank-white IE screen when using owssvr.dll, hopefully this post helps you in your test cases by trying the method after removing lookup columns.&amp;#160; And Second, for those who might be considering/trying to get InfoPath Browser Forms to cross web applications, realize that you may have to somehow provide a simplified version of your list-data.&amp;#160; &lt;/p&gt;  &lt;p&gt;At the end of the day, the form worked as advertised, and the correct columns were returned (and ordered).&amp;#160; &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.rightpoint.com/community/aggbug.aspx?PostID=2814" width="1" height="1"&gt;</content><author><name>jeremyw</name><uri>http://www.rightpoint.com/community/members/jeremyw/default.aspx</uri></author><category term="SharePoint 2007" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/SharePoint+2007/default.aspx" /><category term="MOSS" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/MOSS/default.aspx" /><category term="Office 2010" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/Office+2010/default.aspx" /><category term="Tag" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/Tag/default.aspx" /><category term="InfoPath" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/InfoPath/default.aspx" /></entry><entry><title>Server Tags within Sharepoint 2010 v4.master</title><link rel="alternate" type="text/html" href="/community/blogs/viewpoint/archive/2010/08/05/server-tags-within-sharepoint-2010-v4-master.aspx" /><id>/community/blogs/viewpoint/archive/2010/08/05/server-tags-within-sharepoint-2010-v4-master.aspx</id><published>2010-08-05T17:33:00Z</published><updated>2010-08-05T17:33:00Z</updated><content type="html">&lt;p&gt;Just got done creating my first Masterpage for Sharepoint 2010 and I thought I would outline some of the new server tags I discovered in v4.master.&amp;nbsp; V4.master refers to &amp;quot;Version 4 UI&amp;quot; and is the default 2010 master which includes all the new bells and whistles including the Ribbon.&lt;br /&gt;&lt;br /&gt;If you are looking to maintain the look and feel of a 2007 masterpage default.master is also included within each team site.&amp;nbsp; This supports the standard 2007 look and feel known as the &amp;quot;Version 3&amp;quot; User Interface.&lt;/p&gt;
&lt;p&gt;Starting with the &amp;lt;head&amp;gt; tag you will notice the following javascript variable.&amp;nbsp; This tag is needed to kickoff the Sharepoint Ribbon in the version 4 UI.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var _fV4UI = true;&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;There are four Server Controls necessary to render the Ribbon:&lt;/p&gt;
&lt;p&gt;These two tags go inside &amp;lt;head&amp;gt; tag&lt;/p&gt;
&lt;p&gt;&lt;i&gt;1. &amp;lt;SharePoint:SPPageManager runat=&amp;quot;server&amp;quot;/&amp;gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;2. &amp;lt;SharePoint:ScriptLink language=&amp;quot;javascript&amp;quot; name=&amp;quot;core.js&amp;quot; OnDemand=&amp;quot;true&amp;quot; runat=&amp;quot;server&amp;quot;/&amp;gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;ScriptManager is placed immediately after the &amp;lt;Form&amp;gt; tag&lt;/p&gt;
&lt;p&gt;&lt;i&gt;3. &amp;lt;asp:ScriptManager id=&amp;quot;ScriptManager&amp;quot; runat=&amp;quot;server&amp;quot; EnablePageMethods=&amp;quot;false&amp;quot; EnablePartialRendering=&amp;quot;true&amp;quot; EnableScriptGlobalization=&amp;quot;false&amp;quot; EnableScriptLocalization=&amp;quot;true&amp;quot; /&amp;gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;4.)&amp;lt;SharePoint:SPRibbon&lt;/i&gt;&lt;br /&gt;Places the Ribbon control on the 
page.&amp;nbsp;&amp;nbsp;For more info on the div tags required for the Ribbon placement 
see links at the bottom of this page.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&amp;lt;SharePoint:ULSClientConfig runat=&amp;quot;server&amp;quot;/&amp;gt;&lt;/i&gt;&lt;br /&gt;This control would output the relevant script that enables error reporting.&lt;br /&gt;&lt;i&gt;&lt;br /&gt;&amp;lt;SharePoint:SPShortcutIcon runat=&amp;quot;server&amp;quot; IconUrl=&amp;quot;/_layouts/images/favicon.ico&amp;quot;/&amp;gt;&lt;/i&gt;&lt;br /&gt;Simple tag to output a shortcut icon for your site.&amp;nbsp; The default looks like this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/SPShortcutIcon.gif"&gt;&lt;img src="http://www.rightpoint.com/community/resized-image.ashx/__size/550x0/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/SPShortcutIcon.gif" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&amp;lt;SharePoint:SPHelpPageComponent Visible=&amp;quot;false&amp;quot; runat=&amp;quot;server&amp;quot;/&amp;gt;&lt;/i&gt;&lt;br /&gt;Adds the following script to the page:&lt;br /&gt;&lt;br /&gt;function _registerHelpComponent()&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SP.Ribbon.HelpPageComponent.registerWithPageManager();&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;}&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;ExecuteOrDelayUntilScriptLoaded(_registerHelpComponent, \&amp;quot;sp.ribbon.js\&amp;quot;);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;br /&gt;&amp;lt;SharePoint:SPNoScript runat=&amp;quot;server&amp;quot;/&amp;gt;&lt;/i&gt;&lt;br /&gt;adds the following tag to the page, used in the event javscript is turned off&lt;br /&gt;&amp;lt;div class=&amp;quot;noindex&amp;quot;&amp;gt;You may be trying to access this site from a secured browser on the server. Please enable scripts and reload this page.&amp;lt;/div&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&amp;lt;SharePoint:PopoutMenu&lt;/i&gt;&lt;br /&gt;Container for popup menus used throughout Sharepoint 2010.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;br /&gt;&amp;lt;SharePoint:ListSiteMapPath&lt;/i&gt;&lt;br /&gt;Display breadcrumbs within site, subsites, and libraries.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&amp;lt;SharePoint:SPRibbonPeripheralContent&lt;/i&gt;&lt;br /&gt;Exposes design controls, tagging controls, view state controls, and related design and behaviorial controls for the ribbon user interface. You can use the Location() method to update where the content appears on the page.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;br /&gt;&amp;lt;SharePoint:PageStateActionButton id=&amp;quot;PageStateActionButton&amp;quot; runat=&amp;quot;server&amp;quot; Visible=&amp;quot;false&amp;quot; /&amp;gt;&lt;/i&gt;&lt;br /&gt;Actually.... not really sure what this do-hickey does&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&amp;lt;SharePoint:DeveloperDashboard runat=&amp;quot;server&amp;quot; /&amp;gt;&lt;/i&gt;&lt;br /&gt;The developer dashboard displays information relevant to each page load, including:&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;1. &amp;nbsp;What controls loaded and how long each took to load&lt;br /&gt;&amp;nbsp;&amp;nbsp; 2. Specific database queries executed and the execution time of each&lt;br /&gt;&amp;nbsp;&amp;nbsp; 3. Events that were fired during the page load&lt;br /&gt;&amp;nbsp;&amp;nbsp; 4. Order of the page lifecycle and time during each stage &lt;br /&gt;&lt;br /&gt;&lt;i&gt;&amp;lt;div id=&amp;quot;DeveloperDashboard&amp;quot; class=&amp;quot;ms-developerdashboard&amp;quot; /&amp;gt;&lt;/i&gt;&lt;br /&gt;Actual location of dashboard&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&amp;lt;Sharepoint:DeveloperDashboardLauncher&lt;/i&gt;&lt;br /&gt;Displays an icon to launch the developer dashboard if active.&amp;nbsp; You can activate the developer dashboard either through stsadm or code.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;1. stsadm:&amp;nbsp; STSADM &amp;ndash;o setproperty &amp;ndash;pn developer-dashboard &amp;ndash;pv OnDemand&lt;br /&gt;&amp;nbsp;2. code:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SPWebService cs = SPWebService.ContentService;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cs.DeveloperDashboardSettings.DisplayLevel = SPDeveloperDashboardLevel.On;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cs.DeveloperDashboardSettings.Update();&lt;br /&gt;&amp;nbsp;3. If you enable the dashboard but remove the Launcher Icon you can still launch it by appending the querystring: &amp;quot;?DeveloperDashboard=true&amp;quot;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&amp;lt;SharePoint:UIVersionedContent UIVersion=&amp;quot;3&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;&lt;/i&gt;&lt;br /&gt;Indicates UI version of encapsulated content.&amp;nbsp; Content that does not match the UI version is not rendered.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;References:&lt;br /&gt;&lt;br /&gt;This article outlines exactly which placeholder and classes to be aware of when upgrading an Existing Master Page to the SharePoint Foundation Master Page&lt;br /&gt;&lt;a target="_blank" title="http://msdn.microsoft.com/en-us/library/ee539981.aspx" href="http://msdn.microsoft.com/en-us/library/ee539981.aspx"&gt;http://msdn.microsoft.com/en-us/library/ee539981.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;NightAndDay.Master&lt;br /&gt;&lt;a target="_blank" title="http://msdn.microsoft.com/en-us/library/ff625186.aspx" href="http://msdn.microsoft.com/en-us/library/ff625186.aspx"&gt;http://msdn.microsoft.com/en-us/library/ff625186.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Customizing Ribbon positioning&lt;br /&gt;&lt;a target="_blank" title="http://www.facebook.com/notes/microsoft-sharepoint-server-2010/customizing-ribbon-positioning-in-sharepoint-2010-master-pages/440358734744" href="http://www.facebook.com/notes/microsoft-sharepoint-server-2010/customizing-ribbon-positioning-in-sharepoint-2010-master-pages/440358734744"&gt;http://www.facebook.com/notes/microsoft-sharepoint-server-2010/customizing-ribbon-positioning-in-sharepoint-2010-master-pages/440358734744&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Ribbon Customization: Changing Placement, Look and Behavior&lt;br /&gt;&lt;a target="_blank" title="http://styledpoint.com/blog/ribbon-customization-changing-placement-look-and-behavior/" href="http://styledpoint.com/blog/ribbon-customization-changing-placement-look-and-behavior/"&gt;http://styledpoint.com/blog/ribbon-customization-changing-placement-look-and-behavior/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;SharePoint 2010 &amp;ndash; Enable &amp;amp; using Developer Dashboard&lt;br /&gt;&lt;a target="_blank" title="http://blogs.technet.com/b/patrick_heyde/archive/2009/11/16/sharepoint-2010-enable-using-developer-dashboard.aspx" href="http://blogs.technet.com/b/patrick_heyde/archive/2009/11/16/sharepoint-2010-enable-using-developer-dashboard.aspx"&gt;http://blogs.technet.com/b/patrick_heyde/archive/2009/11/16/sharepoint-2010-enable-using-developer-dashboard.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Working with SharePoint 2010 Foundation Master Pages&lt;br /&gt;&lt;a target="_blank" title="http://blog.allyis.com/blog/bid/48102/Working-with-SharePoint-2010-Foundation-Master-Pages" href="http://blog.allyis.com/blog/bid/48102/Working-with-SharePoint-2010-Foundation-Master-Pages"&gt;http://blog.allyis.com/blog/bid/48102/Working-with-SharePoint-2010-Foundation-Master-Pages&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;TechNet&lt;br /&gt;&lt;a target="_blank" title="http://social.technet.microsoft.com/Forums/en-US/category/sharepoint2010" href="http://social.technet.microsoft.com/Forums/en-US/category/sharepoint2010"&gt;http://social.technet.microsoft.com/Forums/en-US/category/sharepoint2010&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.rightpoint.com/community/aggbug.aspx?PostID=2813" width="1" height="1"&gt;</content><author><name>ssamnadda</name><uri>http://www.rightpoint.com/community/members/ssamnadda/default.aspx</uri></author><category term="SharePoint 2010" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/SharePoint+2010/default.aspx" /></entry><entry><title>Umbraco: Resolving the “Opening edit screen is very slow when macros are present” issue</title><link rel="alternate" type="text/html" href="/community/blogs/viewpoint/archive/2010/07/27/umbraco-resolving-the-opening-edit-screen-is-very-slow-when-macros-are-present-issue.aspx" /><id>/community/blogs/viewpoint/archive/2010/07/27/umbraco-resolving-the-opening-edit-screen-is-very-slow-when-macros-are-present-issue.aspx</id><published>2010-07-27T15:30:01Z</published><updated>2010-07-27T15:30:01Z</updated><content type="html">&lt;p&gt;On our shared Umbraco development server, we were having some performance issues with the backend that neither I nor the other developer on the project were experiencing with the same code/document types/macros on our local system.&amp;#160; Even backing up the shared system and restoring to our local machines didn’t reproduce the problem.&amp;#160; When we’d open up certain pages for editing, it would take a *very* long time for the server to send back the editContent.aspx page (about 35s as measured by Firebug).&amp;#160; Other pages didn’t have the issue. A quick comparison of the pages showed one obvious difference – the slow page had a macro in a content block, the fast page didn’t.&amp;#160; After checking a few things (umbracoLog table in the DB, CPU usage), it was obvious the server wasn’t pegging it’s CPU or anything like that, and the SQL Server process wasn’t going crazy either (which might indicate an excessive number of queries running), so on a whim, I thought I’d dig into the code and see what happens before that “No macro content available for WYSIWYG editing” message is generated.&lt;/p&gt;  &lt;p&gt;Now, I could just download the source code for Umbraco and dig in a bit, but I started my investigation on my evening train ride home, where I don’t have Internet access, and I didn’t already have a copy of the code on my machine.&amp;#160; So, I pulled up the secret weapon of a .Net developer’s arsenal, &lt;a href="http://www.red-gate.com/products/reflector/" target="_blank"&gt;Reflector&lt;/a&gt;.&amp;#160; After a search for the message above, I was led to umbraco.macro.MacroContentByHttp, which uses Request.ServerVariables[“SERVER_NAME”] to find out it’s name and makes a request to /macroResultWrapper.aspx to get the contents of the macro:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.rightpointconsulting.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_7BA7E0EB.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.rightpointconsulting.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb_5F00_4C75F554.png" width="521" height="144" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Could this be our culprit?&amp;#160; I logged onto the server and tried to access the site via the name we were using.&amp;#160; Sure enough, timeout…&amp;#160; So I try pinging the hostname we’re using from the server itself – same result – no response.&amp;#160; I added a host entry for that name using 127.0.0.1 as the IP address, tried hitting the server again from the browser, and sure enough, success.&amp;#160; I cycled IIS, loaded up the backend of the shared dev environment from my client machine, and went to edit a page with a macro – 3 seconds to load. &lt;strong&gt;Much&lt;/strong&gt; better.&amp;#160; Apparently, due to firewall issues on our hosting environment, the server can’t access itself via it’s ‘public’ IP, only via the private IP, but DNS still resolves it’s name to the public IP.&lt;/p&gt;  &lt;p&gt;The lesson here: with Umbraco, make sure your server can reach itself using the name you’re using to access it.&amp;#160; Ie. if you use a hosts entry to map myshareddevserver.local to the IP address of your shared dev server in the office and set up an Umbraco instance in IIS on that server, make sure you put the same hosts entry on the dev server too, or you’ll have (at least) this issue.&lt;/p&gt;  &lt;p&gt;Note: this may be changed/resolved in Umbraco 4.5 (released last month) – I haven’t worked with that version yet.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.rightpoint.com/community/aggbug.aspx?PostID=2812" width="1" height="1"&gt;</content><author><name>jrupp</name><uri>http://www.rightpoint.com/community/members/jrupp/default.aspx</uri></author><category term=".NET" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/.NET/default.aspx" /><category term="Umbraco" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/Umbraco/default.aspx" /></entry><entry><title>SQL Server Geospatial Part 3 – Visualizing Spatial Data in SSRS</title><link rel="alternate" type="text/html" href="/community/blogs/viewpoint/archive/2010/07/24/sql-server-geospatial-part-3-visualizing-spatial-data-in-ssrs.aspx" /><id>/community/blogs/viewpoint/archive/2010/07/24/sql-server-geospatial-part-3-visualizing-spatial-data-in-ssrs.aspx</id><published>2010-07-25T00:18:00Z</published><updated>2010-07-25T00:18:00Z</updated><content type="html">&lt;p&gt;In the &lt;a target="_blank" href="http://www.rightpoint.com/community/blogs/viewpoint/archive/2010/04/19/sql-server-geospatial-part-2-the-geography-data-type.aspx"&gt;previous post&lt;/a&gt;, we finished by calculating population density for the city of Chicago. Today we will continue to build on that same dataset and will look at a cool way to visualize our spatial data using SSRS in SQL Server 2008 R2. If you haven&amp;rsquo;t done so yet, run through the tutorials in posts &lt;a target="_blank" href="http://www.rightpoint.com/community/blogs/viewpoint/archive/2010/03/29/a-brief-introduction-to-sql-server-2008-geospatial.aspx"&gt;one&lt;/a&gt; and &lt;a target="_blank" href="http://www.rightpoint.com/community/blogs/viewpoint/archive/2010/04/19/sql-server-geospatial-part-2-the-geography-data-type.aspx"&gt;two&lt;/a&gt; to bring your database up to speed.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;First of all, let&amp;rsquo;s look at an interesting way to join spatial datasets, as well as building a little on the knowledge from the &lt;a target="_blank" href="http://www.rightpoint.com/community/blogs/viewpoint/archive/2010/04/19/sql-server-geospatial-part-2-the-geography-data-type.aspx"&gt;last post&lt;/a&gt; about geography vs. geometry data. If you remember my comments about spatial reference systems, you&amp;rsquo;ll remember that the only way to truly measure distance is to use the geography type, which maps to three-dimensional space. However, you&amp;rsquo;ll also remember that the geography type supports far less functions that the geometry type. One of the convenient, and missing, functions from the geometry type is STCentroid() which returns a point at the center of mass of any shape. There&amp;rsquo;s a good explanation &lt;a target="_blank" href="http://www.bostongis.com/PrinterFriendly.aspx?content_name=sql2008_tut02"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Thankfully with some casting back and forth, we can find the center points of two geometry objects, and calculate distance between them in meters. The comments in the query below illustrate what&amp;rsquo;s happening. Of note is also the join between the two datasets, you&amp;rsquo;ll find yourself using this type of join over and over when working with spatial data, whether you&amp;rsquo;re calculating distances or overlaps, ranking overlaps to find primary geographical relationships between towns and zip codes, the list goes on.&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height:normal;margin-bottom:0pt;mso-layout-grid-align:none;"&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:blue;font-size:10pt;mso-no-proof:yes;"&gt;select&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;font-size:10pt;mso-no-proof:yes;"&gt; places&lt;span style="color:gray;"&gt;.&lt;/span&gt;NAME       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:gray;font-size:10pt;mso-no-proof:yes;"&gt;,&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;font-size:10pt;mso-no-proof:yes;"&gt;referenceplace&lt;span style="color:gray;"&gt;.&lt;/span&gt;name       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:gray;font-size:10pt;mso-no-proof:yes;"&gt;,&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;font-size:10pt;mso-no-proof:yes;"&gt;places&lt;span style="color:gray;"&gt;.&lt;/span&gt;geom       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:gray;font-size:10pt;mso-no-proof:yes;"&gt;,&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;font-size:10pt;mso-no-proof:yes;"&gt;pops&lt;span style="color:gray;"&gt;.&lt;/span&gt;POP_2008       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:green;font-size:10pt;mso-no-proof:yes;"&gt;/*      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:green;font-size:10pt;mso-no-proof:yes;"&gt;Find the distance between the centroid of the place and      &lt;br /&gt;Chicago&amp;#39;s centroid. &lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:green;font-size:10pt;mso-no-proof:yes;"&gt;Both need to be converted to geometry      &lt;br /&gt;to find the centroid and then this point &lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:green;font-size:10pt;mso-no-proof:yes;"&gt;is converted      &lt;br /&gt;back to geography       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:green;font-size:10pt;mso-no-proof:yes;"&gt;*/      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:gray;font-size:10pt;mso-no-proof:yes;"&gt;,&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;font-size:10pt;mso-no-proof:yes;"&gt;dbo&lt;span style="color:gray;"&gt;.&lt;/span&gt;MakeValidGeographyFromText      &lt;br /&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;places&lt;span style="color:gray;"&gt;.&lt;/span&gt;geom&lt;span style="color:gray;"&gt;.&lt;/span&gt;MakeValid&lt;span style="color:gray;"&gt;().&lt;/span&gt;STCentroid&lt;span style="color:gray;"&gt;().&lt;/span&gt;STAsText&lt;span style="color:gray;"&gt;(),&lt;/span&gt;4326&lt;span style="color:gray;"&gt;)        &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:gray;font-size:10pt;mso-no-proof:yes;"&gt;.&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;font-size:10pt;mso-no-proof:yes;"&gt;STDistance&lt;span style="color:gray;"&gt;(&lt;/span&gt;dbo&lt;span style="color:gray;"&gt;.&lt;/span&gt;MakeValidGeographyFromText      &lt;br /&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;referenceplace&lt;span style="color:gray;"&gt;.&lt;/span&gt;geom&lt;span style="color:gray;"&gt;.&lt;/span&gt;MakeValid&lt;span style="color:gray;"&gt;().&lt;/span&gt;STCentroid&lt;span style="color:gray;"&gt;().&lt;/span&gt;STAsText&lt;span style="color:gray;"&gt;(),&lt;/span&gt;4326&lt;span style="color:gray;"&gt;))&lt;/span&gt;       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:blue;font-size:10pt;mso-no-proof:yes;"&gt;as&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;font-size:10pt;mso-no-proof:yes;"&gt; CentroidDistanceFromChicagoCentroid      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:green;font-size:10pt;mso-no-proof:yes;"&gt;/*      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:green;font-size:10pt;mso-no-proof:yes;"&gt;This finds the population density per square mile. See last      &lt;br /&gt;post for an &lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:green;font-size:10pt;mso-no-proof:yes;"&gt;explanation. The large number represents the      &lt;br /&gt;number of square meters in a &lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:green;font-size:10pt;mso-no-proof:yes;"&gt;square mile.      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:green;font-size:10pt;mso-no-proof:yes;"&gt;*/      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:gray;font-size:10pt;mso-no-proof:yes;"&gt;,&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:fuchsia;font-size:10pt;mso-no-proof:yes;"&gt;convert&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:gray;font-size:10pt;mso-no-proof:yes;"&gt;(&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:blue;font-size:10pt;mso-no-proof:yes;"&gt;int&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:gray;font-size:10pt;mso-no-proof:yes;"&gt;,&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;font-size:10pt;mso-no-proof:yes;"&gt;pops&lt;span style="color:gray;"&gt;.&lt;/span&gt;POP_2008       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:gray;font-size:10pt;mso-no-proof:yes;"&gt;/&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:blue;font-size:10pt;mso-no-proof:yes;"&gt; &lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:gray;font-size:10pt;mso-no-proof:yes;"&gt;(&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;font-size:10pt;mso-no-proof:yes;"&gt;dbo&lt;span style="color:gray;"&gt;.&lt;/span&gt;MakeValidGeographyFromText      &lt;br /&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;places&lt;span style="color:gray;"&gt;.&lt;/span&gt;geom&lt;span style="color:gray;"&gt;.&lt;/span&gt;STAsText&lt;span style="color:gray;"&gt;(),&lt;/span&gt;4326&lt;span style="color:gray;"&gt;).&lt;/span&gt;STArea&lt;span style="color:gray;"&gt;()&lt;/span&gt; &lt;span style="color:gray;"&gt;/&lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;2589988.11&lt;span style="color:gray;"&gt;))&lt;/span&gt;       &lt;br /&gt;&lt;span style="color:blue;"&gt;as&lt;/span&gt; PopDensity       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:blue;font-size:10pt;mso-no-proof:yes;"&gt;from&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;font-size:10pt;mso-no-proof:yes;"&gt; tl_2009_17_place &lt;span style="color:blue;"&gt;as&lt;/span&gt; places       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:gray;font-size:10pt;mso-no-proof:yes;"&gt;inner&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;font-size:10pt;mso-no-proof:yes;"&gt; &lt;span style="color:gray;"&gt;join&lt;/span&gt; ILPlacesCensusPops &lt;span style="color:blue;"&gt;as&lt;/span&gt; pops       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:blue;font-size:10pt;mso-no-proof:yes;"&gt;on&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;font-size:10pt;mso-no-proof:yes;"&gt; pops&lt;span style="color:gray;"&gt;.&lt;/span&gt;place &lt;span style="color:gray;"&gt;=&lt;/span&gt; places&lt;span style="color:gray;"&gt;.&lt;/span&gt;PLACEFP       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:green;font-size:10pt;mso-no-proof:yes;"&gt;/*      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:green;font-size:10pt;mso-no-proof:yes;"&gt;This syntax joins the data sets together on distance &amp;lt; 20000      &lt;br /&gt;meters to find towns &lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:green;font-size:10pt;mso-no-proof:yes;"&gt;with a center less than 20 kilometers from      &lt;br /&gt;the center of Chicago. See centroid &lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:green;font-size:10pt;mso-no-proof:yes;"&gt;logic above.      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:green;font-size:10pt;mso-no-proof:yes;"&gt;*/      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:gray;font-size:10pt;mso-no-proof:yes;"&gt;join&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;font-size:10pt;mso-no-proof:yes;"&gt; tl_2009_17_place &lt;span style="color:blue;"&gt;as&lt;/span&gt; referenceplace       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:blue;font-size:10pt;mso-no-proof:yes;"&gt;on&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;font-size:10pt;mso-no-proof:yes;"&gt; dbo&lt;span style="color:gray;"&gt;.&lt;/span&gt;MakeValidGeographyFromText      &lt;br /&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;places&lt;span style="color:gray;"&gt;.&lt;/span&gt;geom&lt;span style="color:gray;"&gt;.&lt;/span&gt;MakeValid&lt;span style="color:gray;"&gt;().&lt;/span&gt;STCentroid&lt;span style="color:gray;"&gt;().&lt;/span&gt;STAsText&lt;span style="color:gray;"&gt;(),&lt;/span&gt;4326&lt;span style="color:gray;"&gt;)        &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:gray;font-size:10pt;mso-no-proof:yes;"&gt;.&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;font-size:10pt;mso-no-proof:yes;"&gt;STDistance&lt;span style="color:gray;"&gt;(&lt;/span&gt;dbo&lt;span style="color:gray;"&gt;.&lt;/span&gt;MakeValidGeographyFromText      &lt;br /&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;referenceplace&lt;span style="color:gray;"&gt;.&lt;/span&gt;geom&lt;span style="color:gray;"&gt;.&lt;/span&gt;MakeValid&lt;span style="color:gray;"&gt;().&lt;/span&gt;STCentroid&lt;span style="color:gray;"&gt;().&lt;/span&gt;STAsText&lt;span style="color:gray;"&gt;(),&lt;/span&gt;4326&lt;span style="color:gray;"&gt;))&lt;/span&gt;       &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:gray;font-size:10pt;mso-no-proof:yes;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;font-size:10pt;mso-no-proof:yes;"&gt; 20000      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;color:blue;font-size:10pt;mso-no-proof:yes;"&gt;where&lt;/span&gt;&lt;span style="font-family:&amp;#39;Courier New&amp;#39;;font-size:10pt;mso-no-proof:yes;"&gt; referenceplace&lt;span style="color:gray;"&gt;.&lt;/span&gt;Name&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color:gray;"&gt;=&lt;/span&gt; &lt;span style="color:red;"&gt;&amp;#39;Chicago&amp;#39;        &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height:115%;font-family:&amp;#39;Courier New&amp;#39;;color:gray;font-size:10pt;mso-no-proof:yes;"&gt;and&lt;/span&gt;&lt;span style="line-height:115%;font-family:&amp;#39;Courier New&amp;#39;;font-size:10pt;mso-no-proof:yes;"&gt; pops&lt;span style="color:gray;"&gt;.&lt;/span&gt;STATENAME &lt;span style="color:gray;"&gt;=&lt;/span&gt; &lt;span style="color:red;"&gt;&amp;#39;Illinois&amp;#39;&lt;/span&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;You&amp;rsquo;ll see that we return a nice little dataset, with population, population density, and distance from Chicago for 49 communities, including Chicago itself.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_37D7953F.png"&gt;&lt;img height="227" width="473" src="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb_5F00_204CBB41.png" alt="image" border="0" title="image" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Now let&amp;rsquo;s see what we can do with our little dataset. I am going to go ahead and assume that you have BIDS installed along with SQL Server 2008 R2, if not you can install the free evaluation from &lt;a target="_blank" href="http://www.microsoft.com/sqlserver/2008/en/us/r2.aspx"&gt;this&lt;/a&gt; site. Fire up Visual Studio, and select &amp;ldquo;File &amp;ndash;&amp;gt; New &amp;ndash;&amp;gt; Project&amp;rdquo;. Select &amp;ldquo;Report Server Project&amp;rdquo; and call your new project GeoExamples.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_4119E65A.png"&gt;&lt;img height="303" width="448" src="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb_5F00_77A7919E.png" alt="image" border="0" title="image" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Add a new report through the solution explorer and call it ChicagoAreaPopulation.rdl.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_285A994A.png"&gt;&lt;img height="178" width="244" src="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb_5F00_15396C9E.png" alt="image" border="0" title="image" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_490162EF.png"&gt;&lt;img height="282" width="467" src="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb_5F00_2BAC0B25.png" alt="image" border="0" title="image" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Right-click &amp;ldquo;Data Sources&amp;rdquo; and select &amp;ldquo;Add Data Source&amp;rdquo;. Connect to your local GeoExamples database.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_786FD1BB.png"&gt;&lt;img height="321" width="599" src="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb_5F00_44C7655D.png" alt="image" border="0" title="image" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Now right-click the data source we just added, and select &amp;ldquo;Add Dataset&amp;rdquo;. Name it ChicagoAreaPopulation and paste in our query from the beginning of this post. It should look like the image below.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_222326E2.png"&gt;&lt;img height="417" width="594" src="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb_5F00_793811D8.png" alt="image" border="0" title="image" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Now right click in the main report area and select &amp;ldquo;Insert &amp;ndash;&amp;gt; Map&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_21F37722.png"&gt;&lt;img height="358" width="435" src="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb_5F00_74FE1446.png" alt="image" border="0" title="image" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Select &amp;ldquo;SQL Server spatial query&amp;rdquo; and click &amp;ldquo;Next.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_539E6EAA.png"&gt;&lt;img height="291" width="396" src="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb_5F00_590CDF4E.png" alt="image" border="0" title="image" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Select the dataset we just created and click &amp;ldquo;Next.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_30FA302F.png"&gt;&lt;img height="298" width="405" src="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb_5F00_61AD37DA.png" alt="image" border="0" title="image" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt;&amp;nbsp; &lt;/p&gt;
&lt;p&gt;Now this SSRS report starts getting cool. Make sure the geom field is selected as the Spatial field, select &amp;ldquo;Add a Bing Maps layer&amp;rdquo; and choose &amp;ldquo;Aerial&amp;rdquo; as the type. Leave all other default options selected and click next.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_197F7BFE.png"&gt;&lt;img height="348" width="473" src="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb_5F00_2A3700DF.png" alt="image" border="0" title="image" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt; On the next pane, select &amp;ldquo;Color Analytical Map&amp;rdquo; as the map type and go to the next screen.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_52863333.png"&gt;&lt;img height="349" width="474" src="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb_5F00_109F4DE5.png" alt="image" border="0" title="image" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;We are going to add a new dataset using the same query. Really you should be writing different queries for the spatial data and the analytical data but for this example using the same query in both places will work. If you use the same dataset in both places it will only allow you to display aggregates of our analytical field (population density) so that won&amp;rsquo;t do. This is also a good time to point out that for any type of production environment you&amp;rsquo;ll want to materialize all the spatial calculations, running them at execution time is not recommended. Select &amp;ldquo;Add a dataset that includes fields that relate to the spatial data that you chose earlier&amp;rdquo; and hit &amp;ldquo;Next&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_64161DFE.png"&gt;&lt;img height="349" width="474" src="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb_5F00_4DE002AC.png" alt="image" border="0" title="image" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Paste in our same query and hit &amp;ldquo;Next.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_52E2405B.png"&gt;&lt;img height="348" width="473" src="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb_5F00_108F2818.png" alt="image" border="0" title="image" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Accept all the defaults on this page (after all, we&amp;rsquo;re using the same query twice) and hit &amp;ldquo;Next.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_2E8D360C.png"&gt;&lt;img height="363" width="455" src="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb_5F00_7933FDD9.png" alt="image" border="0" title="image" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Now, leave the theme &amp;ldquo;Generic&amp;rdquo;, leave the color rule &amp;ldquo;Green-Yellow-Red&amp;rdquo;, select #PopDensity as the visualization field, Select &amp;ldquo;Display labels&amp;rdquo; and choose #NAME (this second one, in all caps), and hit &amp;ldquo;Finish.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_4995DF4D.png"&gt;&lt;img height="365" width="458" src="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb_5F00_26193AE8.png" alt="image" border="0" title="image" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Edit the map title to read &amp;ldquo;Chicago Area Population Density&amp;rdquo; and toy around with the font sizes to display more place names. This is the result! A pretty little map showing population density per square mile for towns within 20km of Chicago. All based on free data, and using technologies you already own.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_0B006BDA.png"&gt;&lt;img height="438" width="473" src="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb_5F00_4B92927C.png" alt="image" border="0" title="image" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;There are many other ways to unlock the power of your spatial data, SSRS is just one of many outlets. Stay tuned for more in future posts!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.rightpoint.com/community/aggbug.aspx?PostID=2811" width="1" height="1"&gt;</content><author><name>jsaunders</name><uri>http://www.rightpoint.com/community/members/jsaunders/default.aspx</uri></author><category term="BI" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/BI/default.aspx" /><category term="SQL Server 2008" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/SQL+Server+2008/default.aspx" /><category term="Geospatial" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/Geospatial/default.aspx" /><category term="Spatial" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/Spatial/default.aspx" /><category term="Reporting Services" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/Reporting+Services/default.aspx" /><category term="SSRS" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/SSRS/default.aspx" /></entry><entry><title>SharePoint Search: The Difference Between RowCount And TotalRows</title><link rel="alternate" type="text/html" href="/community/blogs/viewpoint/archive/2010/07/19/sharepoint-search-the-difference-between-rowcount-and-totalrows.aspx" /><id>/community/blogs/viewpoint/archive/2010/07/19/sharepoint-search-the-difference-between-rowcount-and-totalrows.aspx</id><published>2010-07-19T18:17:00Z</published><updated>2010-07-19T18:17:00Z</updated><content type="html">&lt;p class="Text"&gt;I just wanted to post a real quick note about something that finally dawned on me regarding the SharePoint 2007 search API. There are two properties in the &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/microsoft.office.server.search.query.resulttable.aspx" class="Link"&gt;ResultTable&lt;/a&gt; object that I&amp;#39;ve been using interchangeably, as the documentation on MSDN does little to discern them from one another. These are &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/microsoft.office.server.search.query.resulttable.rowcount.aspx" class="Link"&gt;RowCount&lt;/a&gt; and &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/microsoft.office.server.search.query.resulttable.totalrows.aspx" class="Link"&gt;TotalRows&lt;/a&gt;. &lt;/p&gt;
&lt;p class="Text"&gt;Turns out, the way I usually customize my queries also technically didn&amp;#39;t discern them. I&amp;#39;m working on a paged search result viewer control. The way it worked previously was that it got all of the data from a single query and chopped up the results into pages client side. Using Silverlight, these pages could then be navigated via prettily-animated transitions. With this style, since we are interested in ALL of the results in the query, RowCount is always the same as TotalRows. &lt;/p&gt;
&lt;p class="Text"&gt;As a performance enhancement, we punted the animations, and instead only started requesting a certain block of results. Now, each query gives us results X though Y of Z. When you tell SharePoint to only give you a certain number of results (Y) starting from a particular index (X), you actually get (Z) for free! So if you are doing paged searches, you don&amp;#39;t need to worry about doing an &amp;quot;empty&amp;quot; search (in terms of columns) to just get the total number of rows; the API is smart enough give us this number without actually doing the work of calculating all the corresponding results. &lt;/p&gt;
&lt;p class="Text"&gt;So: &lt;span class="Bold"&gt;RowCount&lt;/span&gt; is the actual number of search results, based on the &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/microsoft.office.server.search.query.query.startrow.aspx" class="Link"&gt;StartRow&lt;/a&gt; and &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/microsoft.office.server.search.query.query.rowlimit.aspx" class="Link"&gt;RowLimit&lt;/a&gt; properties. &lt;span class="Bold"&gt;TotalRows&lt;/span&gt; is therefore the actual about of search items that exist in the index that correspond to their query, irrespective to any paging trimming. &lt;/p&gt;
&lt;p class="Text"&gt;Here&amp;#39;s a quick code block to demonstrate how to use these properties: &lt;/p&gt;
&lt;p class="Text"&gt;
&lt;table cellpadding="0" cellspacing="0" class="CodeLayout"&gt;
&lt;tbody&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellTopLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;
&lt;div class="CodeContainer"&gt;
&lt;div class="CodeLayout"&gt;&lt;ol class="Code"&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;private&lt;/span&gt; &lt;span class="ClassName"&gt;ResultTable&lt;/span&gt; RunQuery&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;string&lt;/span&gt; text&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;int&lt;/span&gt; rowLimit&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;int&lt;/span&gt; startIndex&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//initialization&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;FullTextSqlQuery&lt;/span&gt; query &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;FullTextSqlQuery&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;ServerContext&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Current&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//build query&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;query&lt;span class="Operator"&gt;.&lt;/span&gt;RowLimit &lt;span class="Operator"&gt;=&lt;/span&gt; rowLimit&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;query&lt;span class="Operator"&gt;.&lt;/span&gt;QueryText &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Constant"&gt;&amp;quot;(query)&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;query&lt;span class="Operator"&gt;.&lt;/span&gt;TrimDuplicates &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;true&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;query&lt;span class="Operator"&gt;.&lt;/span&gt;StartRow &lt;span class="Operator"&gt;=&lt;/span&gt; startIndex &lt;span class="Operator"&gt;*&lt;/span&gt; rowLimit&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;query&lt;span class="Operator"&gt;.&lt;/span&gt;ResultTypes &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;ResultType&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;RelevantResults&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//return&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;return&lt;/span&gt; query&lt;span class="Operator"&gt;.&lt;/span&gt;Execute&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;[&lt;/span&gt;&lt;span class="ClassName"&gt;ResultType&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;RelevantResults&lt;span class="Operator"&gt;]&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellBottomLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;Have fun! &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.rightpoint.com/community/aggbug.aspx?PostID=2810" width="1" height="1"&gt;</content><author><name>cdomino</name><uri>http://www.rightpoint.com/community/members/cdomino/default.aspx</uri></author></entry><entry><title>The SUESS Lifecycle: Stage 1 - Upload</title><link rel="alternate" type="text/html" href="/community/blogs/viewpoint/archive/2010/07/17/the-suess-lifecycle-stage-1-upload.aspx" /><id>/community/blogs/viewpoint/archive/2010/07/17/the-suess-lifecycle-stage-1-upload.aspx</id><published>2010-07-17T04:57:00Z</published><updated>2010-07-17T04:57:00Z</updated><content type="html">&lt;p class="Text"&gt;
&lt;p class="Text"&gt;
&lt;p class="Text"&gt;&lt;span class="Underline"&gt;The SUESS Series&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;&lt;a target="_blank" href="http://chrisdomino.com/blog/post/SUESS-A-Silverlight-Uploader-Encoder-and-Smooth-Streamer" class="Link"&gt;Introduction&lt;/a&gt; &lt;br /&gt;&lt;span class="Bold"&gt;Stage 1 - Upload&lt;/span&gt; &lt;br /&gt;&lt;a target="_blank" href="http://chrisdomino.com/blog/post/The-SUESS-Lifecycle-Stage-2-Encode" class="Link"&gt;Stage 2 - Encode&lt;/a&gt; &lt;br /&gt;&lt;a target="_blank" href="http://chrisdomino.com/blog/post/The-SUESS-Lifecycle-Stage-3-SmoothStreaming" class="Link"&gt;Stage 3 - SmoothStreaming&lt;/a&gt; &lt;/p&gt;
&lt;p class="Text"&gt;Our in-depth media adventure begins, well, at the beginning of the SUESS &amp;quot;lifecycle&amp;quot; with Uploading. This stage contains two sub-components: the Uploader Silverlight control, and the WCF service on the Web Server that facilitates the file upload process. The only prerequisite required here is to have your data tier (Component 3) in place (which can simply be a folder on the Web Server). &lt;/p&gt;
&lt;p class="Text"&gt;Of course, there is nothing new about a file upload control; it&amp;#39;s been in HTML longer than I have. Over the years, I&amp;#39;ve seen a lot of modifications to the familiar read only textbox and &amp;quot;Browse...&amp;quot; button to get the effects people are starting to expect in this whole Web 2.0 craze: progress bars, client-side file type filtering, large file support, etc. &lt;/p&gt;
&lt;p class="Text"&gt;To achieve these nice features, a lot of magic needs to happen client side. If you&amp;#39;ve read anything I&amp;#39;ve written before, you&amp;#39;ll know that I don&amp;#39;t consider AJAX to be magic; it&amp;#39;s voodoo at best compared to the wizardry of Silverlight. The argument remains the Silverlight needs to be installed on the client&amp;#39;s machine while AJAX comes down for free from the server along with the rest of the page. However, when it comes to programmatic benefits such as a first-class development experience (IntelliSense, compilation, UI designer, etc.), robustness of code, and extent of possibilities of what you can build, you cannot argue against Silverlight. &lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Rant"&gt;&amp;lt;RANT&amp;gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Now don&amp;#39;t get me wrong: AJAX is a really cute technology that has a lot of niche uses. The difference, as far as I&amp;#39;m concerned, falls in the mindset of the developer. Take animating progress bars for example. In AJAX/HTML, you&amp;#39;d need to arrange a few nested divs, set all their widths and background colors, and then when the upload mechanism reports progress, update the width of the inner-most div. To me, that&amp;#39;s not really a true &lt;span class="Italic"&gt;progress bar&lt;/span&gt;; it&amp;#39;s HTML kludginess. &lt;/p&gt;
&lt;p class="Text"&gt;Now, in Silverlight, you see, you literally just &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/cc189090(VS.95).aspx" class="Link"&gt;animate&lt;/a&gt; a &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.windows.controls.progressbar(VS.95).aspx" class="Link"&gt;ProgressBar&lt;/a&gt;. &lt;/p&gt;
&lt;p class="Text"&gt;THAT&amp;#39;S the point. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;span class="Rant"&gt;&amp;lt;/RANT&amp;gt;&lt;/span&gt; &lt;/p&gt;
&lt;p class="Text"&gt;The example Uploader control I&amp;#39;ll show you shortly lacks all the bells and whistles with which it could be adorned to truly make the life of a content manager much better. These features include drag and drop support, multi-file uploads, a slick UI, etc. However, the big ones, like progress bars and cancellation, will demonstrate how uploading large files (such as media) can be a pleasant experience for a user. &lt;/p&gt;
&lt;p class="Text"&gt;First of all, what does it look like? Well, not much, unfortunately. A pretty admin UI was not a requirement of the project through which I came up with SUESS, since this was all back end functionality. But here&amp;#39;s what we have: &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;p class="Image"&gt;&lt;img src="http://chrisdomino.com/content/images/The-SUESS-Lifecycle-Stage-1-Upload/Uploader.png" class="Image" alt="" /&gt;&lt;/p&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;The title and description fields are watermarked textboxes with some gradient borders to implement the comps of the project. I really don&amp;#39;t want to bore you with the details of the code that updates the visual state of the UI; it&amp;#39;s hard to make hiding buttons and displaying error messages sexy. You&amp;#39;ll be able to download SUESS in its entirety and comb through all the details yourself. Instead, let&amp;#39;s take a quick trip through it, and then dive into the cool stuff. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;The only input we actually need from the user is the file itself. Depending on your data tier, you could accept more metadata. (SUESS was actually born into SharePoint, so the sky was the limit for metadata.) But for now, we&amp;#39;ll just have two optional textboxes for the name of the media and a description. If the name is blank, we&amp;#39;ll use the file name. (As you&amp;#39;ll see later, with the way Encoder outputs its SmoothStreaming formatted files, we don&amp;#39;t have to worry about filename collisions; it&amp;#39;s only a consideration during uploading.) &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Next we have the &amp;quot;Encoding Quality&amp;quot; drop down. Once again, this is optional, and included only as an example to show another aspect of what you can do with SUESS in terms of explicitly controlling a myriad of Encoder options. (You&amp;#39;ll see what I&amp;#39;m talking about in the Encoding post about SUESS.) These are hard-coded (barf, I know) values mimicking the Video Complexity (no documentation available) enumeration in the Encoder SDK. This is the best we can do to this extent, since we can&amp;#39;t actually reference the DLL in our Silverlight project and reflect each enum member. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;The purpose of including this in the example Uploader is to allow the user the ability to &amp;quot;throttle&amp;quot; the encoding process, which, as previously mentioned, could be very processor (and, of course, time) intensive. Unfortunately, I don&amp;#39;t have a lot of metrics regarding just how much quality is sacrificed in terms of time taken to encode. However, I can say that media encoded with the highest quality settings indeed takes much longer than with the lowest. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Finally, we have the media itself. Silverlight gives us the &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.windows.controls.openfiledialog(VS.95).aspx" class="Link"&gt;OpenFileDialog&lt;/a&gt; control that is more or less identical to what you&amp;#39;d find in Windows Forms. The one immediate advantage it gives us over what is available in the HTML version is the ability to filter the file types (by extension) that the user is allowed to select in the dialog. This not only gives us a more elegant user experience (since we can &amp;quot;label&amp;quot; our filter with something like &amp;quot;Media Files,&amp;quot;) but also makes the development much easier, since we don&amp;#39;t have to go through the &amp;quot;hand slapping&amp;quot; input validation experience. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Rant"&gt;&amp;lt;RANT&amp;gt;&lt;/span&gt; &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Back in the HTML/AJAX version of a file upload control, if you need to enforce a certain type (or types) of file(s), the best you can do is inspect the file the user selected, check its extension, and display an error message, forcing the user to have to go through the entire exercise again. Instead, with Silverlight, we can simply hide invalid file extensions in the folders they navigate within the dialog via the &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.windows.controls.openfiledialog.filter(v=VS.95).aspx" class="Link"&gt;Filter&lt;/a&gt; property. This probably doesn&amp;#39;t seem like a big deal, but I think it&amp;#39;s huge: small UX improvements like these are what Web 2.0 is all about; with Silverlight, you are really using an application, not just a webpage. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&lt;span class="Rant"&gt;&amp;lt;/RANT&amp;gt;&lt;/span&gt; &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Let&amp;#39;s talk about a few of the more interesting code samples. The first one simply sets the OpenFileDialog to only allow the files that Encoder supports to be uploaded. It also has a hard coded value (which can easily be made to be configurable) to disallow files over 1GB (purely for sanity purposes). &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;table cellpadding="0" cellspacing="0" class="CodeLayout"&gt;
&lt;tbody&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellTopLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;
&lt;div class="CodeContainer"&gt;
&lt;div class="CodeLayout"&gt;&lt;ol class="Code"&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;private&lt;/span&gt; &lt;span class="Keyword"&gt;void&lt;/span&gt; btnSelectFile_Click&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;object&lt;/span&gt; sender&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="ClassName"&gt;RoutedEventArgs&lt;/span&gt; e&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//initialization&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;OpenFileDialog&lt;/span&gt; ofd &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;OpenFileDialog&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//show open file dialog&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;ofd&lt;span class="Operator"&gt;.&lt;/span&gt;Multiselect &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;false&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;ofd&lt;span class="Operator"&gt;.&lt;/span&gt;Filter &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Constant"&gt;&amp;quot;Media Files|*.asf;*.avi;*.bmp;*.gif;*.jpg;*.jpeg;*.m2t;*.m2ts;*.mov;*.mp4;*.mpeg;*.mpg;*.png;*.tif;*.tiff;*.ts;*.vob;*.wmv;&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;bool&lt;/span&gt;&lt;span class="Operator"&gt;?&lt;/span&gt; fileSelected &lt;span class="Operator"&gt;=&lt;/span&gt; ofd&lt;span class="Operator"&gt;.&lt;/span&gt;ShowDialog&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//check for file&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;if&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;fileSelected&lt;span class="Operator"&gt;.&lt;/span&gt;HasValue &lt;span class="Operator"&gt;&amp;amp;&lt;/span&gt;&lt;span class="Operator"&gt;&amp;amp;&lt;/span&gt; fileSelected&lt;span class="Operator"&gt;.&lt;/span&gt;Value&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//check legth&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;if&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;ofd&lt;span class="Operator"&gt;.&lt;/span&gt;File&lt;span class="Operator"&gt;.&lt;/span&gt;Length &lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt; &lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_maxFileSize&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//(omitted UI code)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//file too large&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;tbProgress&lt;span class="Operator"&gt;.&lt;/span&gt;Text &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Constant"&gt;&amp;quot;You cannot upload a file larger than 500 MB.&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;return&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//(omitted UI code)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//start upload&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;StartUpload&lt;span class="Operator"&gt;(&lt;/span&gt;ofd&lt;span class="Operator"&gt;.&lt;/span&gt;File&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellBottomLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Line #7 above sets the Filter property of the OpenFileDialog to the Encoder 3 supported file types. This is what ensures that Encoder will be able to handle whatever the user throws at it. Line #15 shows that &amp;quot;UI&amp;quot; code has been omitted. You&amp;#39;ll see this in a lot the code samples throughout SUESS. Like I said, I don&amp;#39;t want to bore you with the details of dealing with &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.windows.visualstate(VS.95).aspx" class="Link"&gt;VisualStates&lt;/a&gt; in the application. Here are some more action shots: &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;p class="Image"&gt;&lt;img src="http://chrisdomino.com/content/images/The-SUESS-Lifecycle-Stage-1-Upload/Uploading.png" class="Image" alt="" /&gt;&lt;/p&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;p class="Image"&gt;&lt;img src="http://chrisdomino.com/content/images/The-SUESS-Lifecycle-Stage-1-Upload/Analyzing.png" class="Image" alt="" /&gt;&lt;/p&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;p class="Image"&gt;&lt;img src="http://chrisdomino.com/content/images/The-SUESS-Lifecycle-Stage-1-Upload/Encoding.png" class="Image" alt="" /&gt;&lt;/p&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Next let&amp;#39;s look at the logic that implements the recursive &amp;quot;chunky&amp;quot; upload. If we send the entire file up to the server, we can&amp;#39;t show progress bars, and really don&amp;#39;t take advantage of client side functionality at all. Instead, the SUESS Uploader sends 1MB of the file up to the server at a time. After each call, the UI is updated with the current progress, and then the next &amp;quot;chunk&amp;quot; is uploaded. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Since all Silverlight service communication is done asynchronously, we need to daisy chain the &amp;quot;Completed&amp;quot; callback for each of these calls so that they are executed serially within it. Normally, if service calls can be done in parallel (such as downloading images or assembling the content of unselected tabs), you can kick off them all off at the same time; when they&amp;#39;re done, they&amp;#39;re done, and the corresponding part of the UI lights up. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Otherwise, if you need to call service A and then pass its result on to service B (or a subsequent call back to A, like the Uploader), then there will be some chaining going on. Here&amp;#39;s a quick diagram that demonstrates these two paradigms. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;p class="Image"&gt;&lt;img src="http://chrisdomino.com/content/images/The-SUESS-Lifecycle-Stage-1-Upload/Services.png" class="Image" alt="" /&gt;&lt;/p&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;In the top half, where we show &amp;quot;parallel&amp;quot; calls, all of the service references are explicit. We invoke a service, and when the associated completed event handler is fired, we do something back on the UI. What if we need to call the same service multiple (and in an unknowable amount of) times in a specific order? This is the case with the Uploader. Since we obviously can&amp;#39;t know the size of the file, then we further don&amp;#39;t know how many chunks we&amp;#39;ll be dealing with. We need to make these calls serially. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;The answer is recursion, as shown in the bottom half of the diagram. (Of course, this is only logical recursion, since the same physical method isn&amp;#39;t actually calling itself.) I experimented with some crazy iterative algorithms, but they got real messy real quick, and were all ultimately besmirched by the asynchronousity of Silverlight. Instead, I created a method that uploads a chunk (array of bytes) of a file, and when it&amp;#39;s done, increments a counter and progress bars. Finally, the same service is called again with the next chunk. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;This algorithm, other than being sweet at uploading files, makes two additional features of the Uploader trivial: real time progress bars and upload cancellation. We&amp;#39;ll discuss those next. First, however, let&amp;#39;s look at this code. This piece is the StartUpload method that the above code block calls to kick off the recursion. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;table cellpadding="0" cellspacing="0" class="CodeLayout"&gt;
&lt;tbody&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellTopLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;
&lt;div class="CodeContainer"&gt;
&lt;div class="CodeLayout"&gt;&lt;ol class="Code"&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;private&lt;/span&gt; &lt;span class="Keyword"&gt;void&lt;/span&gt; StartUpload&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;FileInfo&lt;/span&gt; file&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//(omitted UI code that resets progress bars, clears errors, etc.)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//start recursive upload&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_index &lt;span class="Operator"&gt;=&lt;/span&gt; 0&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_fileName &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;string&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Format&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Constant"&gt;&amp;quot;{0}-{1}&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="ClassName"&gt;Guid&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;NewGuid&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt; file&lt;span class="Operator"&gt;.&lt;/span&gt;Name&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;UploadFile&lt;span class="Operator"&gt;(&lt;/span&gt;file&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;true&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellBottomLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;The Boolean passed as the second parameter to UploadFile in Line #7 simply tells the algorithm this is the first chunk. UploadFile actually doesn&amp;#39;t care; it just passes this along to the service so that it knows whether to create a new file on the data tier or open an existing one. This can probably be inferred on the server rather than made explicit, but I didn&amp;#39;t want to have to burn an extra trip to the disk for each chunk if I didn&amp;#39;t have to. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Here&amp;#39;s the algorithm: &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;table cellpadding="0" cellspacing="0" class="CodeLayout"&gt;
&lt;tbody&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellTopLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;
&lt;div class="CodeContainer"&gt;
&lt;div class="CodeLayout"&gt;&lt;ol class="Code"&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;private&lt;/span&gt; &lt;span class="Keyword"&gt;void&lt;/span&gt; UploadFile&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;FileInfo&lt;/span&gt; file&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;bool&lt;/span&gt; isFirstChunk&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//initialization&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;byte&lt;/span&gt;&lt;span class="Operator"&gt;[&lt;/span&gt;&lt;span class="Operator"&gt;]&lt;/span&gt; buffer &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="Keyword"&gt;byte&lt;/span&gt;&lt;span class="Operator"&gt;[&lt;/span&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_bufferSize&lt;span class="Operator"&gt;]&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;MediaServiceSoapClient&lt;/span&gt; svc &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;Utilities&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;GetMediaClient&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//get chunk&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;using&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;Stream&lt;/span&gt; data &lt;span class="Operator"&gt;=&lt;/span&gt; file&lt;span class="Operator"&gt;.&lt;/span&gt;OpenRead&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//write to buffer&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;data&lt;span class="Operator"&gt;.&lt;/span&gt;Seek&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_index&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="ClassName"&gt;SeekOrigin&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Begin&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;data&lt;span class="Operator"&gt;.&lt;/span&gt;Read&lt;span class="Operator"&gt;(&lt;/span&gt;buffer&lt;span class="Operator"&gt;,&lt;/span&gt; 0&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_bufferSize&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//upload chunk&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;svc&lt;span class="Operator"&gt;.&lt;/span&gt;UploadFileChunkAsync&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_fileName&lt;span class="Operator"&gt;,&lt;/span&gt; buffer&lt;span class="Operator"&gt;,&lt;/span&gt; isFirstChunk&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;svc&lt;span class="Operator"&gt;.&lt;/span&gt;UploadFileChunkCompleted &lt;span class="Operator"&gt;+&lt;/span&gt;&lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;sender&lt;span class="Operator"&gt;,&lt;/span&gt; args&lt;span class="Operator"&gt;)&lt;/span&gt; &lt;span class="Operator"&gt;=&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//determine result&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;if&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;args&lt;span class="Operator"&gt;.&lt;/span&gt;Cancelled &lt;span class="Operator"&gt;|&lt;/span&gt;&lt;span class="Operator"&gt;|&lt;/span&gt; args&lt;span class="Operator"&gt;.&lt;/span&gt;Error &lt;span class="Operator"&gt;!&lt;/span&gt;&lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;null&lt;/span&gt; &lt;span class="Operator"&gt;|&lt;/span&gt;&lt;span class="Operator"&gt;|&lt;/span&gt; &lt;span class="Operator"&gt;!&lt;/span&gt;&lt;span class="Keyword"&gt;string&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;IsNullOrEmpty&lt;span class="Operator"&gt;(&lt;/span&gt;args&lt;span class="Operator"&gt;.&lt;/span&gt;Result&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//(error code very much truncated here; the above if statement should check each OR&amp;#39;ed condition separately and update the UI appropriately)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;else&lt;/span&gt; &lt;span class="Keyword"&gt;if&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_index &lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt; &lt;span class="Operator"&gt;-&lt;/span&gt;1&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//update text progress&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;double&lt;/span&gt; progress &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;Convert&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;ToDouble&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_index&lt;span class="Operator"&gt;)&lt;/span&gt; &lt;span class="Operator"&gt;/&lt;/span&gt; &lt;span class="ClassName"&gt;Convert&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;ToDouble&lt;span class="Operator"&gt;(&lt;/span&gt;file&lt;span class="Operator"&gt;.&lt;/span&gt;Length&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt; &lt;span class="Operator"&gt;*&lt;/span&gt; 100&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;pbUpload&lt;span class="Operator"&gt;.&lt;/span&gt;IsIndeterminate &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;false&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;tbProgress&lt;span class="Operator"&gt;.&lt;/span&gt;Text &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;string&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Format&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Constant"&gt;&amp;quot;{0} / {1} MB uploaded...&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="ClassName"&gt;Convert&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;ToDouble&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_index&lt;span class="Operator"&gt;)&lt;/span&gt; &lt;span class="Operator"&gt;/&lt;/span&gt; &lt;span class="ClassName"&gt;Convert&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;ToDouble&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_bufferSize&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;GetTotalSize&lt;span class="Operator"&gt;(&lt;/span&gt;file&lt;span class="Operator"&gt;.&lt;/span&gt;Length&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//animate value&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;Storyboard&lt;/span&gt; sb &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;Storyboard&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;DoubleAnimation&lt;/span&gt; da &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;DoubleAnimation&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;Storyboard&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;SetTarget&lt;span class="Operator"&gt;(&lt;/span&gt;da&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;pbUpload&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;Storyboard&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;SetTargetProperty&lt;span class="Operator"&gt;(&lt;/span&gt;da&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;PropertyPath&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Constant"&gt;&amp;quot;Value&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;sb&lt;span class="Operator"&gt;.&lt;/span&gt;Children&lt;span class="Operator"&gt;.&lt;/span&gt;Add&lt;span class="Operator"&gt;(&lt;/span&gt;da&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;da&lt;span class="Operator"&gt;.&lt;/span&gt;To &lt;span class="Operator"&gt;=&lt;/span&gt; progress&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//determine if we&amp;#39;ve reached the end of the file&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;if&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;file&lt;span class="Operator"&gt;.&lt;/span&gt;Length &lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt; &lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_index&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//pause and upload next chunk&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;Thread&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Sleep&lt;span class="Operator"&gt;(&lt;/span&gt;200&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_index &lt;span class="Operator"&gt;+&lt;/span&gt;&lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_bufferSize&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//recurse&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;UploadFile&lt;span class="Operator"&gt;(&lt;/span&gt;file&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;false&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//(omitted UI code)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//we&amp;#39;re done - start encoding&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;EncodeCompletedFile&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//animate progress&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;sb&lt;span class="Operator"&gt;.&lt;/span&gt;Begin&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//update canceled&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;ShowCancel&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;return&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellBottomLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;The first thing to point out here is the utility method in Line #5. This method is a nice Silverlight helper that alleviates the need to have to deal with the &amp;quot;ServiceReferences.ClientConfig&amp;quot; files that store the Service URLs and other WCF settings. Using this method allows you to promote your control from development through production without having to worry about maintaining it. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;table cellpadding="0" cellspacing="0" class="CodeLayout"&gt;
&lt;tbody&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellTopLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;
&lt;div class="CodeContainer"&gt;
&lt;div class="CodeLayout"&gt;&lt;ol class="Code"&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;public&lt;/span&gt; &lt;span class="Keyword"&gt;static&lt;/span&gt; &lt;span class="ClassName"&gt;MediaServiceSoapClient&lt;/span&gt; GetMediaClient&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//return&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;return&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;MediaServiceSoapClient&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;Utilities&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;GetBinding&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="ClassName"&gt;Utilities&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;GetAddress&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Constant"&gt;&amp;quot;Media&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellBottomLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Here are the two internal methods that build the WCF binding and get the URL of the service dynamically: &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;table cellpadding="0" cellspacing="0" class="CodeLayout"&gt;
&lt;tbody&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellTopLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;
&lt;div class="CodeContainer"&gt;
&lt;div class="CodeLayout"&gt;&lt;ol class="Code"&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;private&lt;/span&gt; &lt;span class="Keyword"&gt;static&lt;/span&gt; &lt;span class="ClassName"&gt;BasicHttpBinding&lt;/span&gt; GetBinding&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//initialization&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;BasicHttpBinding&lt;/span&gt; binding &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;BasicHttpBinding&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;BasicHttpSecurityMode&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;None&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//set timeout&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;binding&lt;span class="Operator"&gt;.&lt;/span&gt;SendTimeout &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;TimeSpan&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;FromHours&lt;span class="Operator"&gt;(&lt;/span&gt;1&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;binding&lt;span class="Operator"&gt;.&lt;/span&gt;OpenTimeout &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;TimeSpan&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;FromHours&lt;span class="Operator"&gt;(&lt;/span&gt;1&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;binding&lt;span class="Operator"&gt;.&lt;/span&gt;CloseTimeout &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;TimeSpan&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;FromHours&lt;span class="Operator"&gt;(&lt;/span&gt;1&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;binding&lt;span class="Operator"&gt;.&lt;/span&gt;ReceiveTimeout &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;TimeSpan&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;FromHours&lt;span class="Operator"&gt;(&lt;/span&gt;1&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//set messags sizes&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;binding&lt;span class="Operator"&gt;.&lt;/span&gt;MaxBufferSize &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;int&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;MaxValue&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;binding&lt;span class="Operator"&gt;.&lt;/span&gt;MaxReceivedMessageSize &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;int&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;MaxValue&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//return&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;return&lt;/span&gt; binding&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellBottomLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;And the piece to get the service endpoint. (Note that since this example was lifted from a SharePoint implementation of SUESS, I had to be a bit creative with the URL.) &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;table cellpadding="0" cellspacing="0" class="CodeLayout"&gt;
&lt;tbody&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellTopLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;
&lt;div class="CodeContainer"&gt;
&lt;div class="CodeLayout"&gt;&lt;ol class="Code"&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;private&lt;/span&gt; &lt;span class="Keyword"&gt;static&lt;/span&gt; &lt;span class="ClassName"&gt;EndpointAddress&lt;/span&gt; GetAddress&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;string&lt;/span&gt; name&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//window.location.href&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;Uri&lt;/span&gt; uri &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;Uri&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;ScriptObject&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;HtmlPage&lt;span class="Operator"&gt;.&lt;/span&gt;Window&lt;span class="Operator"&gt;.&lt;/span&gt;GetProperty&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Constant"&gt;&amp;quot;location&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;GetProperty&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Constant"&gt;&amp;quot;href&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;ToString&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//return&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;return&lt;/span&gt; &lt;span class="Keyword"&gt;new&lt;/span&gt; &lt;span class="ClassName"&gt;EndpointAddress&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;string&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Format&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Constant"&gt;&amp;quot;{0}://{1}/_vti_bin/{2}Service.asmx&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt; uri&lt;span class="Operator"&gt;.&lt;/span&gt;Scheme&lt;span class="Operator"&gt;,&lt;/span&gt; uri&lt;span class="Operator"&gt;.&lt;/span&gt;Host&lt;span class="Operator"&gt;,&lt;/span&gt; name&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellBottomLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;The rest of the main algorithm is actually pretty straight forward. The recursiveness happens in lines 39 through 42. We pause a bit in Line #39 so that Silverlight doesn&amp;#39;t try to open the file from a new thread before the previous one properly closed it, increment the index of where we &amp;quot;are&amp;quot; in the file, and then recursively call the service. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;How do we break out of the recursion? Three things can happen. First of all, if something goes terribly wrong on the server or some other exception is thrown, it will be caught on Line #20, handled, and then we&amp;#39;ll hard return out of the method. (Again, since this isn&amp;#39;t physical recursion, we don&amp;#39;t have any stack trace &amp;quot;depth&amp;quot; to worry about.) Otherwise, we use the index. If it&amp;#39;s greater than or equal to the length of the file, we know we&amp;#39;ve uploaded all the bytes: break out here, and start encoding. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;The final way is through cancelation, which is one of the big features the Uploader. I know this isn&amp;#39;t anything amazing, but it&amp;#39;s another example of something that&amp;#39;s pretty easy in Silverlight and probably pretty tough in HTML. As someone who&amp;#39;s been in and around SharePoint for years, I&amp;#39;ve seen a lot of large file uploads quietly timeout after watching the page spin for ten minutes. That sort of behavior is not good enough; we need a big red self-destruct button to make sure we can cleanly stop an upload. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;So as all this asynchronous uploading is happening on background threads, how do we cancel it from the click event of a cancel button on the UI thread? It turns out that it just works. Silverlight will automatically fire the completed event for a service call on the correct thread, alleviating the need for any dispatching. Since we don&amp;#39;t have to worry about any cross threading, we can jump right in with the logic. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;The Uploader cancel button click does two things. First, it simply sets the aforementioned index to -1, which basically throws a wrench in the recursive gears. Since all of our calls are on the same thread, we can check this index, see that we&amp;#39;ve been cancelled, and, well, stop making calls. This is all the housekeeping we need on the client. But what about the server? &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;The second cancellation task is to make one more call that tells the server that this upload has been cancelled so it can clean up the file. This is one of the reasons for the intermediate &amp;quot;upload&amp;quot; folder on the server: we never had to worry about IIS serving fragments of files. Other than cancellation, dropped connections will also leave broken files on the server. If the upload connections die, then we obviously won&amp;#39;t be able to make another call to tell the server to clean up this file. Here is where the cleanup job finishes up for us. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;This is a good transition to start looking at server code. We&amp;#39;ll begin with the CancelFile method: &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;table cellpadding="0" cellspacing="0" class="CodeLayout"&gt;
&lt;tbody&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellTopLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;
&lt;div class="CodeContainer"&gt;
&lt;div class="CodeLayout"&gt;&lt;ol class="Code"&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;[&lt;/span&gt;&lt;span class="ClassName"&gt;WebMethod&lt;/span&gt;&lt;span class="Operator"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;public&lt;/span&gt; &lt;span class="Keyword"&gt;string&lt;/span&gt; CancelFile&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;string&lt;/span&gt; path&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//initialization&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;string&lt;/span&gt; result &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;string&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Empty&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;path &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;Path&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Combine&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;GetTempUploadPath&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt; path&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//impersonation&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;SPSecurity&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;RunWithElevatedPrivileges&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt; &lt;span class="Operator"&gt;=&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;try&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//delete&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;if&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;File&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Exists&lt;span class="Operator"&gt;(&lt;/span&gt;path&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;File&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Delete&lt;span class="Operator"&gt;(&lt;/span&gt;path&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;catch&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;Exception&lt;/span&gt; ex&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//(error code omitted)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//return&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;return&lt;/span&gt; result&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellBottomLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;The interesting thing going on here is in Line #8 where I elevate to run as the SharePoint app pool account. This is important for two reasons (neither of which, of course, are what the &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsecurity.runwithelevatedprivileges.aspx" class="Link"&gt;RunWithElevatedPrivileges&lt;/a&gt; delegate is designed to do). First of all, we don&amp;#39;t have to assign &amp;quot;Everyone&amp;quot; permissions on our folders. Second, it gets us around a potential &lt;a target="_blank" href="http://blogs.iis.net/owscott/archive/2008/08/22/iis-windows-authentication-and-the-double-hop-issue.aspx" class="Link"&gt;IIS double hop&lt;/a&gt; issue, in case the GetTempUploadPath method (which is a wrapper around a config file call) returns a UNC path. (Kerberos is the right way to deal with IIS double hops, but that seems to be more configuration than most people - including me - are willing to deal with). &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Next we have the method that accepts a chunk from the client and builds a file on the destination server: &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;table cellpadding="0" cellspacing="0" class="CodeLayout"&gt;
&lt;tbody&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellTopLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;
&lt;div class="CodeContainer"&gt;
&lt;div class="CodeLayout"&gt;&lt;ol class="Code"&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;[&lt;/span&gt;&lt;span class="ClassName"&gt;WebMethod&lt;/span&gt;&lt;span class="Operator"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;public&lt;/span&gt; &lt;span class="Keyword"&gt;string&lt;/span&gt; UploadFileChunk&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;string&lt;/span&gt; path&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;byte&lt;/span&gt;&lt;span class="Operator"&gt;[&lt;/span&gt;&lt;span class="Operator"&gt;]&lt;/span&gt; data&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;bool&lt;/span&gt; isFirstChunk&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//initialization&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;string&lt;/span&gt; result &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;string&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Empty&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;Action&lt;/span&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="ClassName"&gt;&lt;span class="Keyword"&gt;object&lt;/span&gt;&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt; uploadCode &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;null&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;path &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;Path&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Combine&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;GetTempUploadPath&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt; path&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//impersonation&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;SPSecurity&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;RunWithElevatedPrivileges&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt; &lt;span class="Operator"&gt;=&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;try&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//determine if this is the first request&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;if&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;isFirstChunk&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//delete&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;if&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;File&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Exists&lt;span class="Operator"&gt;(&lt;/span&gt;path&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:50px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;File&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Delete&lt;span class="Operator"&gt;(&lt;/span&gt;path&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//determine if file exits&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;if&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;File&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Exists&lt;span class="Operator"&gt;(&lt;/span&gt;path&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//add chunk to existing file&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;uploadCode &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;o&lt;span class="Operator"&gt;)&lt;/span&gt; &lt;span class="Operator"&gt;=&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:50px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//open file&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:50px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;using&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;FileStream&lt;/span&gt; fs &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;File&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Open&lt;span class="Operator"&gt;(&lt;/span&gt;path&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="ClassName"&gt;FileMode&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Open&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:50px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:60px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//write chunk&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:60px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;WriteChunk&lt;span class="Operator"&gt;(&lt;/span&gt;fs&lt;span class="Operator"&gt;,&lt;/span&gt; data&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:50px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//create new file&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;uploadCode &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;o&lt;span class="Operator"&gt;)&lt;/span&gt; &lt;span class="Operator"&gt;=&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:50px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//open file&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:50px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;using&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;FileStream&lt;/span&gt; fs &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;File&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Create&lt;span class="Operator"&gt;(&lt;/span&gt;path&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:50px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:60px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//write chunk&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:60px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;WriteChunk&lt;span class="Operator"&gt;(&lt;/span&gt;fs&lt;span class="Operator"&gt;,&lt;/span&gt; data&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:50px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//upload&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;Utils&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;ForceRetryFunction&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Keyword"&gt;object&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="ClassName"&gt;Exception&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt; &lt;span class="Operator"&gt;=&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt; &lt;span class="Operator"&gt;{&lt;/span&gt; uploadCode&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;null&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt; &lt;span class="Keyword"&gt;return&lt;/span&gt; &lt;span class="Keyword"&gt;null&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt; &lt;span class="Operator"&gt;}&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Constant"&gt;&amp;quot;MediaService.UploadFileChunk&amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;string&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Concat&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Constant"&gt;&amp;quot;The following error occured while uploading &amp;quot;&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt; path&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;catch&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;Exception&lt;/span&gt; ex&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//(error code omitted)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//return&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;return&lt;/span&gt; result&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellBottomLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;There are a couple of things to note here. First of all, you&amp;#39;ll notice that I use an &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/018hxwa8.aspx" class="Link"&gt;Action&lt;/a&gt; delegate to pass the blocks of code that do the file writing (WriteChunk will be displayed shortly) to a method in Line #48 called ForceRetryFunction. This method takes in a &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/bb534960.aspx" class="Link"&gt;Func&lt;/a&gt; (that is passed via an anonymous method in the invocation) which is basically processed in a while loop until it doesn&amp;#39;t throw the type of exception (that is generically passed in as well). There are few other operations in the system that spawned SUESS, so I refactored it into ForceRetryMethod. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;But WHY? Simply because certain operations need to be kicked in the ass to work. In this example, with I/O happening on several threads really fast, .NET can step on itself and open the file before it&amp;#39;s properly closed (just like on the client). I&amp;#39;ll put the code here for fun because it&amp;#39;s a pretty cool algorithm, but the details are outside the scope of SUESS. &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;table cellpadding="0" cellspacing="0" class="CodeLayout"&gt;
&lt;tbody&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellTopLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;
&lt;div class="CodeContainer"&gt;
&lt;div class="CodeLayout"&gt;&lt;ol class="Code"&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;public&lt;/span&gt; &lt;span class="Keyword"&gt;static&lt;/span&gt; &lt;span class="ClassName"&gt;T&lt;/span&gt; ForceRetryFunction&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="ClassName"&gt;T&lt;/span&gt;&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="ClassName"&gt;E&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;Func&lt;/span&gt;&lt;span class="Operator"&gt;&amp;lt;&lt;/span&gt;&lt;span class="ClassName"&gt;T&lt;/span&gt;&lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt; code&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;string&lt;/span&gt; sender&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;string&lt;/span&gt; description&lt;span class="Operator"&gt;)&lt;/span&gt; &lt;span class="Keyword"&gt;where&lt;/span&gt; &lt;span class="ClassName"&gt;E&lt;/span&gt; &lt;span class="Operator"&gt;:&lt;/span&gt; &lt;span class="ClassName"&gt;Exception&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//initialization&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;int&lt;/span&gt; sleep &lt;span class="Operator"&gt;=&lt;/span&gt; 500&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;bool&lt;/span&gt; worked &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;false&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;T&lt;/span&gt; result &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;default&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;T&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;DateTime&lt;/span&gt; now &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;DateTime&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;UtcNow&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//keep trying&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;while&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;!&lt;/span&gt;worked&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;try&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//run the code&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;result &lt;span class="Operator"&gt;=&lt;/span&gt; code&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//code successful&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;worked &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;true&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;catch&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;E&lt;/span&gt; ex&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//only try for one minute&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;if&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;DateTime&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;UtcNow&lt;span class="Operator"&gt;.&lt;/span&gt;Subtract&lt;span class="Operator"&gt;(&lt;/span&gt;now&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;TotalMinutes &lt;span class="Operator"&gt;&amp;gt;&lt;/span&gt; 1&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//unable to save&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//(error code omitted)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;worked &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;true&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//method blew up: sleep and try again&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;lock&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;Utils&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_random&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:50px;"&gt;&lt;span class="Code"&gt;sleep &lt;span class="Operator"&gt;*&lt;/span&gt;&lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;Convert&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;ToInt32&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;1&lt;span class="Operator"&gt;.&lt;/span&gt;5 &lt;span class="Operator"&gt;+&lt;/span&gt; &lt;span class="ClassName"&gt;Utils&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;_random&lt;span class="Operator"&gt;.&lt;/span&gt;NextDouble&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//sleep exponentially&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:40px;"&gt;&lt;span class="Code"&gt;&lt;span class="ClassName"&gt;Thread&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Sleep&lt;span class="Operator"&gt;(&lt;/span&gt;sleep&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//return&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;return&lt;/span&gt; result&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellBottomLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;After all the trying, retrying, locking, and checking, the actual &lt;span class="Italic"&gt;work&lt;/span&gt; that the server performs can be boiled down the simplest method in this section: WriteChunk. Here&amp;#39;s the little guy: &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;
&lt;table cellpadding="0" cellspacing="0" class="CodeLayout"&gt;
&lt;tbody&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellTopLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;
&lt;div class="CodeContainer"&gt;
&lt;div class="CodeLayout"&gt;&lt;ol class="Code"&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;private&lt;/span&gt; &lt;span class="Keyword"&gt;void&lt;/span&gt; WriteChunk&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;FileStream&lt;/span&gt; fs&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="Keyword"&gt;byte&lt;/span&gt;&lt;span class="Operator"&gt;[&lt;/span&gt;&lt;span class="Operator"&gt;]&lt;/span&gt; buffer&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//seek to end of the file&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;fs&lt;span class="Operator"&gt;.&lt;/span&gt;Seek&lt;span class="Operator"&gt;(&lt;/span&gt;0&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="ClassName"&gt;SeekOrigin&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;End&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//write chunk&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;fs&lt;span class="Operator"&gt;.&lt;/span&gt;Write&lt;span class="Operator"&gt;(&lt;/span&gt;buffer&lt;span class="Operator"&gt;,&lt;/span&gt; 0&lt;span class="Operator"&gt;,&lt;/span&gt; buffer&lt;span class="Operator"&gt;.&lt;/span&gt;Length&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellBottomLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Very straight forward, and unfortunately, a rather anticlimactic way to end our discussion of the SUESS Uploader. Once the file is up on the server, the Uploader&amp;#39;s only remaining task is to kick off the Encoder stage. This is where all the really cool stuff happens, so stay tuned for the next post! &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;Have fun! &lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;&amp;nbsp;&lt;/p&gt;
&lt;div&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.rightpoint.com/community/aggbug.aspx?PostID=2809" width="1" height="1"&gt;</content><author><name>cdomino</name><uri>http://www.rightpoint.com/community/members/cdomino/default.aspx</uri></author><category term="Silverlight" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/Silverlight/default.aspx" /><category term="IIS SmoothStreaming" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/IIS+SmoothStreaming/default.aspx" /><category term="Expression Encoder" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/Expression+Encoder/default.aspx" /></entry><entry><title>Enterprise’s Internal Communications can Transform itself into a Social Business</title><link rel="alternate" type="text/html" href="/community/blogs/viewpoint/archive/2010/07/09/enterprise-s-internal-communications-can-transform-itself-into-a-social-business.aspx" /><id>/community/blogs/viewpoint/archive/2010/07/09/enterprise-s-internal-communications-can-transform-itself-into-a-social-business.aspx</id><published>2010-07-09T20:54:00Z</published><updated>2010-07-09T20:54:00Z</updated><content type="html">&lt;div class="WordSection1"&gt;
&lt;p&gt;&lt;span&gt;The most successful examples of social businesses&amp;nbsp;include those who are already using social processes and tools internally. Those business that&amp;nbsp;systematically encourage openness inside the organization are the most likely to empower employees to engage with the outside world.&amp;nbsp; SharePoint tends to be that glue.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;These are ways an enterprise&amp;rsquo;s&amp;nbsp;internal communications can transform itself into&amp;nbsp;a social business:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:gray;font-size:8pt;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;bull; A process with social guidelines is already in place. (For example,&amp;nbsp;Microsoft co-created their guidelines, with&lt;span&gt;&amp;nbsp; &lt;/span&gt;employees.)&lt;/p&gt;
&lt;p&gt;&amp;bull; Employees use social tools to collaborate internally, before opening up external gates. (Examples: employee networks on Facebook, Yammer, Newsgator, Jive, and Social Text.)&lt;/p&gt;
&lt;p&gt;&amp;bull; Companies reconsider the role of individuals in the company, with greater value of and incentives for extra market forces and nonfinancial drivers, including an individual&amp;rsquo;s sense of meaning and purpose.&lt;/p&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.rightpoint.com/community/aggbug.aspx?PostID=2808" width="1" height="1"&gt;</content><author><name>jwillinger</name><uri>http://www.rightpoint.com/community/members/jwillinger/default.aspx</uri></author><category term="SharePoint" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/SharePoint/default.aspx" /><category term="Collaboration" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/Collaboration/default.aspx" /><category term="internal communications" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/internal+communications/default.aspx" /><category term="enterprise 2.0" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/enterprise+2.0/default.aspx" /><category term="intranets" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/intranets/default.aspx" /></entry><entry><title>Getting Silverlight 4 Drag And Drop Working With The SharePoint 2010 Silverlight Web Part</title><link rel="alternate" type="text/html" href="/community/blogs/viewpoint/archive/2010/07/05/getting-silverlight-4-drag-and-drop-working-with-the-sharepoint-2010-silverlight-web-part.aspx" /><id>/community/blogs/viewpoint/archive/2010/07/05/getting-silverlight-4-drag-and-drop-working-with-the-sharepoint-2010-silverlight-web-part.aspx</id><published>2010-07-05T18:52:00Z</published><updated>2010-07-05T18:52:00Z</updated><content type="html">&lt;p class="Text"&gt;I&amp;#39;m working on some Silverlight 4 drag and drop functionality for a SharePoint 2010 site, and ran into the old situation where it worked fine locally, but not fine in SharePoint. What would happen is the browser, in SharePoint, actually opened the image instead of tunneling the drop event to my Silverlight control. I actually knew it wasn&amp;#39;t going to work immediately when I noticed that the cursor was different between the two browsers: the one spawned by Visual Studio had the correct &amp;quot;drag&amp;quot; cursor, while SharePoint sported the &amp;quot;shortcut&amp;quot; one. &lt;/p&gt;
&lt;p class="Text"&gt;This was one of those problems that seemed impossible. How can I control the browser&amp;#39;s behavior toward dragging and dropping files from a different process (such as Windows Explorer)? How could it possibly work on one site and not another? Environmental problems are much harder to solve, in my opinion, than logical problems. I can always take my code apart line by line to exterminate some bug. But when it comes to IE (in this case) being flakey, what can you do? &lt;/p&gt;
&lt;p class="Text"&gt;So I peeked behind the scenes at both markups, and found one difference between the two. &amp;quot;If this isn&amp;#39;t the problem,&amp;quot; I thought, &amp;quot;well, I&amp;#39;m going home.&amp;quot; The difference turned out to be the Silverlight &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/cc838156(VS.95).aspx" class="Link"&gt;Windowless&lt;/a&gt; setting. This is an optional parameter that can be nestled into the object tag and takes a Boolean value. &lt;/p&gt;
&lt;p class="Text"&gt;Setting this to &amp;quot;true&amp;quot; means the Silverlight control is, well, windowless; it literally embeds itself in the browser&amp;#39;s window instead of having the plugin define its bounds. Although there is a performance hit, this embedding allows the control to be truly transparent, and have HTML overlay or underlay it. If Windowless is &amp;quot;false,&amp;quot; it sort of floats &amp;quot;above&amp;quot; the browser. Now, Silverlight is always still in the same physical window (as it&amp;#39;s in IE&amp;#39;s process) of course; the difference is that, if not Windowless, Silverlight acts a bit more autonomously from the browser. &lt;/p&gt;
&lt;p class="Text"&gt;The other consideration, and the one that got me here, is that setting Windowless to true precludes some of the mouse events. Since Silverlight is &amp;quot;in line&amp;quot; with the browser, then the browser will handle them. However, when it floats above (not Windowless), Silverlight can intercept these mouse events, including, of course, drag and drop! &lt;/p&gt;
&lt;p class="Text"&gt;Visual Studio, by default, does not include this parameter, and therefore Windowless defaults to false in Silverlight. The problem is that the SilverightWebPart that comes OOTB in SharePoint 2010 automatically adds this parameter, and sets it to true. And in classic SharePoint fashion, although there is Boolean .NET property that can be set programmatically, the ToolPart does not expose it on the UI. &lt;/p&gt;
&lt;p class="Text"&gt;So how do we fix this to get drag and drop working? You can always add some &lt;a target="_blank" href="http://docs.jquery.com/Main_Page" class="Link"&gt;jQuery&lt;/a&gt;to the master page that blindly sets the parameter to false, but this is a little sloppy. Instead, I came up with the following code that correctly sets the WindowlessMode property on the web part, and persists it: &lt;/p&gt;
&lt;p class="Text"&gt;
&lt;table cellpadding="0" cellspacing="0" class="CodeLayout"&gt;
&lt;tbody&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellTopLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellTopRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellMiddleLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleMiddle"&gt;
&lt;div class="CodeContainer"&gt;
&lt;div class="CodeLayout"&gt;&lt;ol class="Code"&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;using&lt;/span&gt; System&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;using&lt;/span&gt; System&lt;span class="Operator"&gt;.&lt;/span&gt;Web&lt;span class="Operator"&gt;.&lt;/span&gt;UI&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;using&lt;/span&gt; Microsoft&lt;span class="Operator"&gt;.&lt;/span&gt;SharePoint&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;using&lt;/span&gt; System&lt;span class="Operator"&gt;.&lt;/span&gt;Web&lt;span class="Operator"&gt;.&lt;/span&gt;UI&lt;span class="Operator"&gt;.&lt;/span&gt;WebControls&lt;span class="Operator"&gt;.&lt;/span&gt;WebParts&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;using&lt;/span&gt; SPWP &lt;span class="Operator"&gt;=&lt;/span&gt; Microsoft&lt;span class="Operator"&gt;.&lt;/span&gt;SharePoint&lt;span class="Operator"&gt;.&lt;/span&gt;WebPartPages&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;...&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//get this page&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;using&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;SPWP&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;SPLimitedWebPartManager mgr &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="ClassName"&gt;SPContext&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Current&lt;span class="Operator"&gt;.&lt;/span&gt;Web&lt;span class="Operator"&gt;.&lt;/span&gt;GetLimitedWebPartManager&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Keyword"&gt;this&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Page&lt;span class="Operator"&gt;.&lt;/span&gt;Request&lt;span class="Operator"&gt;.&lt;/span&gt;Url&lt;span class="Operator"&gt;.&lt;/span&gt;AbsolutePath&lt;span class="Operator"&gt;,&lt;/span&gt; &lt;span class="ClassName"&gt;PersonalizationScope&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;Shared&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//get all web parts&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;foreach&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;WebPart&lt;/span&gt; wp &lt;span class="Keyword"&gt;in&lt;/span&gt; mgr&lt;span class="Operator"&gt;.&lt;/span&gt;WebParts&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//look for silverlight web parts&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Keyword"&gt;if&lt;/span&gt; &lt;span class="Operator"&gt;(&lt;/span&gt;wp &lt;span class="Keyword"&gt;is&lt;/span&gt; &lt;span class="ClassName"&gt;SPWP&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;SilverlightWebPart&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//disable windowless mode&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="ClassName"&gt;SPWP&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;SilverlightWebPart&lt;span class="Operator"&gt;)&lt;/span&gt;wp&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;.&lt;/span&gt;WindowlessMode &lt;span class="Operator"&gt;=&lt;/span&gt; &lt;span class="Keyword"&gt;false&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:30px;"&gt;&lt;span class="Code"&gt;mgr&lt;span class="Operator"&gt;.&lt;/span&gt;SaveChanges&lt;span class="Operator"&gt;(&lt;/span&gt;wp&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:20px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;&lt;span class="Comment"&gt;//clean&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;mgr&lt;span class="Operator"&gt;.&lt;/span&gt;Web&lt;span class="Operator"&gt;.&lt;/span&gt;Close&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:10px;"&gt;&lt;span class="Code"&gt;mgr&lt;span class="Operator"&gt;.&lt;/span&gt;Web&lt;span class="Operator"&gt;.&lt;/span&gt;Dispose&lt;span class="Operator"&gt;(&lt;/span&gt;&lt;span class="Operator"&gt;)&lt;/span&gt;&lt;span class="Operator"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="Code" style="padding-left:0px;"&gt;&lt;span class="Code"&gt;&lt;span class="Operator"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td class="CodeCellMiddleSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellMiddleRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="CodeRow"&gt;
&lt;td class="CodeCellBottomLeft"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomMiddle"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomSpacer"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td class="CodeCellBottomRight"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p class="Text"&gt;This code could be a web part, a feature, or code in the master page. Run it once, and you&amp;#39;ll be able to drag and drop files into a Silverlight 4 web part living inside of SharePoint 2010! Then reference the Client Object Model DLL in your control, and you&amp;#39;ve got the makings of a killer SharePoint 2010 uploader control, using one of the coolest new features of Silverlight. &lt;/p&gt;
&lt;p class="Text"&gt;Have fun! &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.rightpoint.com/community/aggbug.aspx?PostID=2807" width="1" height="1"&gt;</content><author><name>cdomino</name><uri>http://www.rightpoint.com/community/members/cdomino/default.aspx</uri></author></entry><entry><title>Using Sharepoint 2007 Search via custom code</title><link rel="alternate" type="text/html" href="/community/blogs/viewpoint/archive/2010/06/29/using-sharepoint-2007-search-via-custom-code.aspx" /><id>/community/blogs/viewpoint/archive/2010/06/29/using-sharepoint-2007-search-via-custom-code.aspx</id><published>2010-06-29T13:48:01Z</published><updated>2010-06-29T13:48:01Z</updated><content type="html">&lt;p&gt;Recently, I’ve been working on a Sharepoint 2007 farm that has 500+ site collections, each representing a project.&amp;#160; The plan is to potentially have several GB of (scanned) documents in each of these projects, so they were set up as separate site collections to allow them to be split across different content databases, as well as be able to be backed up and restored independently if needed.&lt;/p&gt;  &lt;p&gt;I’ve been tasked with modifying a custom webpart that rolls up some information (tasks) from these individual site collections.&amp;#160; The original version of this webpart iterated through every site collection on the web application, found the task list, and loaded the tasks.&amp;#160; It worked with 20-30 site collections (but was slow), but would timeout with 500+.&amp;#160; A few weeks ago, I made a couple of quick tweaks to reduce the amount of list-scanning used and properly dispose objects after their use and got it down to a 50s load-time on those 500 site collections, but could get no further.&amp;#160; Creating 500+ SPSite objects just isn’t fast, and SPSiteDataQuery doesn’t work across site collections.&amp;#160; So I’ve been tasked with finding an alternate way to do it, and we’ve settled on using MOSS Search.&lt;/p&gt;  &lt;p&gt;After a few false-starts (initially using &lt;strong&gt;WSS &lt;/strong&gt;search instead of &lt;strong&gt;MOSS&lt;/strong&gt; search), and some issues around dates (use ISO8601 format), my query ran like I expected and pulled back all the tasks.&amp;#160; I switched over to FullTextSqlQuery (to get the range comparison operators) and the core functionality of my custom search piece was done.&lt;/p&gt;  &lt;p&gt;Quick-hit list of lessons from this:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Having 500+ separate site collections makes doing anything to all sites rather painful (and rather slow).&amp;#160; Now that 2010 is out, consider whether RBS can let you achieve the scale you’re looking for without death-by-a-million-site-collections. &lt;/li&gt;    &lt;li&gt;When writing code against search, make sure you know whether you want to use &lt;strong&gt;WSS&lt;/strong&gt; search (&lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.search.query.aspx" target="_blank"&gt;Microsoft.Sharepoint.Search&lt;/a&gt;) or &lt;strong&gt;MOSS&lt;/strong&gt; search (&lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.office.server.search.query.aspx" target="_blank"&gt;Microsoft.Office.Server.Search&lt;/a&gt;).&amp;#160; Their APIs may look similar, but WSS search is less capable.&amp;#160; For one, WSS search doesn’t work with custom managed properties (it’ll throw an “InvalidPropertyException: Property doesn&amp;#39;t exist or is used in a manner inconsistent with schema settings”). &lt;/li&gt;    &lt;li&gt;KeywordQuery does simple queries well.&amp;#160; If you need something more complicated (like greater-than/less-than), you have to go to FullTextSqlQuery. &lt;/li&gt;    &lt;li&gt;‘Contains’ clauses (ie Contains(“value”) or Contains(field, “value”)) don’t support full wildcards – ie. “*value*” won’t match what you want it to – use ‘like’ instead (though that only works for a single field) &lt;/li&gt;    &lt;li&gt;Dates for FullTextSqlQuery must be in &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.sputility.createiso8601datetimefromsystemdatetime.aspx"&gt;ISO8601&lt;/a&gt; format. &lt;/li&gt;    &lt;li&gt;When exposing a new field to search, the procecedure is: Add field to list (if needed), incremental crawl (automatically adds crawled property), add managed property, full crawl.&amp;#160; Keep this in mind when scheduling a migration to a new environment, as that full crawl can take some time (4-8 hours in my 500+ site collection setup on dev hardware). &lt;/li&gt;    &lt;li&gt;AssignedTo behaves oddly when it comes back in a search result.&amp;#160; If it has a single user, it comes back with “Joe Smith”.&amp;#160; If it has multiple, it comes back with “Joe Smith;#41;#Jane Smith;#42;#Roger Brown”.&amp;#160; I had to add logic for this field to remove the ;#ID;# chunks from this (split it up, keep only the 0th, 2nd, etc. items).&amp;#160; This works for my scenario because I don’t actually want those to be links anyway (hence I don’t need the IDs):      &lt;p&gt;var assignedTo = Convert.ToString(row[&amp;quot;AssignedTo&amp;quot;]);        &lt;br /&gt;var assignedTokens = assignedTo.Split(new string[] { &amp;quot;;#&amp;quot; }, StringSplitOptions.None);         &lt;br /&gt;var assignedToNames = assignedTokens.Where((s, i) =&amp;gt; i % 2 == 0).ToArray();         &lt;br /&gt;row[&amp;quot;AssignedTo&amp;quot;] = string.Join(&amp;quot;, &amp;quot;, assignedToNames);&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;When your managed property has the ‘Include values from all crawled properties mapped’ flag set, you may get an array for that column instead of a single value (one farm gave me an array, the other didn’t).&amp;#160; None of my search results had multiple values, so I’m guessing the array is used if *any* item in the index has multiple values – if your managed properties are defined that way, you’ll need to fix it up – I have a previous blog post that covers &lt;a href="http://www.rightpointconsulting.com/community/blogs/viewpoint/archive/2010/04/27/dealing-with-multi-valued-managed-properties-with-custom-sharepoint-search.aspx" target="_blank"&gt;dealing with multi-valued managed properties in Sharepoint Search&lt;/a&gt;. &lt;/li&gt;    &lt;li&gt;If you’re seeing ‘odd’ values in some default fields, check the managed property definitions.&amp;#160; OOTB (and on my local dev environment), the definition of the managed property ‘Path’ – was such that non-document-library items had a value like DispForm.aspx?ID=x, while on our shared test/prod farms, it was ListName/X._000.&amp;#160; Turns out, the managed property definition was modified to try to fix an issue with a third-party library.&amp;#160; Since it ended up not helping that library, we just reverted the change back to the OOTB managed property definition, and all was well again. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;   &lt;br /&gt;Sure, using search for things that aren’t-quite-search has a few challenges, but when it’s all done and working together, it’s a solid solution.&amp;#160; In this case, it changed a feature that took so long to run that it’d time out into a feature that can do sub-second searches, and doesn’t rely on any custom code in event handlers to keep track of everything.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.rightpoint.com/community/aggbug.aspx?PostID=2806" width="1" height="1"&gt;</content><author><name>jrupp</name><uri>http://www.rightpoint.com/community/members/jrupp/default.aspx</uri></author></entry><entry><title>SharePoint Designer 2010 – Quick Tips</title><link rel="alternate" type="text/html" href="/community/blogs/viewpoint/archive/2010/06/22/sharepoint-designer-2010-quick-tips.aspx" /><id>/community/blogs/viewpoint/archive/2010/06/22/sharepoint-designer-2010-quick-tips.aspx</id><published>2010-06-22T19:20:00Z</published><updated>2010-06-22T19:20:00Z</updated><content type="html">&lt;p&gt;For the uninitiated, SharePoint Designer 2010 (SPD) has been revamped alongside the rest of Office 2010.&amp;nbsp; Not only does SPD get the ribbon interface now, but it is also a much better tool for interacting and managing SharePoint 2010.&amp;nbsp; Recently, I was using SPD 2010 for authoring some Page Layouts and editing some other supporting pages in SharePoint and I came across a couple of differences between the 2010 and 2007 versions.&amp;nbsp; More specifically:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;SPD 2010 tries to protect you from doing dumb things&lt;/li&gt;
&lt;li&gt;SPD 2010 tries to guess what you&amp;rsquo;re thinking (with mixed results)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;SPD 2010 tries to protect you from doing dumb things&lt;/h2&gt;
&lt;p&gt;Consider the following scenario: You want to edit a page layout that has already been customized by a coworker of yours.&amp;nbsp; In SPD 2010, this is relatively straight forward.&amp;nbsp; I click on the &amp;lsquo;Page Layouts&amp;rsquo; link on the left-hand toolbox, and then double click on the page layout I&amp;rsquo;d like to edit.&amp;nbsp; This takes me to that layout&amp;rsquo;s &amp;ldquo;dashboard&amp;rdquo;, which displays information about the file itself (i.e. permissions, versions, etc.).&amp;nbsp; Now, if a user were to click on the &amp;lsquo;Edit File&amp;rsquo; link, they open the Page Layout in &amp;lsquo;standard editing mode&amp;rsquo;.&amp;nbsp; This mode is designed to prevent users from making changes to pages that could cause SharePoint to error out at render time.&amp;nbsp; It accomplishes this by marking parts of the file as &amp;lsquo;read-only&amp;rsquo;, indicated by yellow shading.&amp;nbsp; However, if I want to make any major change, I would need to close out from the standard editing experience, return to the file&amp;rsquo;s dashboard page, and then navigate to the ribbon and select the Edit File &amp;ndash;&amp;gt;Edit File in Advanced Mode.&amp;nbsp; This would open a fully editable page in SPD 2010.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Reader Beware&lt;/strong&gt;: You can &lt;em&gt;easily break things&lt;/em&gt; in the Advanced Editor; if you&amp;rsquo;re not sure if you should be using the Advanced Editor, chances are you shouldn&amp;rsquo;t.&amp;nbsp; :-)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rightpointconsulting.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_2.png"&gt;&lt;img height="86" width="454" src="http://www.rightpointconsulting.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb.png" alt="image" border="0" title="image" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rightpointconsulting.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_6.png"&gt;&lt;img height="299" width="454" src="http://www.rightpointconsulting.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb_5F00_2.png" alt="image" border="0" title="image" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So now that I have a file all opened up in my Advanced Editor, I&amp;rsquo;d like to move a web part that was previously stored in a Web Part Zone and make it so that it&amp;rsquo;s a part of the page layout (effectively, not within a web part zone).&amp;nbsp; The advantage of this approach is that I can ensure my content authors can&amp;rsquo;t edit/delete the web part, so the web part will always display.&amp;nbsp; However, if &lt;em&gt;I&lt;/em&gt; ever need to edit/delete the web part, I&amp;rsquo;ll have to do so in the page layout (which will change all page layouts based on it) or I&amp;rsquo;d have to detach a page from it&amp;rsquo;s layout and delete the code.&amp;nbsp; Regardless, this scenario bring me to my next point:&lt;/p&gt;
&lt;h2&gt;SPD 2010 tries to guess what you&amp;rsquo;re thinking (with mixed results)&lt;/h2&gt;
&lt;p&gt;Consider this scenario.&amp;nbsp; I&amp;rsquo;ve opened up the page layout my coworker started in the Advanced Editor, and I now want to add another web part below the existing web part which is outside of any web part zone.&amp;nbsp; So I click my cursor in just after the closing tags for the first we web part; navigate to the &amp;lsquo;Insert&amp;rsquo; menu, Web Part, and select your web part.&amp;nbsp; Now, the problem is illustrated below with the before and after shots. As you can see, by inserting a web part outside of a zone, I have (effectively) deleted the existing web part, which is certainly not what I want.&amp;nbsp; To get around this, you simply need to insert your web part in another area of the document (anywhere will do, just make sure if doesn&amp;rsquo;t overwrite existing code&amp;hellip;This is why I paste in large whitespace areas); then cut the generated code, and paste it right below your existing web part.&amp;nbsp; You&amp;rsquo;ll happily notice that SharePoint will now allow both web parts to exist outside of a web part zone!&lt;/p&gt;
&lt;p&gt;Before:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://www.rightpointconsulting.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_8.png"&gt;&lt;img height="95" width="304" src="http://www.rightpointconsulting.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb_5F00_3.png" alt="image" border="0" title="image" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;After:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://www.rightpointconsulting.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_10.png"&gt;&lt;img height="200" width="304" src="http://www.rightpointconsulting.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb_5F00_4.png" alt="image" border="0" title="image" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Stuff-Before:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rightpointconsulting.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_12.png"&gt;&lt;img height="56" width="304" src="http://www.rightpointconsulting.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb_5F00_5.png" alt="image" border="0" title="image" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Stuff-After:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rightpointconsulting.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_14.png"&gt;&lt;img height="70" width="304" src="http://www.rightpointconsulting.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/image_5F00_thumb_5F00_6.png" alt="image" border="0" title="image" style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Bonus Tip&lt;/strong&gt;: If you&amp;rsquo;re ever in Split View of SPD, and your cursor is in the code view window, and you&amp;rsquo;re trying to insert a SharePoint Web Part, but the menu item grayed out; here the fix.&amp;nbsp; Click into the Design (preview) view below your code view, click back to code view, and you&amp;rsquo;ll see that you can once again insert web parts.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.rightpoint.com/community/aggbug.aspx?PostID=2805" width="1" height="1"&gt;</content><author><name>jeremyw</name><uri>http://www.rightpoint.com/community/members/jeremyw/default.aspx</uri></author><category term="SharePoint" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/SharePoint/default.aspx" /><category term="SharePoint Designer" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/SharePoint+Designer/default.aspx" /><category term="SharePoint 2010" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/SharePoint+2010/default.aspx" /><category term="Office 2010" scheme="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/Office+2010/default.aspx" /></entry></feed>