Monthly Archives: May 2008

Problem calling a Web Service from Silverlight 2



Apparently the “System.ServiceModel.ProtocolException” error is common in the fledgling world of Silverlight 2 and Web Services.


In my case I tried to reference a Web Service that my company created and was disappointed with this entertaining message:


System.ServiceModel.ProtocolException’ occurred in System.ServiceModel.dll but was not handled in user code Additional information: [UnexpectedHttpResponseCode]Arguments:Not Found
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See


What this meant in my case is that I needed a “crossdomain.xml” file placed in the root folder of the server I was accessing.


For a development server, this could mean something like this:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "">
  <allow-access-from domain="*" />


This gives all applications (Silverlight, Flash) no matter where they’re from to access any web applicaitons on your web host.


As an ISV I find this a bit annoying, as it means updating a file that is outside of the Web Application (in the Web Root).


It would be nice to be able to configure this information within the virtual directory of the application itself.




Combining Silverlight 2 content from multiple web applications in VS2008



In a project I’m doing I need to create a web application that can consume Silverlight 2 RIA content from other web applications.

As it turns out, this is pretty easy to do.  All you need to do is reference the xap in the other web application from your page and it works exactly the same as if you were using an xap from within your own web application.

A Problem with Debugging

One problem is that Visual Studio tries to run the two web applications on different ports, which makes it impossible to reference the other web app directly.  You can’t use a relative url:

<form id="form1" runat="server" style="height:100%;">
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <div  style="height:100%;">
        <asp:Silverlight ID="Xaml1" runat="server" Source="../Crm_Web/ClientBin/TechnologyOneCrm.xap" Version="2.0" Width="100%" Height="100%" />

Therefore you need to set the web application you wish to point to on a static port, like this:


You can then access the web application directly:

<form id="form1" runat="server" style="height:100%;">
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <div  style="height:100%;">
        <asp:Silverlight ID="Xaml1" runat="server" Source="http://localhost:2000/Crm_Web/ClientBin/TechnologyOneCrm.xap" Version="2.0" Width="100%" Height="100%" />

There’s probably many better solutions to this problem, but I thought I’d post my workaround.

3D in Silverlight 2.0



So what’s the difference between WPF and Silverlight again?  Oh yes, well WPF has more advanced features.

You know, 3D graphics!

Isn’t it strange that many Silverlight demos invariably incorporate 3D style effects? 

Take a look at this article for a very rich solution:

Silverlight: Building Advanced 3D Animations with Silverlight 2.0

I wonder how long it will be before Silverlight supports 3D natively?

Twittering using the Compact Framework



My twitter updates are done using a variety of code.  At the moment I use the Curl command line  in conjunction with SlickRun.  In the past I did this with Outlook (see the article Twittering from Outlook Using VBA).  In the past I’ve found this pretty easy to do using the Twitter Api.


I also like to do updates from my Pocket PC, but am not keen on SMS charges.  The solution of course is to create my own client, which I’ll be posting about shortly.

For my client program I intend to use TwitterLib library.  Sadly this does not work for the compact framework unaltered.  I am currently working on porting it to the compact framework.


In the interim I want to share with you a simple code sample for submitting tweets to Twitter. 

The example is simple enough to be used by people who want to do HTTP posts to similar services.


    Dim lsParams As String = "status=" & Uri.EscapeDataString(tweetText)

    Dim loRequest As HttpWebRequest = CType(HttpWebRequest.Create(""), HttpWebRequest)
           With loRequest
               .Proxy = System.Net.GlobalProxySelection.GetEmptyWebProxy()

               .Timeout = 10000
               .AllowAutoRedirect = True
               .AllowWriteStreamBuffering = True

               .Method = "POST"

               .ContentType = "application/x-www-form-urlencoded"
               .ContentLength = Len(lsParams)

               Dim loCred As New System.Net.NetworkCredential("someusername", "somepassword")
               .Credentials = loCred

               ' Write the request paramater
               Dim stOut As New StreamWriter(.GetRequestStream(), System.Text.Encoding.ASCII)

               Dim loResp = .GetResponse
               With loResp

               End With

           End With


The most important difference with the full .net framework is the “GetEmptyWebProxy” and “AllowWriteStreamBuffering” lines.  It won’t work without it.

Share this post :