Silverlight Brass Tacks

Bill Reiss' Silverlight Ramblings
My upcoming Silverlight book for beginners Hello! Silverlight 2 with Dave Campbell, available online now!



Pages

Recent posts

Navigation

Archive

Blogroll

Tampa Divorce Lawyer

North of Tampa in Lutz, Florida. A Tampa Divorce Lawyer focusing on family, divorce, and real estate law.

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

Remember what I said about statistics?

A few days ago I wrote about the tremendous gains that Silverlight has made in install base. I referred to the stats on http://www.riastats.com and it looks like they've made a change in their statistics gathering.

The original article is here:

http://www.bluerosegames.com/SilverlightBrassTacks/post/Olympics2c-DNC-a-boon-for-Silverlight.aspx

If found a comment from Travis of DreamingWell who wrote riastats.com on this blog post:

http://www.sitechno.com/Blog/IsSilverlightMarketshareReallyGrowingThisFast.aspx

Travis says:

Hey guys. I wrote the RiaStats.com site.
The jump comes from several silverlight bloggers adding the riastats collection script to their site. Because they have a ton of subscribers versus the other sites that use it, the statistics are skewed. However, it should still be interesting to note that you can get that high a percentage, if you put silverlight on your site.
When I get a chance, I'm going to add a feature that allows you filter out sites that are specifically about silverlight or flash from the data aggregation.
Travis - DreamingWell.com

I want to note that I wasn't one of the Silverlight bloggers that did this, and I don't know who they are. That change has been made, and now the numbers seem to be a bit more realistic. On August 1, Silverlight 2 had a 1.01% install base, and Silverlight 1 had a 8.12% install base. Today, Silverlight 2 has 10.34%, and Silverlight 1 has 6.89%. This still totals 17.23% for Silverlight installs which means that the Silverlight install base almost doubled in August.

So not the huge jump it originally looked like, but still respectable.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList
Posted: Aug 31 2008, 04:38 by Bill Reiss | Comments (6) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under:

Any VB Silverlight developers out there?

I remember a couple of years ago sitting in a users group meeting where the presenter asked who was a VB.NET developer, and who was a C# developer, and about 75% of the room said they were VB developers. About a year later, the same question was asked, and about 75% said they were C#. Just the other day, just a couple of hands went up to VB for the same question.

I've seen a few questions on the forums lately from people using VB.NET to write their Silverlight apps, and I was curious how widespread this is. If VB is your preferred language, please post a comment below.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList
Posted: Aug 29 2008, 05:03 by Bill Reiss | Comments (4) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under:

Olympics, DNC a boon for Silverlight

UPDATE: Looks like some clever Silverlight bloggers were skewing the numbers, see my new post here: http://www.bluerosegames.com/SilverlightBrassTacks/post/Remember-what-I-said-about-statistics.aspx 

These stats are from http://riastats.com and you know what they say, there are lies, damn lies, and statistics. If you know of other benchmark sites that track the install base for Silverlight, I'd love to hear about them, please post in the comments.

According to riastats.com, before the Olympics the percentage of users without Silverlight installed was right around 90%, with less that 1% having Silverlight 2 installed. Jump forward to today's numbers. Only 48% without Silverlight installed at all, 34% have Silverlight 2 installed, and 17% have Silverlight 1.

If these numbers are even close to accurate, this is a huge gain for Silverlight and a great foot in the door for the technology.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList
Posted: Aug 28 2008, 10:02 by Bill Reiss | Comments (4) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under:

Calling WCF on the server of origin from Silverlight

Let's say you're building a Silverlight app that uses WCF to talk to the same server that the web page is being served up from. You create your application, test it locally, it all works fine, but you go and deploy it to the server and it doesn't work any more. You look in Fiddler and don't see any traffic at all. If you debug, you may see an exception like this:

The remote server returned an unexpected response: (404) Not Found.
at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
at WCFToLocalServer.ServiceReference1.ServiceClient.ServiceClientChannel.EndDoWork(IAsyncResult result)
at WCFToLocalServer.ServiceReference1.ServiceClient.WCFToLocalServer.ServiceReference1.Service.EndDoWork(IAsyncResult result)
at WCFToLocalServer.ServiceReference1.ServiceClient.OnEndDoWork(IAsyncResult result)
at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)

Or worse, you get one of these:

System.ServiceModel.CommunicationException: An error occurred while trying to make a request to URI 'http://localhost:15840/WCFToLocalServerWeb/Service.svc'. This could be due to a cross domain configuration error. Please see the inner exception for more details. ---> System.Security.SecurityException ---> System.Security.SecurityException: Security error.
   at MS.Internal.InternalWebRequest.Send()
   at System.Net.BrowserHttpWebRequest.BeginGetResponseImplementation()
   at System.Net.BrowserHttpWebRequest.InternalBeginGetResponse(AsyncCallback callback, Object state)
   at System.Net.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__3(Object sendState)
   --- End of inner exception stack trace ---
   at System.Net.AsyncHelper.BeginOnUI(BeginMethod beginMethod, AsyncCallback callback, Object state)
   at System.Net.BrowserHttpWebRequest.BeginGetResponse(AsyncCallback callback, Object state)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteSend(IAsyncResult result)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.OnSend(IAsyncResult result)
   --- End of inner exception stack trace ---
   at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
   at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
   at WCFToLocalServer.ServiceReference1.ServiceClient.ServiceClientChannel.EndDoWork(IAsyncResult result)
   at WCFToLocalServer.ServiceReference1.ServiceClient.WCFToLocalServer.ServiceReference1.Service.EndDoWork(IAsyncResult result)
   at WCFToLocalServer.ServiceReference1.ServiceClient.OnEndDoWork(IAsyncResult result)
   at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)

What is going on?

The problem is that endpoints in the service client proxy code that gets generated use absolute URIs. This URI is stored in the ServiceReferences.ClientConfig:

<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_Service" maxBufferSize="65536"
                    maxReceivedMessageSize="65536">
                    <security mode="None" />
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:15840/WCFToLocalServerWeb/Service.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Service"
                contract="WCFToLocalServer.ServiceReference1.Service" name="BasicHttpBinding_Service" />
        </client>
    </system.serviceModel>
</configuration>

This is fine if you're hitting a service like Digg or one of the other public web service APIs out there, but not if you want to be able to test on your own machine and also deploy the same XAP to your server without rebuilding.

You could go ahead and change this to the URI on your server and rebuild, but then it won't work locally for testing unless you have a crossdomain file on your server, and you would be hitting your server's web service, not your local one while testing.

So how do we get around this?

One workaround I've used is to dynamically build the service's URI based on the URI of the page so no matter where the app is running, it will call the right server. The generated proxy client code inherits from System.ServiceModel.ClientBase which has a few other constructors besides the default one which checks the config information to get the endpoint. The one we're interested in is this:

protected ClientBase(Binding binding, EndpointAddress remoteAddress); 

You'll have a line something like the following in your app:

ServiceReference1.ServiceClient svc = new WCFToLocalServer.ServiceReference1.ServiceClient();

Replace it with the following:

Uri uri = System.Windows.Browser.HtmlPage.Document.DocumentUri;
string host = uri.AbsoluteUri;
host = host.Substring(0, host.Length - uri.LocalPath.Length);
string servicePath = "/WCFToLocalServerWeb/Service.svc"
string serviceUri = host + servicePath;
ServiceReference1.ServiceClient svc = 
      new WCFToLocalServer.ServiceReference1.ServiceClient(new System.ServiceModel.BasicHttpBinding(),  new System.ServiceModel.EndpointAddress(serviceUri));

 

Make sure to change the servicePath in this sample to the actual location of your web service. You'll also have to change the object names to match your class names and namespaces generated by the "Add service reference" wizard.

Now no matter where you run the app, whether it's a dynamic port on the Visual Studio web server, or on your local IIS, or on your server, the web service located on the same host that the page is served up from will now get the request. You can check this out in Fiddler and confirm that it's going to the right place.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList
Posted: Aug 21 2008, 03:53 by Bill Reiss | Comments (12) RSS comment feed |
  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under:

Smack your head simple Password text box

Sometimes you see something and you say why didn't I think of that. Silverlight 2 RTW will have a password property on the text box, but what do you do until then? How about using a font where every character is the same?

See the post here: http://dev-tricks.net/silverlight-password-field-no-longer-missing

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList
Posted: Aug 14 2008, 13:38 by Bill Reiss | Comments (3) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under:

Silverlight Game Contest rules and FAQ now online

I previously posted on my game development blog about a Silverlight game development contest.

http://silverlightrocks.com/cs/blogs/silverlight_games_101/archive/2008/07/23/announcing-a-new-silverlight-game-contest.aspx

This contest is being sponsored by TeamZone Sports http://www.teamzonesports.com (who happens to be my employer) and I wanted to briefly update you that the contest site is live, with official rules and FAQ. The submit page isn't quite ready yet, I'll post again when this goes live.

The official contest page is here:

http://www.teamzonesports.com/SilverlightGameContest

Good luck with your games and I'm looking forward to seeing them!

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList
Posted: Aug 13 2008, 05:17 by Bill Reiss | Comments (7) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under:

Does Silverlight need to beat Flash to be successful?

I've seen some posts and comments lately about how Silverlight can't beat Flash, about how it's facing an uphill battle, and the like. Personally I don't feel that Silverlight has to beat Flash to be successful, and I don't think this is even a major goal for Silverlight at this point.

Is there only room in the market for one RIA technology? This is kind of like saying ASP.NET can't be successful unless it totally kills PHP. There are still many things that Flash is better at, and if Flash is more suited to your needs, by all means use the right tool for the job.

In my opinion Microsoft needed a platform for creating online rich experiences that they owned. They didn't want to create their next wave of online offerings using someone else's technology, and the current RIA platforms weren't really suitable to their purposes anyway.

Even if Silverlight becomes the platform for a bunch of new Microsoft offerings but doesn't gain ground in the market overall, I feel it will still be a success for Microsoft. Anything above that is gravy. Do I believe that Silverlight will eventually become a major player? Yes, I do, and I am putting significant stake of my career in Silverlight's corner.

Eventually, in version 3 or 4 of Silverlight, it may offer almost everything Flash offers and more, but for now, it doesn't, and that's OK. If Silverlight in its current form does what you need, and you can do it quicker and better, go for it, but it's a bit early for the Flash/Silverlight wars.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList
Posted: Aug 07 2008, 02:04 by Bill Reiss | Comments (11) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under:

Fiddler is your friend for Silverlight communications debugging

One of the tips I recommend most often is to add Fiddler to the list of troubleshooting tools you use when developing Silverlight apps. Fiddler is an HTTP web debugging proxy and intercepts and logs all HTTP traffic. You can download it for free here:

http://www.fiddlertool.com/fiddler/

You can easily see issues like a clientaccesspolicy file not being found, or the wrong url for a video or an image, or hitting the wrong server for a web service request. A couple of tips for getting started with Fiddler. You can't intercept traffic going to the Visual Studio web server (Cassini), and you can't by default intercept traffic to localhost. For the localhost issue, you can pretty easily add an entry to the hosts file on your machine for 127.0.0.1:

http://compnetworking.about.com/od/windowsnetworking/g/hosts-file.htm

Then to test your app hit the host name you specified in the hosts file instead of localhost. A lot of times the app will work fine locally but then when deployed to another server the app fails. Fiddler will be able to intercept these calls without any changes and you should be able to fine the issue quickly.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList
Posted: Aug 07 2008, 01:22 by Bill Reiss | Comments (11) RSS comment feed |
  • Currently 2/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under:

Be careful when embedding fonts in Silverlight XAP file

There was a question on the Silverlight forums a while back where someone wanted to use the Tahoma font in their Silverlight application. http://silverlight.net/forums/p/20570/77555.aspx

Tahoma isn't included in the built in fonts, so one suggestion was to include the tahoma ttf file in the XAP file. I raised a red flag on that because of discussions I was involved with when XNA Game Studio first got text support. It turns out that you, as a user of Windows, do not have permission to redistribute the font files included with Windows.

There was some discussion about whether it was the same as embedding a font file in a Word doc, which you are allowed to do, but the difference is that the font file is obfuscated when embedded in a Word doc, so you can't easily extract the font file. In a XAP file (even if it's embedded as a resource in the DLL) it is trivial to extract the font file.

Stefan Josten followed up and contacted someone at Microsoft and received the response that you cannot in fact legally embed Tahoma in a Silverlight app without obtaining a license from the font author http://www.ascendercorp.com/inquiry.aspx?Ref=Microsoft

So if you're embedding fonts in Silverlight, make sure they are public domain or you have the license to redistribute them.

DISCLAIMER: I am not a lawyer and you should consult your favorite attorney about this or any other legal issue.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList
Posted: Aug 05 2008, 10:33 by Bill Reiss | Comments (10) RSS comment feed |
  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: