Home / Articles posted by eric (Page 3)

Value can not be null. Parameter name: serviceType

WCF itself isn’t inherently compliated, but learning WCF presents many stumbling blocks. The terminology can be somewhat convoluted, and WCF development and debugging often boils down to making sure many different parts of disparate XML files are edited correctly.

However, the true pain lies in the exceptionally unhelpful error messages. When developing a WCF service that is hosted in a Windows Service (a net/tcp WCF server, for example), you may be presented with this error:

Value can not be null. Parameter name: serviceType

Of course, your code doesn’t have any parameters named “serviceType”. You can’t debug this error because your service can’t even start. “Value can not be null. Parameter name: serviceType” is all you’ve got.

After many hours of frustration, the solution is rather simple. The error happens when the windows service tries to create the WCF server, via this call:

protected override ServiceHost CreateServiceHost(
Type serviceType,
Uri[] baseAddresses
)

CreateServiceHost cannot load the Type information for your WCF service, either because the namespace is wrong of the file itself cannot be loaded. For example, assume your WCF service is defined with the interface IMyService, and implemented in the namespace MyNamespace.MyServiceImplementation, and the file MyServiceImplementation.dll. For one reason or another, MyNamespace.MyServiceImplementation cannot be loaded. Most often this is because of a typo in your namespace declaration. Check both the .config file and the .cs file where it is implementged. Another common problem is that the .dll was not copied to the correct directory. Verify that the MyServiceImplementation.dll is in the same folder as the windows service that is trying to load it. Check your project references or automated build scripts if this was the cause of the error.

Using the Chrome Developer Tools for JavaScript Debugging

One of the thorniest problems with web development has always been cross-browser compatibility. As our web sites become more interactive we focus more on JavaScript and AJAX to deliver rich user experiences, which introduces new challenges for debugging and tracking down cross-browser differences.

Firebug is an excellent option when working with Firefox, and Visual Studio is perfect for Internet Explorer. Until recently there was no good option for Google Chrome, but earlier this year Chrome updated the developer tools, and they rock.

Assuming you’re on a Windows machine, hit Control+Shift+J to open the developer tools window. You can also get there from the page menu, or by right clicking on any element in the page to “inspect element.”

The toolbar at the top lets you inspect the DOM elements, debug scripts, even inspect the cookies currently saved in the browser. It isn’t obvious from teh UI, but there are keyboard shortcuts for each of the debugger commands:
F8 - Run
F10 - Step over
F11 - Step into

Note that if the browser window is focused and not the debugger window, F11 will have the window go into full screen mode.

You can set breakpoints by clicking on the line number in the script window, or by adding the “debugger;” line to your javascript. Simply mouse over a variable to see its current value.

While I’ve found that Chrome is a phenomenal browser and I’m in love with its performance, it can be somewhat less forgiving of errors than other browsers. The Chrome debugger is an excellent tool for tracking down those errors.

Source Control: How to automatically “get latest” with subversion

First things first – if you aren’t currently using source control or are still using something like SourceSafe – stop! Read this article from Jeff Atwood, and come back.

Team System is a great option for larger companies with the budget for it, but for most shops subversion is the perfect solution. Set up your subversion server, and on the clients use TortoiseSVN to integrate subversion with the shell.

While merging  can be relatively painless with Tortoise, too often people forget to get updates from the repository often, which can lead to subtle bugs during development. Fortunately Tortoise comes with a command like interface making it easy to automate this process. Simple create an old-fashioned batch file with notepad in your StartUp folder, and add this line:

TortoiseProc.exe /command:update /path:”c:\path\to\your\code\” /notempfile /closeonend:1

Yes, the  /notempfile switch is required. The  /closeonend:1 will close the dialog automatically if there are no errors. For other options, check the documentation here.

Reducing your Amazon S3 costs…. with a catch

Amazon just recently announced a “Reduced Redundancy Storage” option for S3 objects. In short, you can slash the costs of S3 storage by 33% by accepting a slightly greater chance of losing your data. So ask yourself…

Do I feel lucky? Well, do ya, punk?

In truth, the costs of any data loss in Amazon S3 are minuscule, under both the traditional model and under RRS. If you use S3, I highly recommend starting with the Vogels’ article on RRS and durability.

The same goes for durability; core to the design of S3 is that we go to great lengths to never, ever lose a single bit. We use several techniques to ensure the durability of the data our customers trust us with, and some of those (e.g. replication across multiple devices and facilities) overlap with those we use for providing high-availability. One of the things that S3 is really good at is deciding what action to take when failure happens, how to re-replicate and re-distribute such that we can continue to provide the availability and durability the customers of the service have come to expect. These techniques allow us to design our service for 99.999999999% durability.

Under RRS, instead of 99.999999999% durability, your object is only stored in such a way that is will survive a single data loss, or 99.99% durability:

We can now offer these customers the option to use Amazon S3 Reduced Redundancy Storage (RRS), which provides 99.99% durability at significantly lower cost. This durability is still much better than that of a typical storage system as we still use some forms of replication and other techniques to maintain a level of redundancy. Amazon S3 is designed to sustain the concurrent loss of data in two facilities, while the RRS storage option is designed to sustain the loss of data in a single facility. Because RRS is redundant across facilities, it is highly available and backed by the Amazon S3 Service Level Agreement.

Yes, it’s still covered by the SLA! Finally, to summarize the real risk in terms your manager can undterstand, take this from the RRS announcement on the AWS blog:

The new REDUCED_REDUNDANCY storage class activates a new feature known as Reduced Redundancy Storage, or RRS. Objects stored using RRS have a durability of 99.99%, or four 9’s. If you store 10,000 objects with us, on average we may lose one of them every year. RRS is designed to sustain the loss of data in a single facility.

I suspect that for most business applications 99.99% durability is “good enough” and a 33% savings cost is an great trade-off.

Finally, for my fellow .NET developers… Amazon did update their .NET SDK with this announcement. Be sure to download the latest version.

A brief introduction to video in HTML5

With the release of the iPad there has been a renewed interest in HTML5, since it enables a web site to display video without using Flash. On the one hand displaying video in HTML 5 couldn’t be simpler. It is one tag, that links to one file, like so:

<video src=”waterfall.mp4″ controls></video>

Too easy! But as always, the devil is in the details. The issue with video over the internet has always been the lack of a common standard for video formats. HTML5 does not solve this problem. As of today, HTML5 does not specify the one format that a browser must support. When doing video in HTML5, you essentially have two choices: Ogg Theora or H.264. Ogg Theora is open and free of patents (as far as we know), but is less widely supported and H.264 offers better performance. H.264 is covered by patents, but they are not charging royalties for free internet video until 2015. Today, H.264 is supported by Safari (including the iPhone/iPad), whereas Firefox supports Ogg Theora. Google Chrome supports both. Internet Explorer 8 still does not support the <video> tag. For an updated browser support comparison, see wikipedia.

With this in mind it is easy to alter our <video> tag to link to alternate formats, so our web page will work both Safari, Chrome and Firefox:

<video poster=”poster.jpg” controls>

<source src=”waterfall.mp4″ type=”video/mp4″>

<source src=”waterfall.ogg” type=”video/ogg”>

Your browser isn’t HTML5 compliant, download the video <a href=”waterfall.mp4″>here</a>

</video>

The browser will automatically select the video to display based on what format it supports. In the example above, Safari and Chrome viewers will see the “waterfall.mp4” video, and Firefox viewers will see the “waterfall.ogg” video. Internet explorer viewers will see the “Your browser isn’t HTML5 compliant” message. You could easily embed a flash video here as well instead of a download link.

All that remains is converting your source video both an H.264 mpeg and an ogg video. QuickTime Pro is relatively inexpensive and can easily convert to h.264 and many other formats. The free VLC player supports converting to ogg.  For Windows machines, SUPER can convert to FLV. There are several other free or open source implementations to convert videos from one codec to another – as always google is your friend.

Baby Einstein

A quick non-programming related comment… anyone who’s been blessed with children in the past 10 years surely knows about the Baby Einstein empire. Long story short, they claimed that watching TV could actually help your baby learn. Of course this is not true, and when studies came out proving that it actually hindered childrens’ language skills, Disney got pressured into offering refunds for all Baby Einstein DVDs.

The controversy remains at a simmer, because the original creator of Baby Einstein is trying to redeem his name by challenging the study. It’s a mildly interesting story, but here’s the take-home point:

In fact, I would argue that the Baby Einstein culture has been harmful, contributing to (while feeding off of) the over-parenting that has marked the most recent generation. It can be argued that parents should worry less about trying to force the intellectual development of their very young children, and just relax and give them more quality time and attention.

Turn off the TV and play with your kids! It’s good for them, and gives you an excuse to be childish on a daily basis.

Getting Started with SQL Azure

After getting an account, you can log in at http://sql.azure.com.

They provide a very basic web interface lets you set up the firewalls or create new databases, but that’s about it. To do anything interesting you have to connect via code or the management studio.

The most recent version of MS SQL Server Management Studio (2008 R2) supports connecting to Azure. It’s possible to get earlier versions to connect, but 2008 R2 also ships with an Import/Export wizard that is supposed to support migrating data to Azure, but I have had little success with that. The open source Azure Migration Wizard has been far more reliable at moving data and informing you of any issues you’ll have migrating to the cloud.

When you connect via management studio the standard “object browser” does not work, but you can connect via a new query window:

Then specify the connection parameters, and under “options” select the database you want to connect to:

The first time you’ll attempt to connect chances are you’ll get an access denied error. SQL Azure’s firewall defaults to blocking all incoming traffic, so before you connect you have to open access to your current IP address, or the range of IP’s for your location. This is easy enough to do from your account at http://sql.azure.com. If you still cannot connect check your local firewall and ensure that the TCP 1433 is not blocked for outgoing connections (this is the port used by Azure).

Once connected you have a standard query window in Management Studio, and you can perform virtually any T-SQL function. With a few restrictions, Azure is a standard SQL server database, and very simple to work with.

AWS Announces Spot Instances: Market-Priced Cloud Computing

AWS recently announced a new service: Spot Instances.

Today we launched a new option for acquiring Amazon EC2 Compute resources: Spot Instances. Using this option, customers bid any price they like on unused Amazon EC2 capacity and run those instances for as long their bid exceeds the current “Spot Price.” Spot Instances are ideal for tasks that can be flexible as to when they start and stop. This gives our customers an exciting new approach to IT cost management.

The central concept in this new option is that of the Spot Price, which we determine based on current supply and demand and will fluctuate periodically. If the maximum price a customer has bid exceeds the current Spot Price then their instances will be run, priced at the current Spot Price. If the Spot Price rises above the customer’s bid, their instances will be terminated and restarted (if the customer wants it restarted at all) when the Spot Price falls below the customer’s bid. This gives customers exact control over the maximum cost they are incurring for their workloads, and often will provide them with substantial savings. It is important to note that customers will pay only the existing Spot Price; the maximum price just specifies how much a customer is willing to pay for capacity as the Spot Price changes.

Interestingly, this isn’t a technological innovation but is a major business innovation. The instances they are offering are the same instances offered in the tried and true AWS EC2 system. However, now they can offer these instances at a (presumed) lower price with the caveat that you may lose your instance if the market price for that compute power goes above what you are willing to pay for it.

What strikes me about this is the amazing efficiency of the system. Amazon could (in theory) rent out 100% of their aalable computing power through the EC2/spot instance system. If Amazon needs the computer power back, such as during the Christmas shopping season, they can raise the spot price and reclaim many of the resources. If a third party needs more compute power than is available, they increase their bid and drive up the price.

It should be interesting to see applications built around this model. Protein folding is the obvios example, but I can also see this as very useful for graphics rendering or even mundane tasks such as sending out newsletters.

The Microsoft/Yahoo deal and what it means to you

If you haven’t already heard, Yahoo finally gave in to Microsoft’s advances, and Bing will be the new search provider on Yahoo peroperties:

In a deal that presages its departure from a market it helped pioneer, Yahoo will scrap its own efforts to best Google in search and instead rely on Microsoft’s recently debuted Bing search engine. Ads placed next to those search results would be served up not by Yahoo’s ad platform, dubbed Panama, but by a Microsoft technology called AdCenter. Yahoo CEO Carol Bartz “is essentially giving up on search,” says Danny Sullivan, editor of Search Engine Land.

According to Danny’s twitter feed, even though this is “only” a 10 year deal, Yahoo won’t be maintaining its current search engine at all during that time, so it is in effect dead. Once the deaql expires Yahoo won’t be able to “go back” to a Yahoo search algorithm.

How does this affect you? If you run a web site take the tiem today to look at your referer stats. Where are your visitors coming from? Chances are most are from Google, but you may have a sizable chuck of traffic coming from Yahoo search. Do you have any traffic coming from Bing? How is your SEO for Yahoo search vs. Bing? Once all the regulatory red tape is complete Yahoo search is effectively gone, and all of those Yahoo users will be using Bing search instead.

PHP Frameworks, Fonts

The weather’s too good here for a more in-depth blog post, so today I just have a a few of the better links I’ve run across recently:

If you do any serious work in PHP, you need to familiarize yourself with a framework if you haven’t developed one yourself. This article on Discussing PHP Frameworks is a fair introduction to the major frameworks – no in-depth commentary as to which is best, but a good starting point if you’re not familiar with them already.

Never underestimate the power of fonts in your web design, particularly when choosing a logo.And speaking of fonts, if you’re sick of the nine “web safe” fonts we’ve been stuck with for ages, you may want to experiment with the TypeSelect project from MIT.

If you’re hiring a designer, you are using a contract, right? If not, no more excuses.

A free online drag and drop flash editor?! Try out http://www.wix.com/