<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>CodeProject</title>
        <link>http://geekswithblogs.net/paulschapman/category/9875.aspx</link>
        <description>CodeProject</description>
        <language>en-GB</language>
        <copyright>paulschapman</copyright>
        <managingEditor>paulschapman@xericsystems.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>Windows Azure, TDS, WCF, Silverlight and a few problems on the way Part IV &amp;ndash; The Silverlight Project</title>
            <link>http://geekswithblogs.net/paulschapman/archive/2009/05/26/windows-azure-tds-wcf-silverlight-and-a-few-problems-on-and-again.aspx</link>
            <description>&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;After a short sojourn with the Visual Studio 2010 Beta, I’m back with the next part. Pop quiz – can you run Visual Studio Team Foundation and Visual Studio Professional without Team Suite? Well some wit told a client you could not – so I spent some of the Bank Holiday proving otherwise – Another article there on setting it up, but in general it was incredibly easy for a server app! Anyway I digress back to the subject at hand – hosting a Silverlight Application in an Azure Application.&lt;/p&gt;
&lt;p&gt;This was the part that gave me the most gotchas. &lt;/p&gt;
&lt;h1&gt;Adding a Silverlight Project to the Azure Solution.&lt;/h1&gt;
&lt;p&gt;Right click on the Solution and click on the ‘Add New Project’.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/WindowsAzureTDSWCFSilverlightandafewprob_13772/image_2.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" width="244" height="157" src="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/WindowsAzureTDSWCFSilverlightandafewprob_13772/image_thumb.png" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Select The ‘Silverlight Application’ – Give your Silverlight Application a name and then click on ‘OK’.&lt;/p&gt;
&lt;p&gt;When you hit the ‘OK’ button you will be presented with a new window to create the Web Application that will host the Silverlight App. Well we already have a web app. It is the WebRole – for this reason we select the third option – ‘Link this Silverlight control  into an existing Web Site’, if it has not already been selected.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/WindowsAzureTDSWCFSilverlightandafewprob_13772/image_4.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" width="244" height="218" src="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/WindowsAzureTDSWCFSilverlightandafewprob_13772/image_thumb_1.png" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Of the three options at the bottom ensure the first is selected, we will raid this page for some code. Deselect the Make it the start page and select the Enable Silverlight debugging option.&lt;/p&gt;
&lt;p&gt;Now there is a known issue in the WCF Services SDK which may soon cause you at least a really annoying message; "this operation is not supported for a relative uri". While it is not fatal and you can ignore it – as a matter of good coding I tend to get rid of as many warning messages as possible. To fix it, open your machine.config (both x86 and x64 version), and delete the following section: &lt;br /&gt;
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;   &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;endpoint&lt;/span&gt; &lt;span class="attr"&gt;address&lt;/span&gt;&lt;span class="kwrd"&gt;=""&lt;/span&gt; &lt;span class="attr"&gt;binding&lt;/span&gt;&lt;span class="kwrd"&gt;="netTcpRelayBinding"&lt;/span&gt; &lt;span class="attr"&gt;contract&lt;/span&gt;&lt;span class="kwrd"&gt;="IMetadataExchange"&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="sb"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h1&gt;Linking your Silverlight Application to your Webservice&lt;/h1&gt;
&lt;p&gt;Now last time we created a Web Service and it is now time to link the Webservice to the Silverlight Application. Right click on the Silverlight application you have created last time, and select ‘Add Service Reference’&lt;/p&gt;
&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/WindowsAzureTDSWCFSilverlightandafewprob_13772/image_6.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" width="244" height="197" src="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/WindowsAzureTDSWCFSilverlightandafewprob_13772/image_thumb_2.png" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Click on the Discover button and it will search your solution for the Webservice. Give the Namespace a sensible name and click on OK.&lt;/p&gt;
&lt;p&gt;Go to the ServiceReferences.ClientConfig file in the Silverlight Client that is created when you link a webservice. Look for the client tag;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;client&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;endpoint &lt;/span&gt;&lt;span style="COLOR: red"&gt;address&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;http://localhost:51159/SimplicitaServices.svc&lt;/span&gt;"
        &lt;span style="COLOR: red"&gt;binding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;basicHttpBinding&lt;/span&gt;" &lt;span style="COLOR: red"&gt;bindingConfiguration&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;BasicHttpBinding_ISimplicitaServices&lt;/span&gt;"
        &lt;span style="COLOR: red"&gt;contract&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;SimplicitaServices.ISimplicitaServices&lt;/span&gt;" &lt;span style="COLOR: red"&gt;name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;BasicHttpBinding_ISimplicitaServices&lt;/span&gt;" &lt;span style="COLOR: blue"&gt;/&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;client&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;Change the port number to the same port number that your Azure project executes on. In my development environment this tends to be 81, for yours it might be different.&lt;/p&gt;
&lt;p&gt;We nearly have set up the Silverlight application. One last task remains. Silverlight will not retrieve data from some sites, including some webservices unless it has been given permission. You do this by placing a clientaccesspolicy.xml file in the root of the web server. However for this site, which is being run in the virtual server of Visual Studio that in effect means the root of the site. So add a file with that name to your site and insert the following code;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;access-policy&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
  &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;cross-domain-access&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;policy&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
      &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;allow-from &lt;/span&gt;&lt;span style="COLOR: red"&gt;http-request-headers&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;*&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;
        &lt;/span&gt;&amp;gt;
        &lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;domain &lt;/span&gt;&lt;span style="COLOR: red"&gt;uri&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;*&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;/&amp;gt;
      &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;allow-from&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
      &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;grant-to&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;resource &lt;/span&gt;&lt;span style="COLOR: red"&gt;path&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;/&lt;/span&gt;" &lt;span style="COLOR: red"&gt;include-subpaths&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;true&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;/&amp;gt;
      &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;grant-to&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;policy&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
  &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;cross-domain-access&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;access-policy&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;And there we have it. The Silverlight project is now ready for us to code whatever magic we may wish – which will have to wait till the next part – I’m just about to relax and watch the CSI episode set in a Science Fiction convention!&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=132432"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=132432" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/paulschapman/aggbug/132432.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>paulschapman</dc:creator>
            <guid>http://geekswithblogs.net/paulschapman/archive/2009/05/26/windows-azure-tds-wcf-silverlight-and-a-few-problems-on-and-again.aspx</guid>
            <pubDate>Wed, 27 May 2009 03:08:59 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/paulschapman/comments/132432.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/paulschapman/archive/2009/05/26/windows-azure-tds-wcf-silverlight-and-a-few-problems-on-and-again.aspx#feedback</comments>
            <slash:comments>5</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/paulschapman/comments/commentRss/132432.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/paulschapman/services/trackbacks/132432.aspx</trackback:ping>
        </item>
        <item>
            <title>Windows Azure, TDS, WCF, Silverlight and a few problems on the way Part III &amp;ndash; The Azure Project, and creating our Web service.</title>
            <link>http://geekswithblogs.net/paulschapman/archive/2009/05/14/windows-azure-tds-wcf-silverlight-and-a-few-problems-on-yet-again.aspx</link>
            <description>&lt;p&gt;So far Parts I &amp;amp; II have not given us anything new – the code will work happily in an ASP.Net or a traditional client application. Now we get to a more interesting bit – creating our Azure Project.&lt;/p&gt;
&lt;p&gt;Before we can create an Azure Project you will eventually have to go to the Azure Website – and download the Azure tools from here; &lt;a href="http://www.microsoft.com/azure/windowsazurefordevelopers/default.aspx"&gt;http://www.microsoft.com/azure/windowsazurefordevelopers/default.aspx&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Once you have installed these on your development PC you can now create an Azure Project. You will notice that I have not suggested signing up even for a CTP account. The reason is that you can do your development locally – the Azure tools create a kind of mini-Azure on your development PC. This makes little difference now, but when the service is charged for it will make a difference.&lt;/p&gt;
&lt;p&gt;To create an Azure Project, look under your chosen language (C# or VB.Net) and select the ‘Cloud Service’ leaf. Then choose the required template. Normally I have picked the ‘Web And Worker Cloud Service’ – this is because I invariably need both a web and worker role. Indeed this project, we will have both. Below&lt;/p&gt;
&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/WindowsAzureTDSWCFSilverlightandafewpro_147AC/image_2.png"&gt;&lt;img style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: block; FLOAT: none; MARGIN-LEFT: auto; BORDER-TOP: 0px; MARGIN-RIGHT: auto; BORDER-RIGHT: 0px" title="image" border="0" alt="image" width="244" height="165" src="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/WindowsAzureTDSWCFSilverlightandafewpro_147AC/image_thumb.png" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;And that is it. We now have an Azure Project, that can be run locally to test it.&lt;/p&gt;
&lt;h1&gt;The Web service.&lt;/h1&gt;
&lt;p&gt;Now the Azure project will eventually have a Silverlight frontend and that creates a small problem. Silverlight is designed to be a lightweight download and for this reason it uses a subset of the full .Net runtime. This means that many of the functions that one might take for granted. To allow us the use of the full .Net runtime these are placed behind a WCF web service. &lt;/p&gt;
&lt;p&gt;To create a web service you can host it within your Web role. So right-click on the Web role project and select ‘Add’, then ‘New item’&lt;/p&gt;
&lt;p align="center"&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/WindowsAzureTDSWCFSilverlightandafewpro_147AC/image_4.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" width="244" height="148" src="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/WindowsAzureTDSWCFSilverlightandafewpro_147AC/image_thumb_1.png" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;This will display the above window – select the WCF Service, and give it name then click on the ‘Add’ button. &lt;/p&gt;
&lt;p&gt;This creates your Web Service, but we are not finished. Silverlight requires that a Web Service use basic binding. So change the binding of the service double click on the Web.config of the Web Role. Finding the &amp;lt;services&amp;gt; tag. Make sure the ‘binding’ attribute is changed to basicHttpBinding. The following code shows what the section  should look like;&lt;/p&gt;
&lt;pre class="code"&gt;    &lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;service &lt;/span&gt;&lt;span style="COLOR: red"&gt;behaviorConfiguration&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;NewsMashup_WebRole.NewsMashupServiceBehavior&lt;/span&gt;"
        &lt;span style="COLOR: red"&gt;name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;NewsMashup_WebRole.NewsMashupService&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;endpoint &lt;/span&gt;&lt;span style="COLOR: red"&gt;address&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"" &lt;strong&gt;&lt;span style="COLOR: red"&gt;binding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;basicHttpBinding&lt;/span&gt;"&lt;/strong&gt; &lt;span style="COLOR: red"&gt;contract&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;NewsMashup_WebRole.INewsMashupService&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;identity&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;dns &lt;/span&gt;&lt;span style="COLOR: red"&gt;value&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;localhost&lt;/span&gt;" &lt;span style="COLOR: blue"&gt;/&amp;gt;
            &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;identity&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;endpoint&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;endpoint &lt;/span&gt;&lt;span style="COLOR: red"&gt;address&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;mex&lt;/span&gt;" &lt;span style="COLOR: red"&gt;binding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;mexHttpBinding&lt;/span&gt;" &lt;span style="COLOR: red"&gt;contract&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;IMetadataExchange&lt;/span&gt;" &lt;span style="COLOR: blue"&gt;/&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;service&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;services&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;So this sets up our Azure project, and our web service. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=132118"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=132118" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/paulschapman/aggbug/132118.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>paulschapman</dc:creator>
            <guid>http://geekswithblogs.net/paulschapman/archive/2009/05/14/windows-azure-tds-wcf-silverlight-and-a-few-problems-on-yet-again.aspx</guid>
            <pubDate>Fri, 15 May 2009 04:18:16 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/paulschapman/comments/132118.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/paulschapman/archive/2009/05/14/windows-azure-tds-wcf-silverlight-and-a-few-problems-on-yet-again.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/paulschapman/comments/commentRss/132118.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/paulschapman/services/trackbacks/132118.aspx</trackback:ping>
        </item>
        <item>
            <title>Windows Azure, TDS, WCF, Silverlight and a few problems on the way Part II &amp;ndash; Database access layer</title>
            <link>http://geekswithblogs.net/paulschapman/archive/2009/05/13/windows-azure-tds-wcf-silverlight-and-a-few-problems-on-again.aspx</link>
            <description>&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:23ffb774-c08e-4f72-a287-98bdc5a66866" class="wlWriterEditableSmartContent"&gt;
&lt;p&gt;Project Sourcecode: &lt;a target="_blank" href="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/WindowsAzureTDSWCFSilverlightandafewprob_13ABB/NewsMashup.zip"&gt;NewsMashup&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;In Part I of this series of articles I discussed the database that lies behind the application. Moving from the backend to the client side, it is now time to discuss the code which accesses the database and returns the data to application.&lt;/p&gt;
&lt;p&gt;I have a standard class I use when accessing databases. The version I am using here is developed to connect to SQL Server but with some minor changes it would not be difficult to adapt to other databases, and I already have one for ODBC.&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;public &lt;/span&gt;Database(&lt;span style="COLOR: blue"&gt;string &lt;/span&gt;Connection)
{
    connection = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;SqlConnection&lt;/span&gt;(Connection);
    InitialiseCommand();
}

&lt;span style="COLOR: blue"&gt;public &lt;/span&gt;Database(&lt;span style="COLOR: #2b91af"&gt;SqlConnection &lt;/span&gt;Connection)
{
    connection = Connection;
    InitialiseCommand();
}

&lt;span style="COLOR: blue"&gt;public &lt;/span&gt;Database()
{
    connection = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;SqlConnection&lt;/span&gt;();
    InitialiseCommand();

}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;pre class="prettyprint"&gt; &lt;/pre&gt;
&lt;p&gt;The above code shows the constructor for the data access layer. Essentially the constructor expects either a connection, connection string or nothing to be passed to the constructor. Each calls another function; InitialiseCommand() which sets up the command object and is below.&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;private void &lt;/span&gt;InitialiseCommand()
{
    &lt;span style="COLOR: blue"&gt;try
    &lt;/span&gt;{
        &lt;span style="COLOR: blue"&gt;if &lt;/span&gt;(dbCommand == &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)
        {
            dbCommand             = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;SqlCommand&lt;/span&gt;();
            dbCommand.CommandType = &lt;span style="COLOR: #2b91af"&gt;CommandType&lt;/span&gt;.StoredProcedure;  &lt;span style="COLOR: green"&gt;// default to Stored Prc

            &lt;/span&gt;&lt;span style="COLOR: blue"&gt;if &lt;/span&gt;(connection != &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)
            {
                dbCommand.Connection = connection;
            }
        }
    }
    &lt;span style="COLOR: blue"&gt;catch &lt;/span&gt;(System.&lt;span style="COLOR: #2b91af"&gt;Exception &lt;/span&gt;ex)
    {
        &lt;span style="COLOR: blue"&gt;throw &lt;/span&gt;ex;
    }
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;This initialises the Command object and sets the type to Stored Procedure, if the Connection object has been initialised the command objects connection is set to the connection object.&lt;/p&gt;
&lt;p&gt;To execute stored procedures we need two. One to return a datatable, and one which does not&lt;/p&gt;
&lt;pre class="code"&gt;    &lt;span style="COLOR: blue"&gt;public void &lt;/span&gt;Execute()
    {
        &lt;span style="COLOR: blue"&gt;try
        &lt;/span&gt;{
            &lt;span style="COLOR: blue"&gt;if &lt;/span&gt;(dbCommand.Connection.State != &lt;span style="COLOR: #2b91af"&gt;ConnectionState&lt;/span&gt;.Open) dbCommand.Connection.Open();
            dbCommand.ExecuteNonQuery();
        }
        &lt;span style="COLOR: blue"&gt;catch &lt;/span&gt;(System.&lt;span style="COLOR: #2b91af"&gt;Exception &lt;/span&gt;ex)
        {
            &lt;span style="COLOR: blue"&gt;throw &lt;/span&gt;ex;
        }
    }

    &lt;span style="COLOR: blue"&gt;public &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;DataTable &lt;/span&gt;Execute(&lt;span style="COLOR: blue"&gt;string &lt;/span&gt;TableName)
    {
        &lt;span style="COLOR: #2b91af"&gt;SqlDataAdapter  &lt;/span&gt;da;
        &lt;span style="COLOR: #2b91af"&gt;DataSet         &lt;/span&gt;ds;
        &lt;span style="COLOR: #2b91af"&gt;DataTable       &lt;/span&gt;dt = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;DataTable&lt;/span&gt;();

        &lt;span style="COLOR: blue"&gt;try
        &lt;/span&gt;{
            da = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;SqlDataAdapter&lt;/span&gt;(dbCommand);
            ds = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;DataSet&lt;/span&gt;();
            da.Fill(ds,TableName);

            &lt;span style="COLOR: blue"&gt;if &lt;/span&gt;(ds.Tables.Count &amp;gt; 0)
                dt = ds.Tables[0];
        }
        &lt;span style="COLOR: blue"&gt;catch &lt;/span&gt;(System.&lt;span style="COLOR: #2b91af"&gt;Exception &lt;/span&gt;ex)
        {
            &lt;span style="COLOR: blue"&gt;throw &lt;/span&gt;ex;
        }

        &lt;span style="COLOR: blue"&gt;return &lt;/span&gt;dt;
    }
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;The first of these two methods is fairly simple. Essentially what it does is confirm the connection is open, if not the connection is opened. Then it executes the stored procedure. The whole lot is then wrapped in a try catch, which is thrown back to the calling application. &lt;/p&gt;
&lt;p&gt;The second is more interesting. It uses a Data Adapter and Dataset to fill a table returned back to the calling programme.&lt;/p&gt;
&lt;p&gt;These two methods cover all the various types of database action I might want to undertake. &lt;/p&gt;
&lt;p&gt;The real magic here however is in the objects which inherit from this class. &lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;public class &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;NewsMashupDB &lt;/span&gt;: &lt;span style="COLOR: #2b91af"&gt;Database&lt;/span&gt;,&lt;span style="COLOR: #2b91af"&gt;IDisposable&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;The class inherits from the class defined in the code above. The constructor for the object is as follows;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;public &lt;/span&gt;NewsMashupDB() 
    : &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;()
{
    
}

&lt;span style="COLOR: blue"&gt;public &lt;/span&gt;NewsMashupDB(&lt;span style="COLOR: blue"&gt;string &lt;/span&gt;ConnectionString) 
    : &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;(ConnectionString)
{

}&lt;/pre&gt;
&lt;p&gt;Thats it. There is two here – one initialises the connection string, the other does not. All the calling application need do is retrieve the connection string. Executing a stored procedure is equally simple. Here we have the stored procedure which executes the CreateStory stored procedure;&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;public void &lt;/span&gt;CreateStory(&lt;span style="COLOR: blue"&gt;string &lt;/span&gt;Headline, &lt;span style="COLOR: blue"&gt;string &lt;/span&gt;Description, &lt;span style="COLOR: blue"&gt;string &lt;/span&gt;Url, &lt;span style="COLOR: blue"&gt;string &lt;/span&gt;Supplier, &lt;span style="COLOR: blue"&gt;long &lt;/span&gt;PubDateValue)
{
    &lt;span style="COLOR: #2b91af"&gt;SqlParameter &lt;/span&gt;paramHeadline      = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;SqlParameter&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"Headline"&lt;/span&gt;, &lt;span style="COLOR: #2b91af"&gt;SqlDbType&lt;/span&gt;.VarChar);
    &lt;span style="COLOR: #2b91af"&gt;SqlParameter &lt;/span&gt;paramDescription   = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;SqlParameter&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"Description"&lt;/span&gt;,&lt;span style="COLOR: #2b91af"&gt;SqlDbType&lt;/span&gt;.VarChar);
    &lt;span style="COLOR: #2b91af"&gt;SqlParameter &lt;/span&gt;paramUrl           = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;SqlParameter&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"Url"&lt;/span&gt;,&lt;span style="COLOR: #2b91af"&gt;SqlDbType&lt;/span&gt;.VarChar);
    &lt;span style="COLOR: #2b91af"&gt;SqlParameter &lt;/span&gt;paramSupplier      = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;SqlParameter&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"Supplier"&lt;/span&gt;, &lt;span style="COLOR: #2b91af"&gt;SqlDbType&lt;/span&gt;.VarChar);
    &lt;span style="COLOR: #2b91af"&gt;SqlParameter &lt;/span&gt;paramPubDate       = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;SqlParameter&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"PubDateValue"&lt;/span&gt;, &lt;span style="COLOR: #2b91af"&gt;SqlDbType&lt;/span&gt;.BigInt);

    CommandText = &lt;span style="COLOR: #a31515"&gt;"NewsMashup.CreateStory"&lt;/span&gt;;

    &lt;span style="COLOR: blue"&gt;try
    &lt;/span&gt;{

        paramHeadline.Value = Headline;
        paramDescription.Value = Description;
        paramUrl.Value = Url;
        paramSupplier.Value = Supplier;
        paramPubDate.Value = PubDateValue;

        dbCommand.Parameters.Clear();

        dbCommand.Parameters.Add(paramHeadline);
        dbCommand.Parameters.Add(paramDescription);
        dbCommand.Parameters.Add(paramUrl);
        dbCommand.Parameters.Add(paramSupplier);
        dbCommand.Parameters.Add(paramPubDate);

        Execute();
    }
    &lt;span style="COLOR: blue"&gt;catch &lt;/span&gt;(System.&lt;span style="COLOR: #2b91af"&gt;Exception &lt;/span&gt;ex)
    {
        &lt;span style="COLOR: blue"&gt;throw &lt;/span&gt;ex;
    }
}&lt;/pre&gt;
&lt;p&gt;Except for the code setting up the parameters required the execution of the stored procedure takes two lines; one to initialise the command text, the other to execute the stored procedure. &lt;/p&gt;
&lt;p&gt;A stored procedure which returns data is equally simple.&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="COLOR: blue"&gt;public &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;DataTable &lt;/span&gt;RetrieveNewsFeeds()
{
    &lt;span style="COLOR: #2b91af"&gt;DataTable &lt;/span&gt;dt = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;DataTable&lt;/span&gt;();

    &lt;span style="COLOR: blue"&gt;try
    &lt;/span&gt;{
        CommandText = &lt;span style="COLOR: #a31515"&gt;"NewsMashup.RetrieveNewsFeeds"&lt;/span&gt;;

        dt = Execute(&lt;span style="COLOR: #a31515"&gt;"NewsFeeds"&lt;/span&gt;);

    }
    &lt;span style="COLOR: blue"&gt;catch &lt;/span&gt;(System.&lt;span style="COLOR: #2b91af"&gt;Exception &lt;/span&gt;ex)
    {
        &lt;span style="COLOR: blue"&gt;throw &lt;/span&gt;ex;
    }

    &lt;span style="COLOR: blue"&gt;return &lt;/span&gt;dt;
}&lt;/pre&gt;
&lt;p&gt;It is clearer here than in the other method, again only two lines of code; one to initialise the CommandText the other to execute the stored procedure. This version of the Execute returns the datatable containing the results of the stored procedure’s execution.&lt;/p&gt;
&lt;p&gt;This shows examples of the code. The rest should be in the attached zip file&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=132093"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=132093" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/paulschapman/aggbug/132093.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>paulschapman</dc:creator>
            <guid>http://geekswithblogs.net/paulschapman/archive/2009/05/13/windows-azure-tds-wcf-silverlight-and-a-few-problems-on-again.aspx</guid>
            <pubDate>Thu, 14 May 2009 03:23:21 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/paulschapman/comments/132093.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/paulschapman/archive/2009/05/13/windows-azure-tds-wcf-silverlight-and-a-few-problems-on-again.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/paulschapman/comments/commentRss/132093.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/paulschapman/services/trackbacks/132093.aspx</trackback:ping>
        </item>
        <item>
            <title>Windows Azure, TDS, WCF, Silverlight and a few problems on the way Part I</title>
            <link>http://geekswithblogs.net/paulschapman/archive/2009/05/12/windows-azure-tds-wcf-silverlight-and-a-few-problems-on.aspx</link>
            <description>&lt;p&gt;If you have had a chance to look at the downloadable videos from MIX 09 (&lt;a href="http://videos.visitmix.com/MIX09/All"&gt;http://videos.visitmix.com/MIX09/All&lt;/a&gt;) then you will have heard that it will soon be possible to develop Azure hosted applications and have good old Transact SQL as a backend! It was in Nigel  Ellis’ session on ‘&lt;a target="_blank" href="http://videos.visitmix.com/MIX09/T06F"&gt;What's New in Microsoft SQL Data Services&lt;/a&gt;’ which gives all the details.&lt;/p&gt;
&lt;p&gt;However as of the time of writing this functionality, while due in the next couple of months, is not yet available. All is not lost. I am going to use the local Azure development environment to host an application and point it at my local SQL Server instance until such time that I can host it online.&lt;/p&gt;
&lt;p&gt;While writing this application there were a number of gotcha’s – some because Azure is beta, some not. The follow is how I wrote a small application to show news items, that constantly updates. The backend is a SQL database undated on a regular basis by an Azure Worker Role, then read by a Web Service called from a Silverlight application, itself hosted on an Azure WebRole.&lt;/p&gt;
&lt;p&gt;In developing this application, which I will be adapting for a much larger online one I am working on I will work from the Backend to the Silverlight application which makes up the client end.&lt;/p&gt;
&lt;h2&gt;Creating our database&lt;/h2&gt;
&lt;p&gt;According to the SQL Data Services session access to the database; either locally or from SQL Data Services will be via SQL Management Studio. Once the a database has been created it is time to create the tables that will store the details of our new stories;&lt;/p&gt;
&lt;p&gt;This project is actually part of a much larger one I am creating. For this reason I want to logically separate parts of the database using schemas. This for example will allow one database to have two tables called ledger – one in a schema called ‘Sales’ and one called ‘Purchases’. You will notice that all of the database objects created in the following examples of T/SQL are preceded by the word ‘NewsMashup’. To create this schema execute the following code against the SQL database;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&lt;/font&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;A Tables to store the sites from which feeds will be taken – this allows us to store a hyperlink to the parent site. &lt;/p&gt;
&lt;p&gt;One to store the details of feeds from which stories will be taken;&lt;/p&gt;
&lt;pre class="prettyprint"&gt;SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [NewsMashup].[Feeds](
	[Id] [bigint] IDENTITY(1,1) NOT NULL,
	[Url] [varchar](max) COLLATE Latin1_General_CI_AS NOT NULL,
	[Supplier] [bigint] NULL,
 CONSTRAINT [PK_NewsFeeds] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [NewsMashup].[Feeds]  WITH CHECK ADD  CONSTRAINT [FK_NewsFeeds_Supplier] FOREIGN KEY([Supplier])
REFERENCES [NewsMashup].[Supplier] ([Id])
GO
ALTER TABLE [NewsMashup].[Feeds] CHECK CONSTRAINT [FK_NewsFeeds_Supplier]&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;span class="kwrd"&gt;One table to store Stories as they are picked up&lt;/span&gt;&lt;/p&gt;
&lt;pre class="prettyprint"&gt;SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [NewsMashup].[Stories](
	[Id] [bigint] NOT NULL,
	[Headline] [varchar](max) COLLATE Latin1_General_CI_AS NOT NULL,
	[Description] [varchar](max) COLLATE Latin1_General_CI_AS NOT NULL,
	[Url] [varchar](max) COLLATE Latin1_General_CI_AS NOT NULL,
	[Supplier] [bigint] NOT NULL
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;and finally one table to store the sites from which the feeds will be taken&lt;/p&gt;
&lt;pre class="prettyprint"&gt;ALTER Procedure [NewsMashup].[RetrieveNewsFeeds]
As
Begin
	Select		NewsMashup.Supplier.Id			As Supplier,
				NewsMashup.Supplier.Name, 
				NewsMashup.Supplier.Url			As HomePage,
				NewsMashup.Feeds.Url
	From		NewsMashup.Feeds 
				INNER JOIN NewsMashup.Supplier ON 
					NewsMashup.Feeds.Supplier = NewsMashup.Supplier.Id
	Order By	NewsMashup.Supplier.Name
End&lt;/pre&gt;
&lt;h2&gt;Creating Stored Procedures to access and write data&lt;/h2&gt;
&lt;p&gt;In placing all database queries in a stored procedure you gain a number of advantages. Stored Procedures can be faster than inline code, partly this is because the database is able to partly compile and optimise your query. With inline code this happens at execution time. For the purposes of an application to display news headlines there are four stored procedures; the first to Create our Stories;&lt;/p&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;
&lt;pre class="prettyprint"&gt;ALTER Procedure [NewsMashup].[CreateStory]
	@Headline		VarChar(Max),
	@Description	VarChar(Max),
	@Url			VarChar(Max),
	@Supplier		BigInt,
	@PubDateValue	BigInt
As
Begin
	Declare @Counter		BigInt
	
	Set @Counter = (Select Count(*) As PreviousCounter From NewsMashup.Stories 
					Where Url = @Url)

	If @Counter = 0 
	Begin
		INSERT	INTO NewsMashup.Stories
			(Headline, Description, Url, Supplier, Id)
		VALUES	(@Headline,@Description,@Url,@Supplier,@PubDateValue)
	End 
End&lt;/pre&gt;
&lt;p&gt;It’s fairly simple this function. We first check to see if the link has already been added to the database. If not then the story is added. The next two procedures are both involved in retrieving headlines; we need two – one is used to retrieve the latest 10 stories from the database, the other retrieves any subsequent stories that may have been added to the database. This allows new stories to be added to the display as and when they are picked up.&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;CREATE SCHEMA [NewsMashup] AUTHORIZATION [dbo]&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;Retrieving the most recent 10 headlines &lt;/p&gt;
&lt;div class="csharpcode"&gt;
&lt;pre class="prettyprint"&gt;&lt;font face="Courier New"&gt;ALTER PROCEDURE [NewsMashup].[RetrieveHeadlines]
AS
BEGIN
	
	SET NOCOUNT ON;
	
	SELECT     TOP (10) NewsMashup.Stories.Id, NewsMashup.Stories.Headline, NewsMashup.Stories.Description, NewsMashup.Stories.Url, NewsMashup.Supplier.HasDescription, 
						  NewsMashup.Supplier.Name AS Supplier
	FROM         NewsMashup.Stories INNER JOIN
						  NewsMashup.Supplier ON NewsMashup.Stories.Supplier = NewsMashup.Supplier.Id
	ORDER BY NewsMashup.Stories.Id DESC
END&lt;/font&gt;&lt;/pre&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;&lt;/font&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Retrieving the latest new headlines&lt;/p&gt;
&lt;pre class="prettyprint"&gt;ALTER PROCEDURE [NewsMashup].[RetrieveHeadlines2]
	@LatestHeadline	BigInt
AS
BEGIN

	SET NOCOUNT ON;

	SELECT     Id, Headline, Description, Url, Supplier
	FROM         NewsMashup.Stories
	WHERE     (Id &amp;gt; @LatestHeadline)
	ORDER BY Id 
END&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;The final stored procedure retrieves the list of feeds from which headlines will be extracted. &lt;/p&gt;
&lt;pre class="prettyprint"&gt;ALTER Procedure [NewsMashup].[RetrieveNewsFeeds]
As
Begin
	Select		NewsMashup.Supplier.Id			As Supplier,
				NewsMashup.Supplier.Name, 
				NewsMashup.Supplier.Url			As HomePage,
				NewsMashup.Feeds.Url
	From		NewsMashup.Feeds 
				INNER JOIN NewsMashup.Supplier ON 
					NewsMashup.Feeds.Supplier = NewsMashup.Supplier.Id
	Order By	NewsMashup.Supplier.Name
End&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;That just about creates the database structures required to stored the News Headlines picked up by the application. Part II I will discuss the .Net libraries used to access these procedures.&lt;/p&gt;
&lt;div class="csharpcode"&gt;
&lt;pre class="prettyprint"&gt; &lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;&lt;![CDATA[
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }]]&gt;&lt;/style&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=132070"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=132070" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/paulschapman/aggbug/132070.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>paulschapman</dc:creator>
            <guid>http://geekswithblogs.net/paulschapman/archive/2009/05/12/windows-azure-tds-wcf-silverlight-and-a-few-problems-on.aspx</guid>
            <pubDate>Wed, 13 May 2009 04:22:37 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/paulschapman/comments/132070.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/paulschapman/archive/2009/05/12/windows-azure-tds-wcf-silverlight-and-a-few-problems-on.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/paulschapman/comments/commentRss/132070.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/paulschapman/services/trackbacks/132070.aspx</trackback:ping>
        </item>
        <item>
            <title>Implementing a Silverlight based &amp;lsquo;Vertical&amp;rsquo; tickertape</title>
            <link>http://geekswithblogs.net/paulschapman/archive/2009/03/31/implementing-a-silverlight-based-lsquoverticalrsquo-tickertape.aspx</link>
            <description>&lt;font size="2"&gt;&lt;font size="2"&gt;&lt;font color="#000000" size="2"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Calibri&amp;quot;, &amp;quot;sans-serif&amp;quot;; FONT-SIZE: 11pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-GB; mso-fareast-language: EN-US; mso-bidi-language: AR-SA; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; FONT-SIZE: 10pt; mso-no-proof: yes; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-GB; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;
&lt;h2 style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm; mso-outline-level: 2" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Arial&amp;quot;, &amp;quot;sans-serif&amp;quot;; FONT-SIZE: 18pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;Introduction&lt;/span&gt;&lt;/h2&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm; mso-outline-level: 2" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Arial&amp;quot;, &amp;quot;sans-serif&amp;quot;; FONT-SIZE: 10.5pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;I have a need of a ‘mash-up’ of business headlines for one of my current projects. For this I want an area where headlines enter at the bottom and the other headlines scroll up, vanishing at the top. If there are no new headlines, then the first headline appears at the bottom.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Arial&amp;quot;, &amp;quot;sans-serif&amp;quot;; FONT-SIZE: 10.5pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;Now generally when I work I like to build from the base up, build a part of the solution and then build on that. So for this reason the article does not deal with collecting the news – I’ll leave that one for another article. This will deal with just the scrolling region.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm; mso-outline-level: 2" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Arial&amp;quot;, &amp;quot;sans-serif&amp;quot;; FONT-SIZE: 18pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;Creating a Scrolling Region&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Arial&amp;quot;, &amp;quot;sans-serif&amp;quot;; FONT-SIZE: 10.5pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;Now to have a an area of a silverlight scroll an area we can use the &amp;lt;ScrollViewer&amp;gt; tag. This tag is replaced around whatever mark up we want to scroll. For the news feed or this example this will be a StackPanel, which will be orientated Vertical.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: blue; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #a31515; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;ScrollViewer&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: red; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt; x&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: blue; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;:&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: red; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;Name&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: blue; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;="ScrollRegion"&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt; &lt;br /&gt;
&lt;span style="COLOR: red"&gt;VerticalScrollBarVisibility&lt;/span&gt;&lt;span style="COLOR: blue"&gt;="Hidden"&lt;/span&gt; &lt;br /&gt;
&lt;span style="COLOR: red"&gt;HorizontalScrollBarVisibility&lt;/span&gt;&lt;span style="COLOR: blue"&gt;="Hidden"&lt;/span&gt; &lt;br /&gt;
&lt;span style="COLOR: red"&gt;BorderThickness&lt;/span&gt;&lt;span style="COLOR: blue"&gt;="0"&lt;/span&gt; &lt;br /&gt;
&lt;span style="COLOR: red"&gt;Background&lt;/span&gt;&lt;span style="COLOR: blue"&gt;="White"&lt;/span&gt; &lt;br /&gt;
&lt;span style="COLOR: red"&gt;Height&lt;/span&gt;&lt;span style="COLOR: blue"&gt;="150"&lt;/span&gt; &lt;br /&gt;
&lt;span style="COLOR: red"&gt;Width&lt;/span&gt;&lt;span style="COLOR: blue"&gt;="200"&lt;/span&gt; &lt;br /&gt;
&lt;span style="COLOR: red"&gt;Cursor&lt;/span&gt;&lt;span style="COLOR: blue"&gt;="Hand"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt; &lt;br /&gt;
&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;StackPanel&lt;/span&gt;&lt;span style="COLOR: red"&gt; x&lt;/span&gt;&lt;span style="COLOR: blue"&gt;:&lt;/span&gt;&lt;span style="COLOR: red"&gt;Name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;="ItemsStack"&lt;/span&gt;&lt;span style="COLOR: red"&gt; Orientation&lt;/span&gt;&lt;span style="COLOR: blue"&gt;="Vertical" &amp;gt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt; &lt;br /&gt;
&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;StackPanel&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt; &lt;br /&gt;
&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;ScrollViewer&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; FONT-SIZE: 10.5pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Arial&amp;quot;, &amp;quot;sans-serif&amp;quot;; FONT-SIZE: 10.5pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;The above code creates a scrollable region containing a stack with no border, white background. At the moment the stack panel is empty – this is because the content will be added by the code behind.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm; mso-outline-level: 2" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Arial&amp;quot;, &amp;quot;sans-serif&amp;quot;; FONT-SIZE: 18pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;Creating our ‘Sample’ headings.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Arial&amp;quot;, &amp;quot;sans-serif&amp;quot;; FONT-SIZE: 10.5pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;As this is an example, just to get an idea I’m not using real headlines but the Knights of the Roundtable. This is defined as an array of strings thus;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm; mso-outline-level: 2" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #2b91af; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;String[] Knights = { &lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #a31515; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;"King Arthur"&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #2b91af; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;, &lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #a31515; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;"Sir Lancelot"&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #2b91af; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;, &lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #a31515; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;"Sir Gawain"&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #2b91af; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;, &lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #a31515; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;"Sir Geraint"&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #2b91af; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;, &lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #a31515; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;"Sir Gareth"&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #2b91af; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;, &lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #a31515; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;"Sir Gaheris"&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #2b91af; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;, &lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #a31515; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;"Sir Bedivere"&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #2b91af; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;, &lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #a31515; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;"Sir Galahad"&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #2b91af; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;, &lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #a31515; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;"Sir Kay"&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #2b91af; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;, &lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #a31515; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;"Sir Bors de Ganis"&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #2b91af; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;, &lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #a31515; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;"Sir Lamorak"&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #2b91af; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;, &lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #a31515; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;"Sir Tristan"&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #2b91af; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;, &lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #a31515; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;"Sir Percivale"&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt; &lt;br /&gt;
};&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm; mso-outline-level: 2" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Arial&amp;quot;, &amp;quot;sans-serif&amp;quot;; FONT-SIZE: 18pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;Adding our ‘Sample’ headings&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Arial&amp;quot;, &amp;quot;sans-serif&amp;quot;; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;Adding entries to our stack panel is fairly simple. We first get a reference to the stack panel, create a textblock, set the text to our next entry and add the textblock to the Children of the StackPanel&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm; mso-outline-level: 2" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #2b91af; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;StackPanel&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt; sp = FindName(&lt;span style="COLOR: #a31515"&gt;"ItemsStack"&lt;/span&gt;) &lt;span style="COLOR: blue"&gt;as&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;StackPanel&lt;/span&gt;; &lt;br /&gt;
&lt;span style="COLOR: #2b91af"&gt;TextBlock&lt;/span&gt; tb = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;TextBlock&lt;/span&gt;(); &lt;br /&gt;
tb.Text = Knights[0];&lt;br /&gt;
sp.Children.Add(tb);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm; mso-outline-level: 2" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Arial&amp;quot;, &amp;quot;sans-serif&amp;quot;; FONT-SIZE: 18pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;Setting up the automatic addition of entries&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Arial&amp;quot;, &amp;quot;sans-serif&amp;quot;; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;We need our application to automatically add new entries to the news feed every so often. To do this we need something that fires after a predetermined period of time and for this we use the DispatchTimer class.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #2b91af; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;DispatcherTimer&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt; dispatchTimer;&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: blue; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;.&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: blue; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;.&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: blue; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;.&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: blue; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;&lt;br /&gt;
public&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt; Page()&lt;br /&gt;
{&lt;br /&gt;
InitializeComponent();&lt;br /&gt;
&lt;span style="COLOR: #2b91af"&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: #2b91af"&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;span style="COLOR: #2b91af"&gt;.&lt;/span&gt;&lt;br /&gt;
dispatchTimer = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;DispatcherTimer&lt;/span&gt;();&lt;br /&gt;
dispatchTimer.Interval = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;TimeSpan&lt;/span&gt;(0, 0, 30); &lt;span style="COLOR: green"&gt;// 30 Seconds&lt;br /&gt;
&lt;/span&gt;dispatchTimer.Tick +=&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;EventHandler&lt;/span&gt;(dispatchTimer_Tick);&lt;br /&gt;
dispatchTimer.Start();&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Arial&amp;quot;, &amp;quot;sans-serif&amp;quot;; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;span style="COLOR: black"&gt;What we now need is for new headings to be added to the display each time the interval fires and for this we define a handler for the Tick event&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Arial&amp;quot;, &amp;quot;sans-serif&amp;quot;; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;Adding is the same as the section above, but there are a number of additional activities that must be dealt with when adding more than the first entry. First we need to know how much space is taken up by the new heading. Once we have added the text to it silverlight provides the height taken up by it from the ‘ActualHeight’ property.&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Arial&amp;quot;, &amp;quot;sans-serif&amp;quot;; COLOR: blue; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;UsedHeight += tb.ActualHeight;&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: blue; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt; &lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: green; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;// increment the area that has been filled up till now&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: blue; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Arial&amp;quot;, &amp;quot;sans-serif&amp;quot;; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;Next we check to see if in adding the entry the display area needs to scroll and to do this we compare our ‘UsedHeight’ with the actual height of the StackPanel&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Arial&amp;quot;, &amp;quot;sans-serif&amp;quot;; COLOR: blue; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: blue; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;if &lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;(UsedHeight &amp;gt; sp.ActualHeight)&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: blue; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Arial&amp;quot;, &amp;quot;sans-serif&amp;quot;; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;Now if it has scrolled, certain items will have vanished off the top of the region. So the application loops through each entry to see if it any part of the entry has gone over the top and then removes it.&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Arial&amp;quot;, &amp;quot;sans-serif&amp;quot;; COLOR: blue; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: blue; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;for&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt; (i = 0; i &amp;lt; sp.Children.Count; i++)&lt;br /&gt;
{&lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #2b91af; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;TextBlock&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt; tbVisible = sp.Children[i] &lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: blue; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;as&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt; &lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: #2b91af; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;TextBlock&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;;&lt;br /&gt;
ItemHeight += tbVisible.ActualHeight;&lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: blue; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;if&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt; ((ItemHeight &amp;lt;= UsedHeight - sp.ActualHeight) || ((ItemHeight - tbVisible.ActualHeight)) &amp;lt; (UsedHeight - sp.ActualHeight))&lt;br /&gt;
{&lt;br /&gt;
UsedHeight -= tbVisible.ActualHeight; &lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: green; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;// remove from the used height, the space taken by the item&lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;sp.Children.RemoveAt(i); &lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: green; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;// now remove the item from the stackpanel&lt;br /&gt;
&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Courier New&amp;quot;; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;}&lt;br /&gt;
}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Arial&amp;quot;, &amp;quot;sans-serif&amp;quot;; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;We also remove the space used by the entry from our used space counter.&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Arial&amp;quot;, &amp;quot;sans-serif&amp;quot;; COLOR: blue; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN: 7.5pt 0cm" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: &amp;quot;Arial&amp;quot;, &amp;quot;sans-serif&amp;quot;; COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;And that is how to create a scrollable region. I’ll be doing the actual collection of news items later and will likely post how that works at that point.&lt;/span&gt;&lt;span style="FONT-FAMILY: &amp;quot;Arial&amp;quot;, &amp;quot;sans-serif&amp;quot;; COLOR: blue; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130558"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130558" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/paulschapman/aggbug/130558.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>paulschapman</dc:creator>
            <guid>http://geekswithblogs.net/paulschapman/archive/2009/03/31/implementing-a-silverlight-based-lsquoverticalrsquo-tickertape.aspx</guid>
            <pubDate>Wed, 01 Apr 2009 03:58:05 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/paulschapman/comments/130558.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/paulschapman/archive/2009/03/31/implementing-a-silverlight-based-lsquoverticalrsquo-tickertape.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/paulschapman/comments/commentRss/130558.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/paulschapman/services/trackbacks/130558.aspx</trackback:ping>
        </item>
        <item>
            <title>Getting WCF to work with Azure</title>
            <link>http://geekswithblogs.net/paulschapman/archive/2009/01/07/getting-wcf-to-work-with-azure.aspx</link>
            <description>&lt;p&gt;Silverlight makes creating compelling Rich Internet Applications fairly easy. That said the cut down version of .Net means some things that you would do within an application have to be relegated to Web Services which can benefit from the full .Net library. One of these is of course Azure, after all that is the whole point - an online store of Business Logic and data.&lt;/p&gt;
&lt;p&gt;The application I'm working on uses Silverlight on the front end, and Azure will provide the bulk of the backend. There are reasons for this; my budget for the site is not that large, adopting Azure means first off that it will be free during development, but almost as important - hosting costs will be related to the success of the site. &lt;/p&gt;
&lt;p&gt;Thing is dealing with pre-beta software has meant an increase in grey hairs and those that are left are getting fewer. One of the parts that needs looking at is in WCF. If you run the Azure Labs the WCF lab does not work. This is because the Development Fabric is not hosting the service correctly, and WCF metadata is not being returned correctly.&lt;/p&gt;
&lt;p&gt;Thanks must go to David Burela and his &lt;a target="_blank" href="http://davidburela.wordpress.com/"&gt;&lt;font color="#800080"&gt;House-o-blog&lt;/font&gt;&lt;/a&gt;. In it he describes a way to get WCF working despite the problems with the Development Fabric. So what I thought I would do is write a version of the Azure Services Training Kits Exercise 3: Hosting a WCF Service&lt;/p&gt;
&lt;p&gt;So the following is Exercise 3, but with the changes made to ensure it works&lt;/p&gt;
&lt;p&gt;1. Open the project you created in Exercise 2 or open the &lt;strong&gt;begin.sln&lt;/strong&gt; solution file located in &lt;strong&gt;C:\AzureServicesKit\Labs\BuildingWindowsAzureServices\Ex03-HostingWCFService\begin\&lt;/strong&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;If you closed Visual Studio, be sure to open it elevated as &lt;strong&gt;Administrator&lt;/strong&gt;, from &lt;strong&gt;Start | All Programs | Microsoft Visual Studio 2008 right-click Microsoft Visual Studio 2008&lt;/strong&gt; and choose &lt;strong&gt;Run as Administrator&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;2. Add the WCF service file. To do this, right-click the &lt;strong&gt;RDCompute_WebRole&lt;/strong&gt; node in &lt;strong&gt;Solution Explorer&lt;/strong&gt;, point to &lt;strong&gt;Add&lt;/strong&gt; and select &lt;strong&gt;New Item&lt;/strong&gt;. In the &lt;strong&gt;Add New Item&lt;/strong&gt; dialog, select the &lt;strong&gt;WCF Service&lt;/strong&gt; template, change the Name to &lt;strong&gt;&lt;em&gt;MessageLogger.svc&lt;/em&gt;&lt;/strong&gt;, and then click &lt;strong&gt;Add&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/GettingWCFtoworkwithAzure_1446C/image_2.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="388" alt="Add New Item" width="644" border="0" src="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/GettingWCFtoworkwithAzure_1446C/image_thumb.png" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;The template adds an &lt;strong&gt;IMessageLogger&lt;/strong&gt; interface, which defines the service contract and a &lt;strong&gt;MessageLogger&lt;/strong&gt; class that implements the contract.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;3. Update the contract interface to define a method to send messages to the service. Open the &lt;strong&gt;&lt;em&gt;IMessageLogger.cs&lt;/em&gt;&lt;/strong&gt; file in the text editor. This file contains the generated &lt;strong&gt;IMessageLogger&lt;/strong&gt; interface, which includes a single method named &lt;strong&gt;DoWork&lt;/strong&gt;. Delete this method, and insert a &lt;strong&gt;LogMessage&lt;/strong&gt; method to replace it (shown highlighted in bold text below.) &lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New" size="2"&gt;[ServiceContract] &lt;br /&gt;
public interface IMessageLogger &lt;br /&gt;
{ &lt;br /&gt;
  [OperationContract] &lt;br /&gt;
  &lt;strong&gt;void LogMessage(string message); &lt;br /&gt;
&lt;/strong&gt;}&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;4. Implement the contract interface in the &lt;strong&gt;MessageLogger&lt;/strong&gt; service. Open the &lt;strong&gt;&lt;em&gt;MessageLogger.&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;svc.&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;cs&lt;/em&gt;&lt;/strong&gt; file in the text editor. This file contains the service implementation and includes a skeleton &lt;strong&gt;DoWork&lt;/strong&gt; method. Again, delete this method and insert the following code that implements the &lt;strong&gt;LogMessage&lt;/strong&gt; method in its place. &lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New" size="2"&gt;public void LogMessage(string message) &lt;br /&gt;
{ &lt;br /&gt;
     MessageHelper.SaveMessage(message); &lt;br /&gt;
} &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;5. Change the binding of the &lt;strong&gt;IMessageLogger&lt;/strong&gt; endpoint to use a &lt;strong&gt;&lt;em&gt;basicHttpBinding&lt;/em&gt;&lt;/strong&gt;. Open the &lt;strong&gt;&lt;em&gt;Web.config&lt;/em&gt;&lt;/strong&gt; file in the text editor and locate the &lt;strong&gt;&lt;em&gt;RDCompute_&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;WebRole&lt;/em&gt;&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;.MessageLogger&lt;/em&gt;&lt;/strong&gt; service configuration in the &lt;strong&gt;services&lt;/strong&gt; section inside &lt;strong&gt;system.serviceModel&lt;/strong&gt;. This should be towards the end of the file. Change the &lt;strong&gt;binding&lt;/strong&gt; attribute of the single endpoint contained in this section from &lt;strong&gt;&lt;em&gt;wsHttpBinding&lt;/em&gt;&lt;/strong&gt; to &lt;strong&gt;&lt;em&gt;basicHttpBinding&lt;/em&gt;&lt;/strong&gt;. The endpoint configuration after the change should be as follows: &lt;/p&gt;
&lt;pre&gt;&amp;lt;endpoint address="" binding="basicHttpBinding" contract="RDCompute_WebRole.IMessageLogger"&amp;gt;
  &amp;lt;identity&amp;gt;
    &amp;lt;dns value="localhost" /&amp;gt;
  &amp;lt;/identity&amp;gt;
&amp;lt;/endpoint&amp;gt;&lt;/pre&gt;
&lt;pre&gt;&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;6. Right click on the ASP.Net project (&lt;strong&gt;AzureWCFDemo_WebRole&lt;/strong&gt;) and set it as the startup project&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;7. Right click on the MessageLogger.svc file and select View in Browser&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;8. When IE starts copy the address displayed in the Address Bar to the clipboard&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;9. Start a new instance of Visual Studio&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;10. Create a console client project by select File, New Project&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/GettingWCFtoworkwithAzure_1446C/image_4.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="386" alt="image" width="644" border="0" src="http://geekswithblogs.net/images/geekswithblogs_net/paulschapman/WindowsLiveWriter/GettingWCFtoworkwithAzure_1446C/image_thumb_1.png" /&gt;&lt;/a&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;11. Add a reference to the message logging service. In &lt;strong&gt;Solution Explorer&lt;/strong&gt;, right-click the &lt;strong&gt;Message&lt;/strong&gt;&lt;strong&gt;Generator&lt;/strong&gt; project node, and select &lt;strong&gt;Add Service Reference&lt;/strong&gt;. &lt;br /&gt;Paste the address you copied from the IE instance into the &lt;strong&gt;Add Service Reference&lt;/strong&gt; dialog and click Discover. Change the &lt;strong&gt;Namespace&lt;/strong&gt; to &lt;strong&gt;RDService&lt;/strong&gt; and click &lt;strong&gt;OK&lt;/strong&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;12. Add the following code to the main function&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;strong&gt;using (RDService.MessageLoggerClient client = new RDService.MessageLoggerClient())&lt;/strong&gt;
&lt;strong&gt;  {&lt;/strong&gt;
&lt;strong&gt;    Console.WriteLine("Enter your messages ('quit' to exit)");&lt;/strong&gt;
&lt;strong&gt;    while (true)&lt;/strong&gt;
&lt;strong&gt;    {&lt;/strong&gt;
&lt;strong&gt;      try&lt;/strong&gt;
&lt;strong&gt;      {&lt;/strong&gt;
&lt;strong&gt;        string message = Console.ReadLine();&lt;/strong&gt;
&lt;strong&gt;        if (message.Equals("quit", StringComparison.CurrentCultureIgnoreCase))&lt;/strong&gt;
&lt;strong&gt;          break;&lt;/strong&gt;
&lt;strong&gt;        client.LogMessage(message);&lt;/strong&gt;
&lt;strong&gt;      }&lt;/strong&gt;
&lt;strong&gt;      catch (Exception ex)&lt;/strong&gt;
&lt;strong&gt;      {&lt;/strong&gt;
&lt;strong&gt;           Console.WriteLine(ex.Message);&lt;/strong&gt;
&lt;strong&gt;      }&lt;/strong&gt;
&lt;strong&gt;    }&lt;/strong&gt;
&lt;strong&gt;  }&lt;/strong&gt;
&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;13. Return to the instance of Visual Studio running the ASP.Net application and stop debugging the ASP.Net Application&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;13. Right click the Azure project and set as the Start-up project, then start debugging. The Dev Fabric should start running and hosting the WCF service. &lt;br /&gt;When IE starts note the port number. More than likely this will be 81.&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;14. Finally, go back to our client project. Open the app.config file and change the endpoint address so that is the port number found in the previous step.&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;15. Now run the client project. It should be able to call the WCF Service hosted within the Development Fabric&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&lt;/font&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;font face="Trebuchet MS"&gt;If everything worked you should have completed Exercise 3. Hopefully a fix to the problem will be forthcoming. Excercise 4 should be fun, since in this instance &lt;br /&gt;we will be calling the Web Service from within Azure (rather than a standard Windows Application) and so this technique may need adapting.&lt;/font&gt;&lt;/pre&gt;
&lt;/pre&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=128468"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=128468" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/paulschapman/aggbug/128468.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>paulschapman</dc:creator>
            <guid>http://geekswithblogs.net/paulschapman/archive/2009/01/07/getting-wcf-to-work-with-azure.aspx</guid>
            <pubDate>Thu, 08 Jan 2009 05:04:11 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/paulschapman/comments/128468.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/paulschapman/archive/2009/01/07/getting-wcf-to-work-with-azure.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/paulschapman/comments/commentRss/128468.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/paulschapman/services/trackbacks/128468.aspx</trackback:ping>
        </item>
    </channel>
</rss>