<?xml version="1.0" encoding="utf-8"?>
<feed
    xmlns="http://www.w3.org/2005/Atom"
    xmlns:at="http://www.sixapart.com/ns/at"
    xmlns:icbm="http://postneo.com/icbm"
    xmlns:rvw="http://purl.org/NET/RVW/0.2/"
    xml:lang="en">
    <title>.NET</title>
    <link rel="self" type="application/atom+xml" title=".NET (Atom)" href="http://net.groups.vox.com/library/posts/page/1/atom.xml" />
    <link rel="alternate" type="text/html" title=".NET" href="http://net.groups.vox.com/library/posts/page/1/"/> 
    <link rel="service.subscribe" type="application/atom+xml" title=".NET" href="http://net.groups.vox.com/library/posts/atom.xml" />    
    <link rel="next" type="application/atom+xml" title=".NET" href="http://net.groups.vox.com/library/posts/page/2/atom.xml" /> 
    <link rel="last" type="application/atom+xml" title=".NET" href="http://net.groups.vox.com/library/posts/page/7/atom.xml" />  
    <generator uri="http://www.vox.com/">Vox</generator>
    <updated>2008-07-23T00:17:48Z</updated> 
    <id>tag:vox.com,2006:6p00d09e4dfabebe2b/</id> 
    <subtitle>Microsoft .NET Programmers</subtitle>  
    
    <entry>
        <title>Too late, I bought it anyways</title>   
        <link rel="alternate" type="text/html" title="Too late, I bought it anyways" href="http://net.groups.vox.com/library/post/6a00c2251e5b66549d00fad69c2d290005.html?_c=feed-atom-full" />  
        <link rel="service.post" type="application/atom+xml" title="Too late, I bought it anyways" href="http://net.groups.vox.com/library/post/6a00c2251e5b66549d00fad69c2d290005.html?_c=feed-atom-full#comments" /> 
        <link rel="service.edit" type="application/atom+xml" title="Too late, I bought it anyways" href="http://www.vox.com/atom/svc=post/asset_id=6a00c2251e5b66549d00fad69c2d290005" />          <id>tag:vox.com,2008-07-23:asset-6a00c2251e5b66549d00fad69c2d290005</id>
        <published>2008-07-23T00:17:48Z</published>
        <updated>2008-07-23T00:17:48Z</updated>
    
        <author>
            <name>Thomas Holloway</name>
            <uri>http://nyxtom.vox.com/?_c=feed-atom-full</uri>
        </author>
    
        
        <content type="html" xml:base="http://nyxtom.vox.com/?_c=feed-atom-full">
            <![CDATA[
                <div xmlns="http://www.w3.org/1999/xhtml" xmlns:at="http://www.sixapart.com/ns/at">
        <p>You guys took too long so I went ahead and got the Violin myself. I&#39;m still curious what it would take to get something out of this community though. How about this, a project of some sort: using whatever technologies you want be it JavaScript, Silverlight, WPF or just plain ol&#39; web programming. We don&#39;t necessarily have to have an exchange of money persay, but it would be nice to create something together. We can take a vote or something...Here&#39;s another picture for clarity.<img alt="http://nyxtom.googlepages.com/websiteforawesomeness.jpg" src="http://nyxtom.googlepages.com/websiteforawesomeness.jpg" /><br /><strong>Note</strong>: Be creative, if that makes any sense.</p><p>I&#39;ll update as soon as my Violin comes in. I&#39;m pysched.<br /> </p>   <p style="clear:both;"> 
    <a href="http://net.groups.vox.com/library/post/6a00c2251e5b66549d00fad69c2d290005.html?_c=feed-atom-full#comments">Read and post comments</a>   |   
    <a href="http://www.vox.com/share/6a00c2251e5b66549d00fad69c2d290005?_c=feed-atom-full">Send to a friend</a> 
</p>

                </div>
            ]]>
        </content> 
    <category term="community" scheme="http://net.groups.vox.com/tags/community/" label="community" /> 
    <category term="technology" scheme="http://net.groups.vox.com/tags/technology/" label="technology" /> 
    <category term="violin" scheme="http://net.groups.vox.com/tags/violin/" label="violin" /> 
    <category term="pat" scheme="http://net.groups.vox.com/tags/pat/" label="pat" /> 
    <category term="project" scheme="http://net.groups.vox.com/tags/project/" label="project" /> 
    <category term="back" scheme="http://net.groups.vox.com/tags/back/" label="back" /> 
    <category term="website" scheme="http://net.groups.vox.com/tags/website/" label="website" /> 
    <category term="trade" scheme="http://net.groups.vox.com/tags/trade/" label="trade" /> 
    <category term="exchange" scheme="http://net.groups.vox.com/tags/exchange/" label="exchange" /> 
    <category term="something" scheme="http://net.groups.vox.com/tags/something/" label="something" /> 
    <category term="collaboration" scheme="http://net.groups.vox.com/tags/collaboration/" label="collaboration" /> 
    </entry> 
    
    <entry>
        <title>Idea for Simple Multi-threaded Software</title>   
        <link rel="alternate" type="text/html" title="Idea for Simple Multi-threaded Software" href="http://net.groups.vox.com/library/post/6a00c22525ad91604a00fad69bbb680005.html?_c=feed-atom-full" />  
        <link rel="service.post" type="application/atom+xml" title="Idea for Simple Multi-threaded Software" href="http://net.groups.vox.com/library/post/6a00c22525ad91604a00fad69bbb680005.html?_c=feed-atom-full#comments" /> 
        <link rel="service.edit" type="application/atom+xml" title="Idea for Simple Multi-threaded Software" href="http://www.vox.com/atom/svc=post/asset_id=6a00c22525ad91604a00fad69bbb680005" />          <id>tag:vox.com,2008-07-21:asset-6a00c22525ad91604a00fad69bbb680005</id>
        <published>2008-07-21T16:25:14Z</published>
        <updated>2008-07-22T19:25:20Z</updated>
    
        <author>
            <name>jcoehoorn</name>
            <uri>http://jcoehoorn.vox.com/?_c=feed-atom-full</uri>
        </author>
    
        
        <content type="html" xml:base="http://jcoehoorn.vox.com/?_c=feed-atom-full">
            <![CDATA[
                <div xmlns="http://www.w3.org/1999/xhtml" xmlns:at="http://www.sixapart.com/ns/at">
        <p>As multi-core CPUs become more and more common, the ability to write quality software that takes advantage of them will become more important.&#160; The tools currently available are not adequate to this task.&#160; We are seeing a few things emerge to help solve the problem.&#160; One good example is the shift back to web applications hosted on a server.&#160; Web applications automatically run in parallel; each request can get it&#39;s own thread.&#160; However, there&#39;s still a shortage of simple, effective techiques for building parallel software on the desktop.</p><p>I had an idea of one place that where it would be very easy to build a parallel software approach into the programming language, so that developers can take advantage of a multi-core cpu in certain situations without having to do extra work.&#160; This idea is obvious enough that it probably isn&#39;t new to me, but I don&#39;t think I&#39;ve read about it anywhere else and so I wanted to write it out here.</p><p>What I want to do is updated the standard &quot;foreach&quot; loop that&#39;s included in most modern programming languages.&#160; .Net, java, PHP, Python, and more all have this simple loop.&#160; In a for each loop, you specify an operation to be performed on every item in a collection of items.&#160; Current implementations of this loop always run in serial.&#160; Process one item, and when that one is finished get the next and process it.&#160; However, much of the time this could be done in parallel.&#160; My idea is that you could bake this concept into a programming language by making a simple change to your loop declaration.&#160; For example, take this simple C# loop declaration.&#160; Instead of this:</p><blockquote><p><span style="color: #3366ff">foreach </span>(<span style="color: #3366ff">object </span>Item <span style="color: #3366ff">in </span>MyCollection)<br /></p></blockquote><p>Do this:</p><blockquote><p><span style="color: #3366ff">forevery </span>(<span style="color: #3366ff">object </span>Item <span style="color: #3366ff">in </span>MyCollection)<br /></p></blockquote><p>Change just one key word and the compiler knows it can use create separate threads for the contents of the loop.&#160; <span style="color: #3366ff"></p></span><p>Of course, there are situations where these loops should not be run in parallel.&#160; Maybe you need to break early.&#160; Or maybe you&#39;re building a count as you go.&#160; But this should be relatively easy for the programmer to determine, and they can always use the old behavior when needed.</p><p>Are there any languages out there that already implement this concept?<br /></p>   <p style="clear:both;"> 
    <a href="http://net.groups.vox.com/library/post/6a00c22525ad91604a00fad69bbb680005.html?_c=feed-atom-full#comments">Read and post comments</a>   |   
    <a href="http://www.vox.com/share/6a00c22525ad91604a00fad69bbb680005?_c=feed-atom-full">Send to a friend</a> 
</p>

                </div>
            ]]>
        </content> 
    </entry> 
    
    <entry>
        <title>VB.Net vs C#, Round 2: Partial Namespaces</title>   
        <link rel="alternate" type="text/html" title="VB.Net vs C#, Round 2: Partial Namespaces" href="http://net.groups.vox.com/library/post/6a00c22525ad91604a00fae8cce237000b.html?_c=feed-atom-full" />  
        <link rel="service.post" type="application/atom+xml" title="VB.Net vs C#, Round 2: Partial Namespaces" href="http://net.groups.vox.com/library/post/6a00c22525ad91604a00fae8cce237000b.html?_c=feed-atom-full#comments" /> 
        <link rel="service.edit" type="application/atom+xml" title="VB.Net vs C#, Round 2: Partial Namespaces" href="http://www.vox.com/atom/svc=post/asset_id=6a00c22525ad91604a00fae8cce237000b" />          <id>tag:vox.com,2008-07-17:asset-6a00c22525ad91604a00fae8cce237000b</id>
        <published>2008-07-17T17:31:25Z</published>
        <updated>2008-07-20T03:22:15Z</updated>
    
        <author>
            <name>jcoehoorn</name>
            <uri>http://jcoehoorn.vox.com/?_c=feed-atom-full</uri>
        </author>
    
        
        <content type="html" xml:base="http://jcoehoorn.vox.com/?_c=feed-atom-full">
            <![CDATA[
                <div xmlns="http://www.w3.org/1999/xhtml" xmlns:at="http://www.sixapart.com/ns/at">
        <p>I&#39;ve <a href="http://jcoehoorn.vox.com/library/post/why-i-like-vbnet-over-c.html">talked about this before</a>, and I don&#39;t want to go over the same issues a second time.&#160; However, I recently had a project where I finally spent a few weeks in C#, with no VB work at all.&#160; At last, I had a chance to develop a deeper familiarity with C#.&#160; Maybe I would learn something new.&#160; </p><p>The result?&#160; C# moves closer to VB.Net in my estimation, but doesn&#39;t quite pass it.&#160; All of the short-comings when compared to VB.Net still exist in my mind, but now I&#39;ve had the chance to get a feel for what C# does about them.&#160; I can&#39;t put my finger on it, but there are little things here and there in C# that make up for a lot of what I complained about before.&#160; For example, I still prefer seeing &quot;End If&quot;, &quot;End Sub&quot;, &quot;End Class&quot;, etc to the more ambiguous &quot;}&quot;.&#160; But now that I&#39;ve used C# more it&#39;s not as big a deal.&#160; I like the VB way, but I&#39;m not as handicapped by C# as I was.&#160; The gap is still there, but it&#39;s not as wide.</p><p>The experience did bring one new shorting coming in C# that I didn&#39;t write about before.&#160; VB.Net supports partial namespaces; C# does not.&#160; Let me explain.&#160; Imagine you want to read from a file.&#160; In .Net, that means using the System.IO namespace.&#160; With Visual Basic, System is imported by default and child namespaces are automatically resolved.&#160; So, for example, to see if a file exists I can just say something like this:<br /><blockquote><p><span style="color: #3366ff">If </span>IO.File.Exists(<span style="color: #144692">&quot;foo.bar&quot;</span>) <span style="color: #3366ff">Then </span><br /></p></blockquote>That won&#39;t work in C#.&#160; You have to either type out System.IO.File or add a using directive for System.IO at the top of the file.&#160; Now the IO namespace this isn&#39;t a big deal.&#160; You&#39;re probably going to use the classes from the namespace a dozen times if you use them once, or it&#39;s not a lot to type otherwise.&#160;&#160; It does pollute your intellisense namespace though, and it starts to become annoying when you also need StringBuilder and have to import System.Text but aren&#39;t using anything else from that namespace.&#160; Or maybe you need a single Dataset, but nothing else from System.Data.&#160; You can quickly accumulate several using directives that only exist to support one class declaration.&#160; The point is that the class library heirarchy in .Net is rather flat, and there are a lot of little things you might want that in C# that all require a using directive where VB.Net does not.</p><p><br />So C# doesn&#39;t let you use a partial namespace in a declaration.&#160; Big deal.&#160; Well, this example only illustrates the least of my complaints.&#160; The worst things about what I&#39;ve shown so far are that it leads to a polluted intellisense prompt and that it breaks your flow to have to jump to the top of the page to add the declaration and then jumb back versus simply typing a shorter name.&#160; If this was all there was to it I would just keep my mouth shut and deal with it.&#160; But there are other, more important manifestations.&#160; I&#39;ll give two examples.</p><p>Say you&#39;re working on a project that involves a lot of XML.&#160; You&#39;ll probably import the System.Xml namespace.&#160; In C# you may also need to import one or more of System.Xml.Schema, System.Xml.XPath, System.Xml.Serialization, or System.Xml.Xsl.&#160; And now you&#39;re using a whole bunch of different classes with no reference in the code for which specific namespace each class came from.&#160; In VB.Net you can just preface the class names of classes not directly in the Xml namespace with only the missing child namespace.&#160; For example, if I choose not to import System.Xml.Schema but already have System.Xml I can still just say &quot;Schema.XmlSchema&quot; instead of &quot;System.Xml.Schema.XmlSchema&quot;.&#160; <span style="color: #144692"></p></span><p>That sounds a lot like the same complaint I had earlier, and it usually ends up requiring a little more typing than importing all the namespaces once.&#160; What&#39;s new, though, is that in my opinion this has the potential tomake the code easier to understand.&#160; The specific example of &quot;Schema.XmlSchema&quot; is pretty redundant, but there are plenty of cases where having one level of the namespace with the class would add clarity to the declaration.&#160; This is especially true for junior developers who may not be totally familiar with the framework.&#160; Used correctly, it can provide just a little bit of important context for each of your declarations.</p><p>Now for the next example.&#160; After all, the Xml namespace is pretty well understood.&#160; Also, my XML example wasn&#39;t very good; what do we need the extra context for?&#160; Fair enough.&#160; Let&#39;s look at something even more relevant.&#160; What if you&#39;re working on a project where you want to use a third party library?&#160; In this case, being able to see a small amount of context for each class may have a little more value.&#160; And what if you&#39;ve never used this library before?&#160; </p><p>The <a href="http://sharpdevelop.net/OpenSource/SharpZipLib/">SharpZipLib</a> comes to mind as a reasonable example.&#160; Imagine your project involved using the library to untar some files.&#160; In C# you would import ICSharpCode.SharpZipLib.Tar and then type class names as usuall.&#160; However, there is no help from the IDE in finding out what those classes are without re-typing the entire namespace every time.&#160; This shows one final reason why partial namespaces are useful.&#160; In VB.Net you just import ICSharpCode.SharpZipLib.&#160; Now, if you only type &quot;Tar.&quot; you get an intellisense list of members of that namespace as soon as you hit the period key.&#160; For this reason, I find VB.Net is much easier to work with when learning the ins and outs of a new library.</p><p>In summary, I really like VB.Net&#39;s ability to use partial namespaces in declarations.&#160; There&#39;s probably a more official name for the feature, but I don&#39;t know
it.&#160; It might even be something you can just turn on as an option for a project in
C#, in which case I hope someone will tell me where to find that option.&#160; I think the feature promotes code that is more readable, doesn&#39;t break the flow of the programmer as often, keeps your intellisense namespace clearer, and aids in learning new libraries.</p><p></p><p><br /> </p>   <p style="clear:both;"> 
    <a href="http://net.groups.vox.com/library/post/6a00c22525ad91604a00fae8cce237000b.html?_c=feed-atom-full#comments">Read and post comments</a>   |   
    <a href="http://www.vox.com/share/6a00c22525ad91604a00fae8cce237000b?_c=feed-atom-full">Send to a friend</a> 
</p>

                </div>
            ]]>
        </content> 
    </entry> 
    
    <entry>
        <title>Make your Code as Useful as Possible</title>   
        <link rel="alternate" type="text/html" title="Make your Code as Useful as Possible" href="http://net.groups.vox.com/library/post/6a00c22525ad91604a00fad69a3d7d0005.html?_c=feed-atom-full" />  
        <link rel="service.post" type="application/atom+xml" title="Make your Code as Useful as Possible" href="http://net.groups.vox.com/library/post/6a00c22525ad91604a00fad69a3d7d0005.html?_c=feed-atom-full#comments" /> 
        <link rel="service.edit" type="application/atom+xml" title="Make your Code as Useful as Possible" href="http://www.vox.com/atom/svc=post/asset_id=6a00c22525ad91604a00fad69a3d7d0005" />          <id>tag:vox.com,2008-07-16:asset-6a00c22525ad91604a00fad69a3d7d0005</id>
        <published>2008-07-16T17:35:23Z</published>
        <updated>2008-07-16T20:23:39Z</updated>
    
        <author>
            <name>jcoehoorn</name>
            <uri>http://jcoehoorn.vox.com/?_c=feed-atom-full</uri>
        </author>
    
        
        <content type="html" xml:base="http://jcoehoorn.vox.com/?_c=feed-atom-full">
            <![CDATA[
                <div xmlns="http://www.w3.org/1999/xhtml" xmlns:at="http://www.sixapart.com/ns/at">
        <p>I don&#39;t know how many times I&#39;ve seen code similar to the following on programming help forums:</p><blockquote><p><span style="color: #3366ff">Function </span>MyMethod(<span style="color: #3366ff">ByVal </span>InputParameter() <span style="color: #3366ff">As String</span>) As <span style="color: #3366ff">String</span>()<br />&#160;&#160;&#160; <span style="color: #339933">&#39;Do Stuff here that returns a different string array</span><br /><span style="color: #3366ff">End Function</span><br /></p></blockquote><p>That&#39;s okay.&#160; We can make that work just fine.&#160; I mean, it could be worse; they could have used an <em>ArrayList</em>.&#160; But we can do better, too.&#160; Now look at this code:</p><blockquote><p><span style="color: #3366ff">Function </span>MyNewMethod(<span style="color: #3366ff">ByVal </span>InputParameter <span style="color: #3366ff">As </span>IEnumerable(<span style="color: #3366ff">Of</span> <span style="color: #3366ff">String</span>)) <span style="color: #3366ff">As </span>StringCollection<br />&#160;&#160;&#160;&#160;<span style="color: #339933"> &#39;Do stuff here that returns the string collection</span><br /><span style="color: #3366ff">End Function</span><br /></p></blockquote><p>This code is a drop in replacement for the code above.&#160; By that I mean that anywhere you call the first method, you could replace it with the 2nd method and your code will still work.&#160; You don&#39;t have to change anything else except the type of the variable that accepts the result.&#160; So if it works the same, why change?&#160; I mean, it takes a little more thought to read it and therefore you could argue it takes more to maintain.&#160; What do you gain?&#160; The answer is that you&#39;ve just made the function more useful and flexible.</p><p>Let&#39;s start with the InputParameter.&#160; Perhaps right now you have always have a string array when you call it.&#160; But what if later you start working with something like an ArrayList or the generic List(Of String)?&#160; Those will both work with that method right now, with no other changes.&#160; You can even put Xml or datatables through there with a little work.&#160; IEnumerable(Of String) will accept anything that can give you a string in a For Each loop.&#160; So just by changing the type I&#39;ve instantly made the code more powerful.</p><p>Now for the return type.&#160; I could have used IEnumerable(Of String) here as well.&#160; However, in this case that would actually limit the capabilities of the function.&#160; You&#39;d lose the ability to look at values by index.&#160; What I want to do is expand the capabilities of the function.&#160; String() already implies IEnumerable(Of String).&#160; However, by moving from the&#160; array up to a StringCollection I not only keep that ability but gain the ability to easily add or remove items from the collection.&#160; I also get some bonuses like the nice .Contains() and .IndexOf() methods.&#160; So again, I&#39;ve expanded what the function can do, and therefore made it more valuable.&#160; </p><p>For example, you might now be able to use it somewhere that before would have required a separate (but very similar) function.&#160; Or the switch to the new function might save you having to write a for each loop on the return value because of additional capabilities in the collection like the .Contains() method.&#160; It will enable you to get the same work done in less code.</p><p>One other point is that the new version should perform about the same as the old one. There might be a very small loss, but any difference is likely to be minor relative to other considerations in your code.&#160; Certainly falls under the heading of &quot;premature optimization.&quot;</p><p>In general, we can think of IEnumerable(Of String) as a wider type, and StringCollection as a more powerful type.&#160; A good rule of thumb is to accept a wider type for input and return a more powerful type for output.&#160; In this way you will make your code more useful, and in the long run that&#39;s probably a good thing.</p>    <p style="clear:both;"> 
    <a href="http://net.groups.vox.com/library/post/6a00c22525ad91604a00fad69a3d7d0005.html?_c=feed-atom-full#comments">Read and post comments</a>   |   
    <a href="http://www.vox.com/share/6a00c22525ad91604a00fad69a3d7d0005?_c=feed-atom-full">Send to a friend</a> 
</p>

                </div>
            ]]>
        </content> 
    </entry> 
    
    <entry>
        <title>The Power of Declarative Code in ASP.Net</title>   
        <link rel="alternate" type="text/html" title="The Power of Declarative Code in ASP.Net" href="http://net.groups.vox.com/library/post/6a00c22525ad91604a00fad69997260004.html?_c=feed-atom-full" />  
        <link rel="service.post" type="application/atom+xml" title="The Power of Declarative Code in ASP.Net" href="http://net.groups.vox.com/library/post/6a00c22525ad91604a00fad69997260004.html?_c=feed-atom-full#comments" /> 
        <link rel="service.edit" type="application/atom+xml" title="The Power of Declarative Code in ASP.Net" href="http://www.vox.com/atom/svc=post/asset_id=6a00c22525ad91604a00fad69997260004" />          <id>tag:vox.com,2008-07-11:asset-6a00c22525ad91604a00fad69997260004</id>
        <published>2008-07-11T15:55:55Z</published>
        <updated>2008-07-11T19:58:09Z</updated>
    
        <author>
            <name>jcoehoorn</name>
            <uri>http://jcoehoorn.vox.com/?_c=feed-atom-full</uri>
        </author>
    
        
        <content type="html" xml:base="http://jcoehoorn.vox.com/?_c=feed-atom-full">
            <![CDATA[
                <div xmlns="http://www.w3.org/1999/xhtml" xmlns:at="http://www.sixapart.com/ns/at">
        <p>ASP.Net is often mistaken for a simple update to Classic ASP.&#160; Just take ASP, throw in some .Net classes, and you&#39;re done.&#160; You get a better IDE and you might get a small performance boost from using pre-compiled code, but not much else.&#160; Of course, you <em>could </em>use ASP.Net like Classic ASP.&#160; If that&#39;s as far as you go then I suppose everything above would be true.&#160; In fact, one of the nice things about ASP.Net is it&#39;s ability to work with you as your skills grow, and give at least small benefits right away.&#160; But if you stop here you&#39;re missing out on the best parts of the language.</p><p>ASP.Net allows you to be more declarative in how you lay out your page.&#160; If an SQL SELECT query is the classic example of declarative code, than you can think of each server control as a little SELECT query.&#160; It&#39;s a way to declare what you want to the framework and let it worry about how to actually do it rather than listing out every little step.&#160; The advantages of this approach are numerous: your code base is smaller, busy-work is reduced, you see pages from a higher level, you get better separation of concerns for designers and developers...&#160;&#160; I could go on.&#160; You might be surprised to hear that there&#39;s a huge potential performance benefit as well.</p><p>If that thought does surprise you, it shouldn&#39;t.&#160; After all, it&#39;s what makes SQL fast.&#160; Take an SQL cursor, for example.&#160; A cursor is usually the slowest way to accomplish any task in a database.&#160; Why?&#160; Because it&#39;s procedural.&#160; If you can re-write the cursor to use declarative statements you will nearly always see a significant performance improvement.&#160; This is because the database can now use it&#39;s cache and indexes, and even execute the operation in parallel.&#160; The same concept applies to a web page, and for the same reasons.&#160; I don&#39;t know to what extent, if any, ASP.Net applies these concepts.&#160; But it should be theoretically possible. </p><p>First we&#39;ll look at caching/indexing.&#160; With declarative code the server can get a rough picture of what every instance of a page will look like.&#160; It can use this picture to create and cache a pre-loaded version of the page, where all the declared controls and HTML are loaded and put in the intial state defined by the aspx code.&#160; This is a huge improvement, because the amount of work left to do for each request is greatly reduced.&#160; Classic ASP would have to start from the beginning for every single request and work it&#39;s way through all of the page code to be sure of getting the correct result, like any other procedural code.&#160; The ASP.Net environment can take a few shortcuts.</p><p>Now let&#39;s move on to parallelism.&#160; Server controls in ASP.Net ultimately boil down to plain old XML, and every XML document is a tree structure of tags.&#160; The nature of XML means you have a certain amount of independence between siblings at any given level of the tree; the contents of one sibling aren&#39;t really relevant to the contents of another sibling.&#160; That means that each sibling can be processed in parallel.&#160; In practice ASP.Net controls can have code that modifies other parts of the page, so this ability is not absolute.&#160; However, it should be possible for the compiler to analyze the code and build a dependency tree for a page, and in this way get some advantage.&#160; The important thing here is that less procedural code means a more straightforward dependency tree and a greater the potential for parallelism. </p><p>As CPUs with more cores become more and more common a built-in mechanism
to render a page in parallel will become more and more significant.&#160; This is true even though a web server may already utilize multiple cores by&#160; processing separate requests in parallel.&#160; For example, while one node on a page waits for a request to a database to complete, rather than blocking the entire page other nodes can continue to process.&#160; In this way individual requests can still be served faster.</p><p>I need to repeat that I have no idea if these concepts are currently implemented.&#160; I suspect at moment they are not, and it&#39;s a shame if that&#39;s so. But the possibility and potential here is certainly interesting.</p>   <p style="clear:both;"> 
    <a href="http://net.groups.vox.com/library/post/6a00c22525ad91604a00fad69997260004.html?_c=feed-atom-full#comments">Read and post comments</a>   |   
    <a href="http://www.vox.com/share/6a00c22525ad91604a00fad69997260004?_c=feed-atom-full">Send to a friend</a> 
</p>

                </div>
            ]]>
        </content> 
    </entry> 
    
    <entry>
        <title>PowerShell rescues wedding photos</title>   
        <link rel="alternate" type="text/html" title="PowerShell rescues wedding photos" href="http://net.groups.vox.com/library/post/6a00c2251c28f3f21900fad693d96d0004.html?_c=feed-atom-full" />  
        <link rel="service.post" type="application/atom+xml" title="PowerShell rescues wedding photos" href="http://net.groups.vox.com/library/post/6a00c2251c28f3f21900fad693d96d0004.html?_c=feed-atom-full#comments" /> 
        <link rel="service.edit" type="application/atom+xml" title="PowerShell rescues wedding photos" href="http://www.vox.com/atom/svc=post/asset_id=6a00c2251c28f3f21900fad693d96d0004" />          <id>tag:vox.com,2008-06-22:asset-6a00c2251c28f3f21900fad693d96d0004</id>
        <published>2008-06-22T20:54:31Z</published>
        <updated>2008-06-22T21:06:57Z</updated>
    
        <author>
            <name>Alex</name>
            <uri>http://alexhung.vox.com/?_c=feed-atom-full</uri>
        </author>
    
        
        <content type="html" xml:base="http://alexhung.vox.com/?_c=feed-atom-full">
            <![CDATA[
                <div xmlns="http://www.w3.org/1999/xhtml" xmlns:at="http://www.sixapart.com/ns/at">
        <p>One of my friend reached out to me last week for help. The photographer she hired for her wedding had gone bankrupted. Since she has not gotten the album now she can&#39;t even get her wedding photos in either prints or digital form. All she has access to is the photographer&#39;s web site where the people can order prints from. She was hoping that I can somehow retrieve all the photos (~1220) from the site so that at least she would have digital copies of her wedding photos.<div><br /></div><div>After poking around the site a bit, I found out that I was in luck. Sort of. All the photos are accessible but only in low resolution (500 x 366). But more importantly for me, the site developer had opted to have a nice AJAX interface and for some reason decided to include all the image URLs in the page!</div><div><br /></div><div>So a plan of action quickly formed in my head:</div><div>1. Download the page source</div><div>2. Extract the image URLs from all the HTML/Javascript code</div><div>3. Download all the images, one by one</div><div><br /></div><div>Initially I want to try out <a href="http://www.apple.com/macosx/features/300.html#automator">Automator</a> on my Mac and see how easy it would be to do this, since this is exactly the type of&#160;repetitive&#160;tasks Steve Job told us Automator &#160;is perfect for! Unfortunately after poking around for 30 minutes, I quickly came to the conclusion that Automator is woefully inadequate for this task. So I turned to <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx">PowerShell</a> on my Windows VM instead. Having used <a href="http://blogs.msdn.com/powershell/archive/2008/05/02/announcing-the-release-of-community-technology-preview-2-ctp2-of-windows-powershell-v2.aspx">PowerShell 2.0 CTP</a> a lot in my last project, I was able to quickly develop a script that extracts URLs from the page source, download the file, and save it to disk. In fact, the most time consuming part is to figure out the regular expression for URL extraction!</div><div><br /></div><div>From start to finish, it took me around 90 minutes to get all the photos downloaded. If I didn&#39;t waste time with Automator and better at regular expression I think I can do it in 15 minutes!</div><div><br /></div><div>Now my friend can have her wedding photos. She may not be able to print them out, but at least she can view them on a computer screen.</div><div><br /></div></p>   <p style="clear:both;"> 
    <a href="http://net.groups.vox.com/library/post/6a00c2251c28f3f21900fad693d96d0004.html?_c=feed-atom-full#comments">Read and post comments</a>   |   
    <a href="http://www.vox.com/share/6a00c2251c28f3f21900fad693d96d0004?_c=feed-atom-full">Send to a friend</a> 
</p>

                </div>
            ]]>
        </content> 
    <category term="photography" scheme="http://net.groups.vox.com/tags/photography/" label="photography" /> 
    <category term="programming" scheme="http://net.groups.vox.com/tags/programming/" label="programming" /> 
    <category term="os x" scheme="http://net.groups.vox.com/tags/os+x/" label="os x" /> 
    <category term="powershell" scheme="http://net.groups.vox.com/tags/powershell/" label="powershell" /> 
    <category term="software development" scheme="http://net.groups.vox.com/tags/software+development/" label="software development" /> 
    <category term="automator" scheme="http://net.groups.vox.com/tags/automator/" label="automator" /> 
    <category term="thoughtworks" scheme="http://net.groups.vox.com/tags/thoughtworks/" label="thoughtworks" /> 
    </entry> 
    
    <entry>
        <title>Excel Column Names</title>   
        <link rel="alternate" type="text/html" title="Excel Column Names" href="http://net.groups.vox.com/library/post/6a00c22525ad91604a00fad690d4e60004.html?_c=feed-atom-full" />  
        <link rel="service.post" type="application/atom+xml" title="Excel Column Names" href="http://net.groups.vox.com/library/post/6a00c22525ad91604a00fad690d4e60004.html?_c=feed-atom-full#comments" /> 
        <link rel="service.edit" type="application/atom+xml" title="Excel Column Names" href="http://www.vox.com/atom/svc=post/asset_id=6a00c22525ad91604a00fad690d4e60004" />          <id>tag:vox.com,2008-06-12:asset-6a00c22525ad91604a00fad690d4e60004</id>
        <published>2008-06-12T20:51:53Z</published>
        <updated>2008-06-13T13:35:04Z</updated>
    
        <author>
            <name>jcoehoorn</name>
            <uri>http://jcoehoorn.vox.com/?_c=feed-atom-full</uri>
        </author>
    
        
        <content type="html" xml:base="http://jcoehoorn.vox.com/?_c=feed-atom-full">
            <![CDATA[
                <div xmlns="http://www.w3.org/1999/xhtml" xmlns:at="http://www.sixapart.com/ns/at">
        <p><span id="intelliTxt">I ran across a request in a forum today to create an 
Excel column name from an index.&#160; It sounds simple, but it&#39;s harder than it 
looks.</span>
<p><span></span><span>The obvious solution here is to think about a column name 
as a base 26 number, with A-Z for digits.&#160; Unfortunately,&#160;it doesn&#39;t quite work 
like that.&#160; The &#39;0&#39; digit is broken.&#160; For example, counting the column names 
from A you wrap around to AA after reaching Z. If this were base 10 it would be 
like counting from 1 to 9 and then getting 11 instead of 10, or counting from 0 
to 9 and then getting 00 instead of 10, depending on whether you treat A as 0 or 
1. So it&#39;s tricky.</p>I thought I could get around that but that it would 
take more work than it&#39;s worth, so I decided to look around online. Surely there 
would be something already out there. What I found was a bunch of 
over-complicated implementations that all break somewhere on one of the 
boundaries I described.&#160; Even the&#160;<a href="http://support.microsoft.com/kb/833402">Microsft support 
example</a>&#160;doesn&#39;t work well.&#160; What a disappointment.</span></p><p><span>So I ended up 
writing a new version after all.&#160;&#160;This one will scale, and it&#39;s not even that 
complicated. I just had to get a little recursive:</span></p><blockquote><p><span style="font-size: small; color: #0000ff">Function</span><span style="font-size: small"> 
ColumnName(</span><span style="font-size: small; color: #0000ff">ByVal</span><span style="font-size: small"> index 
</span><span style="font-size: small; color: #0000ff">As</span><span style="font-size: small"> </span><span style="font-size: small; color: #0000ff">Integer</span><span style="font-size: small">) </span><span style="font-size: small; color: #0000ff">As</span><span style="font-size: small"> </span><span style="font-size: small; color: #0000ff">String<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Static</span><span style="font-size: small"> chars() 
</span><span style="font-size: small; color: #0000ff">As</span><span style="font-size: small"> </span><span style="font-size: small; color: #0000ff">Char</span><span style="font-size: small"> = {&quot;A&quot;c, &quot;B&quot;c, &quot;C&quot;c, &quot;D&quot;c, &quot;E&quot;c, 
&quot;F&quot;c, &quot;G&quot;c, &quot;H&quot;c, &quot;I&quot;c, &quot;J&quot;c, &quot;K&quot;c, &quot;L&quot;c, &quot;M&quot;c, &quot;N&quot;c, &quot;O&quot;c, &quot;P&quot;c, &quot;Q&quot;c, &quot;R&quot;c, 
&quot;S&quot;c, &quot;T&quot;c, &quot;U&quot;c, &quot;V&quot;c, &quot;W&quot;c, &quot;X&quot;c, &quot;Y&quot;c, &quot;Z&quot;c}</span></p><p><span style="font-size: small">&#160;&#160;&#160;&#160;&#160;&#160;&#160; index -= </span><span style="font-size: small; color: #800000">1</span><span style="font-size: small"> </span><span style="font-size: small; color: #339933">&#39;adjust so it matches 0-indexed array rather than 1-indexed 
column</span></p><p><span style="font-size: small; color: #0000ff">&#160;&#160;&#160;&#160;&#160;&#160;&#160; Dim</span><span style="font-size: small"> quotient 
</span><span style="font-size: small; color: #0000ff">As</span><span style="font-size: small"> </span><span style="font-size: small; color: #0000ff">Integer</span><span style="font-size: small"> = index \ </span><span style="font-size: small; color: #800000">26</span><span style="font-size: small"> </span><span style="font-size: small; color: #339933">&#39;normal / operator rounds. \ does integer division, which 
truncates</span><br /><span style="font-size: small">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="font-size: small; color: #0000ff">If</span><span style="font-size: small"> quotient &gt; 
</span><span style="font-size: small; color: #800000">0</span><span style="font-size: small"> </span><span style="font-size: small; color: #0000ff">Then</span><br /><span style="font-size: small">&#160;&#160; &#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ColumnName = 
ColumnName(quotient) &amp; chars(index </span><span style="font-size: small; color: #0000ff">Mod</span><span style="font-size: small"> </span><span style="font-size: small; color: #800000">26</span><span style="font-size: small">)</span><br /><span style="font-size: small; color: #0000ff">&#160;&#160;&#160;&#160;&#160;&#160;&#160; Else</span><br /><span style="font-size: small; color: #0000ff">&#160;&#160; &#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="font-size: small">ColumnName = chars(index </span><span style="font-size: small; color: #0000ff">Mod</span><span style="font-size: small"> </span><span style="font-size: small; color: #800000">26)</span><br /><span style="font-size: small; color: #0000ff">&#160;&#160;&#160;&#160;&#160;&#160;&#160; End</span><span style="font-size: small"> 
</span><span style="font-size: small; color: #0000ff">If</span><br /><span style="font-size: small; color: #0000ff">End Function</span><span style="font-size: small"> </span><br /></p></blockquote>
<blockquote dir="ltr" style="margin-right: 0px;"><p><span><blockquote dir="ltr" style="margin-right: 0px;">

<p><span style="font-size: small">
</span><span style="font-size: small">
</span></p></blockquote><span style="font-size: small"></span></span></p></blockquote><p><span style="font-size: small; color: #0000ff"><span style="color: #000000">That still needs some basic bounds and error checking, but it works well for a quick sample.&#160; It&#39;s only 11 lines 
of code as is appears in my IDE (curse the vox formatter!) so it&#39;s pretty easy 
to follow.&#160; It should perform well too, since it would be very odd have more 
than&#160;one or two recursive calls.&#160; Now hopefully Google can index this page 
better than all those bad implementations I saw out there, but I&#39;m not holding 
my breath.</span></span>

<p dir="ltr" style="margin-right: 0px;"><span style="font-size: small; color: #0000ff"></span>&#160;</p> </p>   <p style="clear:both;"> 
    <a href="http://net.groups.vox.com/library/post/6a00c22525ad91604a00fad690d4e60004.html?_c=feed-atom-full#comments">Read and post comments</a>   |   
    <a href="http://www.vox.com/share/6a00c22525ad91604a00fad690d4e60004?_c=feed-atom-full">Send to a friend</a> 
</p>

                </div>
            ]]>
        </content> 
    </entry> 
    
    <entry>
        <title>Video of Alt.Net Opening</title>   
        <link rel="alternate" type="text/html" title="Video of Alt.Net Opening" href="http://net.groups.vox.com/library/post/6a00c2251c28f3f21900e398f18d160004.html?_c=feed-atom-full" />  
        <link rel="service.post" type="application/atom+xml" title="Video of Alt.Net Opening" href="http://net.groups.vox.com/library/post/6a00c2251c28f3f21900e398f18d160004.html?_c=feed-atom-full#comments" /> 
        <link rel="service.edit" type="application/atom+xml" title="Video of Alt.Net Opening" href="http://www.vox.com/atom/svc=post/asset_id=6a00c2251c28f3f21900e398f18d160004" />              <id>tag:vox.com,2008-04-19:asset-6a00c2251c28f3f21900e398f18d160004</id>
        <published>2008-04-19T15:44:03Z</published>
        <updated>2008-04-26T23:30:32Z</updated>
    
        <author>
            <name>Alex</name>
            <uri>http://alexhung.vox.com/?_c=feed-atom-full</uri>
        </author>
    
        
        <content type="html" xml:base="http://alexhung.vox.com/?_c=feed-atom-full">
            <![CDATA[
                <div xmlns="http://www.w3.org/1999/xhtml" xmlns:at="http://www.sixapart.com/ns/at">
        <p>
    
    
    





        





</p>
    
    
    





        





<div at:enclosure="asset" at:xid="6a00c2251c28f3f21900e398f3e4dc0005" at:format="extra-large" at:align="center"
    class="enclosure enclosure-center enclosure-extra-large video-enclosure" 
     style="text-align: center;">
<div class="enclosure-inner"
    
        style="padding: 9px; border: 1px solid; width: px; margin: 10px auto;"
    >
    <div class="enclosure-list">
        <div class="enclosure-item video-asset last">
    
            <div class="enclosure-image">
        
                <a href="http://net.groups.vox.com/library/video/6a00c2251c28f3f21900e398f3e4dc0005.html"><img src="http://a4.vox.com/6a00c2251c28f3f21900e398f3e4dc0005-500pi" alt="Alt.Net Seattle Opening Part 1" title="Alt.Net Seattle Opening Part 1" /></a>
        
            </div>
            <div class="enclosure-meta">
                <div class="enclosure-asset-name"><a href="http://net.groups.vox.com/library/video/6a00c2251c28f3f21900e398f3e4dc0005.html" title="Alt.Net Seattle Opening Part 1">Alt.Net Seattle Opening Part 1</a></div>
            </div>
    
        </div>
    </div>
</div>
</div><!-- end enclosure -->

<p></p><p>
    
    
    





        





</p>
    
    
    





        





<div at:enclosure="asset" at:xid="6a00c2251c28f3f21900f48cf2421e0002" at:format="extra-large" at:align="center"
    class="enclosure enclosure-center enclosure-extra-large video-enclosure" 
     style="text-align: center;">
<div class="enclosure-inner"
    
        style="padding: 9px; border: 1px solid; width: px; margin: 10px auto;"
    >
    <div class="enclosure-list">
        <div class="enclosure-item video-asset last">
    
            <div class="enclosure-image">
        
                <a href="http://net.groups.vox.com/library/video/6a00c2251c28f3f21900f48cf2421e0002.html"><img src="http://a6.vox.com/6a00c2251c28f3f21900f48cf2421e0002-500pi" alt="Alt.Net Conference Opening Part 2" title="Alt.Net Conference Opening Part 2" /></a>
        
            </div>
            <div class="enclosure-meta">
                <div class="enclosure-asset-name"><a href="http://net.groups.vox.com/library/video/6a00c2251c28f3f21900f48cf2421e0002.html" title="Alt.Net Conference Opening Part 2">Alt.Net Conference Opening Part 2</a></div>
            </div>
    
        </div>
    </div>
</div>
</div><!-- end enclosure -->

<p></p><p>You can probably see me standing in the back, as I got there late!</p>   <p style="clear:both;"> 
    <a href="http://net.groups.vox.com/library/post/6a00c2251c28f3f21900e398f18d160004.html?_c=feed-atom-full#comments">Read and post comments</a>   |   
    <a href="http://www.vox.com/share/6a00c2251c28f3f21900e398f18d160004?_c=feed-atom-full">Send to a friend</a> 
</p>

                </div>
            ]]>
        </content> 
    <category term="seattle" scheme="http://net.groups.vox.com/tags/seattle/" label="seattle" /> 
    <category term="programming" scheme="http://net.groups.vox.com/tags/programming/" label="programming" /> 
    <category term=".net" scheme="http://net.groups.vox.com/tags/.net/" label=".net" /> 
    <category term="#altdotnet" scheme="http://net.groups.vox.com/tags/%23altdotnet/" label="#altdotnet" /> 
    </entry> 
    
    <entry>
        <title>meepers is a funny name for a silly game</title>   
        <link rel="alternate" type="text/html" title="meepers is a funny name for a silly game" href="http://net.groups.vox.com/library/post/6a00c225239bda604a00f48ceac83d0003.html?_c=feed-atom-full" />  
        <link rel="service.post" type="application/atom+xml" title="meepers is a funny name for a silly game" href="http://net.groups.vox.com/library/post/6a00c225239bda604a00f48ceac83d0003.html?_c=feed-atom-full#comments" /> 
        <link rel="service.edit" type="application/atom+xml" title="meepers is a funny name for a silly game" href="http://www.vox.com/atom/svc=post/asset_id=6a00c225239bda604a00f48ceac83d0003" />              <id>tag:vox.com,2008-04-03:asset-6a00c225239bda604a00f48ceac83d0003</id>
        <published>2008-04-03T00:19:55Z</published>
        <updated>2008-04-04T04:31:51Z</updated>
    
        <author>
            <name>Steve</name>
            <uri>http://tranbonium.vox.com/?_c=feed-atom-full</uri>
        </author>
    
        
        <content type="html" xml:base="http://tranbonium.vox.com/?_c=feed-atom-full">
            <![CDATA[
                <div xmlns="http://www.w3.org/1999/xhtml" xmlns:at="http://www.sixapart.com/ns/at">
        <div at:enclosure="asset" at:xid="6a00c225239bda604a00e398ec4d730004 6a00c225239bda604a00f48ceab8940002" at:format="strip-vertical" at:align="right" class="enclosure enclosure-right enclosure-strip enclosure-strip-vertical"  style="text-align: center; float: right;">
<div class="enclosure-inner" style="width: 130px; margin: 5px; border: 1px solid; text-align: center;"><a href="http://net.groups.vox.com/library/photo/6a00c225239bda604a00e398ec4d730004.html" class="enclosure-strip-link" title="Beaker-muppets-photo"><img src="http://a3.vox.com/6a00c225239bda604a00e398ec4d730004-120pi" alt="Beaker-muppets-photo" class="enclosure-strip-image" style="margin: 5px; border: 0;" /></a><br /><a href="http://net.groups.vox.com/library/photo/6a00c225239bda604a00f48ceab8940002.html" class="enclosure-strip-link" title="Vox_meepers_beaker"><img src="http://a4.vox.com/6a00c225239bda604a00f48ceab8940002-120pi" alt="Vox_meepers_beaker" class="enclosure-strip-image" style="margin: 5px; border: 0;" /></a><br /></div>
</div> <!-- end enclosure -->
 
 
 <p><span style="font-size: 1.5625em;"><strong>Story</strong></span><br />Back in my early teen years I learned about this programming thing called BASIC, and from there borrowed/bought a bunch of books to learn how to make a video game (amongst VB 6.0 apps).&#160; The game is reminiscent of the Zelda (NES) dungeons or levels. I&#39;m not sure exactly how I came up with the name Meepers, but it had something to do with my first character graphic looking like the Muppet&#39;s Beaker character, who I believe I thought was called Meeper (due to the character making meeping noises). I guess they don&#39;t look that much alike, but whatever.&#160; Anyway if you&#39;d like to check out more info please visit my site (I&#39;m working on it, no frills right now) <a href="http://www.tranbonium.us/projects/meepers/">http://www.tranbonium.us/projects/meepers/</a>. </p><p><span style="font-size: 1.5625em;"><strong>Videos</strong></span><br /><ul><li><a href="http://www.gamevee.com/viewVideo/Meepers/PC/Meepers_v142/159942">Meepers DOS v142 Gameplay</a> - Video I captured of the newest version of the game as it was 10 years ago.</li><li><a href="http://www.gamevee.com/viewVideo/Meepers_XNA_010/PC/Meepers_XNA_Initial_Video/159922">Meepers XNA Initial Preview</a> - Video of the new version I&#39;m starting to create using C# and the XNA Game Studio from Microsoft (maybe I&#39;ll be able to host it up on XBox Live Arcade - you never know ;-P)</li></ul></p> <div><br /></div>   <p style="clear:both;"> 
    <a href="http://net.groups.vox.com/library/post/6a00c225239bda604a00f48ceac83d0003.html?_c=feed-atom-full#comments">Read and post comments</a>   |   
    <a href="http://www.vox.com/share/6a00c225239bda604a00f48ceac83d0003?_c=feed-atom-full">Send to a friend</a> 
</p>

                </div>
            ]]>
        </content> 
    <category term="game" scheme="http://net.groups.vox.com/tags/game/" label="game" /> 
    <category term="programming" scheme="http://net.groups.vox.com/tags/programming/" label="programming" /> 
    <category term="video game" scheme="http://net.groups.vox.com/tags/video+game/" label="video game" /> 
    <category term="projects" scheme="http://net.groups.vox.com/tags/projects/" label="projects" /> 
    <category term="c#" scheme="http://net.groups.vox.com/tags/c%23/" label="c#" /> 
    <category term="xna" scheme="http://net.groups.vox.com/tags/xna/" label="xna" /> 
    <category term="game programming" scheme="http://net.groups.vox.com/tags/game+programming/" label="game programming" /> 
    <category term="/dev" scheme="http://net.groups.vox.com/tags/%2Fdev/" label="/dev" /> 
    <category term="meepers" scheme="http://net.groups.vox.com/tags/meepers/" label="meepers" /> 
    </entry> 
    
    <entry>
        <title>Connect to a WCF Service from a Silverlight 2 application</title>   
        <link rel="alternate" type="text/html" title="Connect to a WCF Service from a Silverlight 2 application" href="http://net.groups.vox.com/library/post/6a00f48d075b66000100f48ce9d5cc0003.html?_c=feed-atom-full" />  
        <link rel="service.post" type="application/atom+xml" title="Connect to a WCF Service from a Silverlight 2 application" href="http://net.groups.vox.com/library/post/6a00f48d075b66000100f48ce9d5cc0003.html?_c=feed-atom-full#comments" /> 
        <link rel="service.edit" type="application/atom+xml" title="Connect to a WCF Service from a Silverlight 2 application" href="http://www.vox.com/atom/svc=post/asset_id=6a00f48d075b66000100f48ce9d5cc0003" />          <id>tag:vox.com,2008-03-31:asset-6a00f48d075b66000100f48ce9d5cc0003</id>
        <published>2008-03-31T04:52:01Z</published>
        <updated>2008-05-01T21:22:56Z</updated>
    
        <author>
            <name>programit</name>
            <uri>http://programit.vox.com/?_c=feed-atom-full</uri>
        </author>
    
        
        <content type="html" xml:base="http://programit.vox.com/?_c=feed-atom-full">
            <![CDATA[
                <div xmlns="http://www.w3.org/1999/xhtml" xmlns:at="http://www.sixapart.com/ns/at">
        <p class="MsoNormal"><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;">This post assumes you have installed the necessary pre-requisites for Silverlight 2 beta 1 and are using Visual Studio 2008.</span></p>
<p class="MsoNormal"><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;"></span><strong><u><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;">Setup your solution</span></u></strong></p>
<p class="MsoNormal"><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;"><span>&#160; </span><br />&#160; Open Visual Studio 2008</span></p>
<p class="MsoNormal">&#160; <span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;">Click File &gt; New Project</span></p>
<p class="MsoNormal">&#160; <span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;">Select the Silverlight 2 project type</span></p>
<p class="MsoNormal">&#160; <span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;">Select the Silverlight Application template</span></p>
<p class="MsoNormal">&#160; <span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;">Provide an application name and click OK</span></p>
<p class="MsoNormal"><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;">&#160;<br />You will be prompted to select whether to host your Silverlight application in a Web Site or Web Application Project. We’ll&#160;&#160; select Web Application Project</span></p><p><br /><strong><u><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;">Add a WCF Service to the Web Application project</span></u></strong> 
<p class="MsoNormal"><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;">&#160;</span></p>
<p class="MsoNormal"><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;">See my blog post on <a href="http://programit.vox.com/library/post/how-to-create-and-connect-to-a-wcf-service-in-vs08.html">How to create and connect to a WCF Service in VS08</a> for instructions on setting up a WCF Service. Ignore the project setup …when you get to the section titled “Create the service proxy”, make sure to add the service reference to the Silverlight Application project.</span></p>
<p class="MsoNormal"><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;">You now have a Web Application, setup to host your Silverlight 2 application, which contains a basic WCF Service, and an empty Silverlight 2 application that is setup to connect to your WCF Service.</span></p>
<p class="MsoNormal"><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;">Now we’ll create a basic interface for your Silverlight Application.</span></p>
<p class="MsoNormal"><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;">&#160;<br /></span></p>
<p class="MsoNormal"><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;"></span><strong><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;"><u>Create&#160; the Silverlight&#160; interface</u></span><u><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;"></span></u></strong></p>
<p class="MsoNormal"><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;">&#160;Use the following xaml markup for your interface:</span></p>
<blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">&lt;</span><span style="FONT-SIZE: 10pt; COLOR: rgb(163,21,21); FONT-FAMILY: Consolas">Grid</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"> x</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">:</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas">Name</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;GrdService&quot;&gt;</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: rgb(163,21,21); FONT-FAMILY: Consolas"><span>&#160;&#160;&#160; </span></span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">&lt;</span><span style="FONT-SIZE: 10pt; COLOR: rgb(163,21,21); FONT-FAMILY: Consolas">Grid.ColumnDefinitions</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">&gt;</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: rgb(163,21,21); FONT-FAMILY: Consolas"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">&lt;</span><span style="FONT-SIZE: 10pt; COLOR: rgb(163,21,21); FONT-FAMILY: Consolas">ColumnDefinition</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"> Width</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;200&quot; /&gt;</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: rgb(163,21,21); FONT-FAMILY: Consolas"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">&lt;</span><span style="FONT-SIZE: 10pt; COLOR: rgb(163,21,21); FONT-FAMILY: Consolas">ColumnDefinition</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"> Width</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;100&quot; /&gt;</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: rgb(163,21,21); FONT-FAMILY: Consolas"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">&lt;</span><span style="FONT-SIZE: 10pt; COLOR: rgb(163,21,21); FONT-FAMILY: Consolas">ColumnDefinition</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"> Width</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;200&quot; /&gt;</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: rgb(163,21,21); FONT-FAMILY: Consolas"><span>&#160;&#160;&#160; </span></span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">&lt;/</span><span style="FONT-SIZE: 10pt; COLOR: rgb(163,21,21); FONT-FAMILY: Consolas">Grid.ColumnDefinitions</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">&gt;</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">&#160;</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: rgb(163,21,21); FONT-FAMILY: Consolas"><span>&#160;&#160;&#160; </span></span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">&lt;</span><span style="FONT-SIZE: 10pt; COLOR: rgb(163,21,21); FONT-FAMILY: Consolas">WatermarkedTextBox</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"> x</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">:</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas">Name</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;TxtName&quot;</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"> Grid.Column</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;0&quot;</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"> </span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>Watermark</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;Enter name here...&quot;</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"> </span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>HorizontalAlignment</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;Center&quot;</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"> </span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>Width</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;190&quot;</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"> </span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>VerticalAlignment</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;Center&quot;</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"> </span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>Height</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;30&quot;</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"> </span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>Margin</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;5&quot; /&gt;</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: rgb(163,21,21); FONT-FAMILY: Consolas"><span>&#160;&#160;&#160; </span></span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">&lt;</span><span style="FONT-SIZE: 10pt; COLOR: rgb(163,21,21); FONT-FAMILY: Consolas">Button</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"> x</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">:</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas">Name</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;BtnCall&quot;</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"> Grid.Column</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;1&quot; </span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>Content</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;WFC Call&quot;</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"> </span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>HorizontalAlignment</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;Left&quot; /&gt;</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"></span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: rgb(163,21,21); FONT-FAMILY: Consolas"><span>&#160;&#160;&#160; </span></span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">&lt;</span><span style="FONT-SIZE: 10pt; COLOR: rgb(163,21,21); FONT-FAMILY: Consolas">Border</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"> Grid.Column</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;2&quot;</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"> </span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>BorderThickness</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;1&quot;</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"> </span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>BorderBrush</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;Black&quot;</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"> </span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>Margin</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;5&quot;</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"> </span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>HorizontalAlignment</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;Center&quot;</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"> </span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>Width</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;190&quot;&gt;</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;</span><span style="FONT-SIZE: 10pt; COLOR: rgb(163,21,21); FONT-FAMILY: Consolas">TextBlock</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"> x</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">:</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas">Name</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;TxtResponse&quot;</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"> </span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>VerticalAlignment</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;Center&quot;</span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"> </span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"></span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>HorizontalAlignment</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=&quot;Center&quot; /&gt;</span><span style="FONT-SIZE: 10pt; COLOR: rgb(163,21,21); FONT-FAMILY: Consolas"><span>&#160;&#160;&#160; </span></span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: rgb(163,21,21); FONT-FAMILY: Consolas"><span>&#160;&#160;&#160; </span></span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">&lt;/</span><span style="FONT-SIZE: 10pt; COLOR: rgb(163,21,21); FONT-FAMILY: Consolas">Border</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">&gt;</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">&lt;/</span><span style="FONT-SIZE: 10pt; COLOR: rgb(163,21,21); FONT-FAMILY: Consolas">Grid</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">&gt;</span><span style="FONT-SIZE: 10pt; COLOR: rgb(163,21,21); FONT-FAMILY: Consolas"><span>&#160;&#160;&#160; </span></span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"></span></p></blockquote>
<p class="MsoNormal"><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;">&#160;</span></p>
<p class="MsoNormal"><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;">Add the Width and Height properties to the UserControl tag of the Page.xaml file. Set the Width to 500 and Height to 40</span></p>
<p class="MsoNormal"><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;">Add a Click event handler to the Button control by selecting the Click property. As you fill in the property you will be prompted with an option to select , doing this will automatically create a handler in the Page.xaml.cs code behind.</span></p>
<p class="MsoNormal"><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;"></span><strong><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;"><u>Connect to the service</u></span><u><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;"><br /><span style="TEXT-DECORATION: none"></span></span></u></strong><br />&#160; <span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;">Open the Page.xaml.cs file</span></p>
<p class="MsoNormal">&#160; <span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;">Locate the button event handler you just created&#160; end enter the code below:</span></p>
<blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">&#160;<br />private</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"> <span style="COLOR: blue">void</span> BtnCall_Click(<span style="COLOR: blue">object</span> sender, <span style="COLOR: rgb(43,145,175)">RoutedEventArgs</span> e)</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas">{</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160; </span><span style="COLOR: green">// substitute the path to your service here</span></span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160; </span><span style="COLOR: blue">string</span> wcfUrl =<span>&#160;&#160;&#160;&#160;&#160; </span></span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: rgb(163,21,21); FONT-FAMILY: Consolas"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&quot;http://localhost:[port]/[WebProjectName]/[ServiceName].svc&quot;</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas">;</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas">&#160;</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160; </span><span style="COLOR: rgb(43,145,175)">BasicHttpBinding</span> bind = <span style="COLOR: blue">new</span> <span style="COLOR: rgb(43,145,175)">BasicHttpBinding</span>();</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160; </span><span style="COLOR: rgb(43,145,175)">EndpointAddress</span> endpoint = <span style="COLOR: blue">new</span> <span style="COLOR: rgb(43,145,175)">EndpointAddress</span>(wcfUrl);</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas">&#160;</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160; </span>HelloService.<span style="COLOR: rgb(43,145,175)">HelloClient</span> wcfClient =</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="COLOR: blue">new</span> HelloService.<span style="COLOR: rgb(43,145,175)">HelloClient</span>(bind, endpoint);</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas">&#160;</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160; </span><span style="COLOR: green">// creates a delegate, called when the asynchronous web method call<span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span></span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160; </span>// completes</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160; </span></span><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas">wcfClient.SayHelloCompleted += </span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="COLOR: blue">new</span> <span style="COLOR: rgb(43,145,175)">EventHandler</span>&lt;HelloService.<span style="COLOR: rgb(43,145,175)">SayHelloCompletedEventArgs</span>&gt;(</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>wcfClient_SayHelloCompleted);</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"><span>&#160; </span><span>&#160;&#160;&#160;&#160;</span></span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160; </span><span style="COLOR: green">// call the web method asynchronously</span></span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160; </span>wcfClient.SayHelloAsync(<span style="COLOR: blue">this</span>.TxtName.Text);<span>&#160;&#160;&#160; </span></span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas">}</span></p></blockquote>
<p class="MsoNormal"><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;">&#160;</span></p>
<p class="MsoNormal"><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;"></span><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;">If you didn’t automatically create the SayHelloCompleted delegate create as follows:</span></p>
<blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"><br />void</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"> wcfClient_SayHelloCompleted(</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160; </span><span style="COLOR: blue">object</span> sender, HelloService.<span style="COLOR: rgb(43,145,175)">SayHelloCompletedEventArgs</span> e)</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas">{<span>&#160;&#160;&#160;&#160;&#160;&#160; </span></span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160; </span>if</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"> (e.Error == <span style="COLOR: blue">null</span>)</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas"><span>&#160;&#160;&#160; </span><span>&#160;&#160;&#160;&#160;</span><span style="COLOR: blue">this</span>.TxtResponse.Text = e.Result;</span></p>
<p class="MsoNormal"><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas">}</span><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;"></span></p></blockquote>
<p class="MsoNormal" dir="ltr"><strong><u><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;"><span></span></span></u></strong><br /><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;">There is one more thing to change before this will work. Open the web.config in the Web Application project and locate the tag with the name of your service. In the tag modify the binding property to use “basicHttpBinding”. This is required for Silverlight connectivity.</span></p>
<blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
<p class="MsoNormal"><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;">Ex. </span><span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Consolas">binding</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Consolas">=</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas">&quot;<span style="COLOR: blue">basicHttpBinding</span>&quot;</span></p></blockquote>
<p class="MsoNormal"><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;">&#160;You have successfully connected to a WCF Service from a Silverlight 2 beta 1 application. One thing to note, if you want to connect to a WCF Service that is hosted in a different domain than your Silverlight application you will need to follow the instructions located <a href="http://msdn2.microsoft.com/en-us/library/cc197955%28VS.95%29.aspx">here</a> to setup a client access policy.</span></p>
<p class="MsoNormal"><br /><span style="FONT-FAMILY: &#39;Calibri&#39;,&#39;sans-serif&#39;"></span></p></p>   <p style="clear:both;"> 
    <a href="http://net.groups.vox.com/library/post/6a00f48d075b66000100f48ce9d5cc0003.html?_c=feed-atom-full#comments">Read and post comments</a>   |   
    <a href="http://www.vox.com/share/6a00f48d075b66000100f48ce9d5cc0003?_c=feed-atom-full">Send to a friend</a> 
</p>

                </div>
            ]]>
        </content> 
    <category term=".net" scheme="http://net.groups.vox.com/tags/.net/" label=".net" /> 
    <category term="silverlight" scheme="http://net.groups.vox.com/tags/silverlight/" label="silverlight" /> 
    <category term="wcf" scheme="http://net.groups.vox.com/tags/wcf/" label="wcf" /> 
    </entry> 
</feed>

