posts filed under "March 2008 Entries"
(.)

Had to share this...

 


Auch wenn ich seit Kurzem ein Apple Notebook mein eigen nenne, finde ich es doch angemessen darauf hinzuweisen, dass jetzt offiziell nachgewiesen wurde, dass der Software Riese aus Redmond, Microsoft, in Sachen Sicherheitslücken schließen deutlich besser und schneller ist, als sein Unix Konkurrent.

 


 

Surprise, surprise, today I have been accepted for the Apple iPhone Enterprise Developer program - I hope it's worth the 299 US$. It's been quite a hassle getting in - Apple seems to not have expected the massive interest in its program. My PowerBook ships this Tuesday and I occasionally keep you posted on how it feels for a .NET addict to develop on an Apple OS platform. :-) For now I'm downloading all of the subscriber content...

A few days ago Adobe announced the immediate availability of Flash Media Rights Management server. Soon be gone will the days where you could just grab and exchange Flash based video content. The movie industry is already freaking out with respect to the new end user device control mechanisms introduced by Adobe's latest product addition. I don't know about you but I do not like the idea that in the future my Flash player will be remote controlled and dictate how many times I can play a video or whether I can share it with my family or not. There is still some hope left that we will see jailbreaks for Flash Media Rights Management pretty soon, too.

 


On 11th of March Google has announced significant extensions of their API which will allow developers to create even more integrated mashup experiences.

I haven't spent a great amount of time in investigating the issue but it currently seems as if YouTube's web servers do not allow cross-domain access, so trying to e.g. execute a ClientLogin() request against the YouTube API results into a security violation exception being raised. They obviously do also not support Flash/Flex based cross-domain access, as Silverlight 2.0 also respects the cross domain authorization for Flash players and would work just fine.

I've sent the Google API team an email about it and wait for an answer.

Part 2 of my tutorial on HTTP networking with Silverlight 2.0 will then showcase how to build an integrated experience with Silverlight and the YouTube backend!

 


Microsoft recently made available the long awaited Beta 1 of Silverlight Version 2.0. This new version of Silverlight includes .NET language and framework support bringing cross-platform .NET development to live. Silverlight not only comes with the first iteration of rich controls which allow developers to design great user interfaces but also contains a pretty sophisticated network stack.

In this blog post I'm going to take you through creating a Silverlight application which sends an HTTP POST request out to a (very basic PHP driven) service and prints out the response. While Silverlight implements higher level abstractions for accessing SOAP and REST based services I've seen numerous people asking for HTTP POST request support with parameters transmitted as part of the HTTP request as opposed to URL encoding them (which would be an HTTP GET request then). The popularity might be driven by users who are learning Silverlight programming and simply want to start by replacing traditional HTML forms with a Silverlight front end. Another driver might be the mere existence of "services" which accept HTTP POST requests and have not yet been migrated to a full blown REST model.

I assume you've got a solid understanding of .NET and know how to handle Visual Studio 2008. I also assume you've successfully installed all the bits required to build Silverlight 2.0 Beta 1 apps. (If not, Tim Sneath has a great post outlining what's needed.)

In order for you to easily follow along I've set up a very simple service which accepts two HTTP POST parameters (lastname and firstname) and returns a simple XML structure which - if you successfully submitted HTTP POST parameters - feeds back the input parameters. If not, it replaces them with "null".

The service can be freely accessed at http://www.24100.net/labs/silverservice.php. The root of my web server also services a clientaccesspolicy.xml file which allows any Silverlight application out there to access the service. (See the MSDN article How To Make A Service Available Across Domain Boundaries for details.)

Let's get started.

Fire up Visual Studio 2008 and create a new Silverlight Application. I usually create a Web Application along with it just because it makes testing more easy with the built-in development web server.

In the main application page Page.xaml add a button, name it Execute and hook up an event handler to the Click event:

image

Next add a TextBlock named Log which we are going to use to output debug information. I've arranged everything in a vertical StackPanel to make it look a bit better.

image

This is actually all we are going to do on the user interface side. The rest of the tutorial will focus on coding the HTTP POST request and happen in Page.xaml's code behind file Page.xaml.cs.

Open the code behind file Page.xaml.cs. If you've used Visual Studio's IntelliSense to create the Click event before, you'll find the Execute_Click() handler method stub prepared for you:

image

The HttpWebRequest class we are going to use resides in the System.Net namespace which does not get added to your Silverlight project by default Right-click on References > Add Reference... and manually add the System.Net assembly...

image

... and import the namespace by adding the appropriate Using statement at the top of Page.xaml.cs:

image

Now we are all set to start coding. The first thing we are going to do is creating an instance of System.Uri. We are then going to use the static Create() method of System.Net.WebRequest to factor an instance of type HttpWebRequest:

image

If you've used HttpWebRequest in traditional .NET applications before, you'll find out that the Silverlight implementation does not provide a synchronous GetResponse() member. Instead we do have to use .NET's asynchronous programming model to proceed. This is, where things get a bit more complicated. Before we actually proceed with sending out the HTTP request, we have to set the method - which is POST - and set the way the data gets encoded:

image

As stated above HttpWebRequest offers an asynchronous way to handle HTTP requests and responses. We are starting the request by calling the BeginGetRequestStream() method of our request object. The method expects two parameters: The first one is a callback method of type System.AsyncCallback which gets called once the asynchronous creation of the request stream completed successfully. The second parameter can be any object and represents a state object. Why do we need the second parameter anyway? The problem with our asynchronous operation is that the code inside our asynchronous callback method does not necessarily have access to objects inside the "calling" method. The object provided as the second parameter of BeginGetRequestStream() is available inside the asynchronous callback method via the AsyncState property. If the asynchronous callback method would not require any object from within the "calling scope", it would be perfectly legal to use null as the second parameter.

With that said we are going to submit the our request object itself as the second parameter so we can access it's members within the asynchronous callback method.

Here is the code:

image

Note that RequestProceed() is still underlined because we have not yet implemented it. Just for clarity: We are executing the asynchronous BeginGetRequestStream() method on our HttpWebRequest instance stating that once the operation has completed, we want to proceed with the RequestProceed() method and hand over our HttpWebRequest instance itself via the AsyncState mechanism.

Please be also aware that we are starting and asynchronous request here which will allow us to write (aka POST) data along with it. We are not handling a response, yet!

To get rid of Visual Studio's complain about the non existing RequestProceed() method let's go ahead and create the asynchronous callback method:

image

RequestProceed() must implement AsyncCallback's signature.

In the next step we first want to get back a reference to our initial request object from the calling scope. Remember that we submitted the initial request as the AsyncState parameter of BeginGetRequestStream(). All we need to do is cast it from IAsyncResult's AsyncState property:

image

Now we do need a StreamWriter in order to actually write to the request stream. StreamWriter is part of the System.IO namespace so we got to add a Using statement to our project:

image

StreamWriter's constructor expects a Stream object. We do get this via EndGetRequestStream() which itself expects an object which implements IAsyncResult and represents a pending request for a stream. Thanks god, we got both at hand! In the next line of code we are going to new up a StreamWriter object by calling our request's EndGetRequestStream() method and passing in the IAsyncResult object reference from our "calling scope":

image

We are almost there! With this brand new StreamWriter we can now easily write to the HTTP request stream.

POST parameters are defined in a format which you might very well know from URL encoded parameters. We want to hand in a firstname and a lastname parameter. Here we go:

image

Please do note that we are calling the Close() method which sends the data over the wire and closes the underlying stream. There also is a Flush() method available which sends the data out but does not close the stream. Just bear in mind that at some stage you should actively close any stream to release resources.

At this point we have send out our HTTP POST request to http://www.24100.net/labs/silverservice.php and transmitted two parameters with it. What's left to do is handling the response. Once you've followed along until here, it's an easy one as it again involves asynchronous callbacks.

So the last action inside our request callback method is to kick off handling the response:

image

You recognize the pattern. We are starting the asynchronous response handling by calling the BeginGetResponse() method of our request object. We are defining the ResponseProceed() method to be executed once the asynchronous call completed successfully and again "forward" our initial request via the AsyncState mechanism.

In our asynchronous response handler the first step we do is again casting the initial request via the asyncResult.AsyncState property. We then get an HttpWebResponse instance by calling the requests EndGetResponse() method. Finally we new up a StreamReader for the Stream returned by HttpWebResponse's GetResponseStream() method. Here is the straight forward code:

image

The last and final step is to actually use StreamReader to read the response from the web server:

image

Finally we assign the response to our Silverlight TextBlock control:

image

Here is the browser output after clicking the Execute button:

image

(You can try it out here if you've got Silverlight 2.0 installed!)

This is all we've got to do. In my next post I'm going to guide you through encapsulating all the asynchronous plumbing above into a separate class and using Silverlight's powerful eventing mechanisms to feed back responses to the main UI thread. The service at http://www.24100.net/labs/silverservice.php is available for you to test. Feel free!

 


I recently had quite some trouble trying to install Microsoft SQL Server Management Studio on Windows Vista Ultimate. Note: I'm not referring to the Express edition which can be downloaded separately and installs like a charm. The root cause seems to be that once you've got SQL Server Express installed - maybe via Visual Studio 2005 or Visual Studio 2008 - the SQL Server 2005 installer thinks, there's nothing to be added to your install and quits.

Other solutions Google revealed pointed to either running SqlRun_Tools.msi or SqlRun_Tools.exe manually from the \Setup folder and did not work for me.

What did work was to opening a command prompt and running

setup SKUUPGRADE=1

where setup points to the 2 MB setup.exe file in SQL Server 2005's DVD root.

Hope this might help others, too.

 

 


Just in case you missed it due to all the Mix 2008 buzz, the Microsoft Expression Blend 2.5 March preview has been made available for download. As not expected otherwise the god-does-this-guy-ever-sleep great Scott Guthrie provides some hands on material to jump start into Silverlight 2 development with the latest Beta.

 


I have to admit, I finally have fallen for an iPhone.

Actually, this is not entirely true. In light of a couple of business trips I had to do I found out that my not-so-often-used iPod did no longer work so I had to go for a new toy anyway. Based on discussions with good friends the video capabilities of the iPod Touch appealed a lot to me given that I quite frequently have to spend some hours in an aircraft and the idea that I could watch training videos during flights was intriguing. So initially I went looking for an iPod, not an iPhone.

During a more in-depth value-for-my-money type of product comparison I finally decided to pick the 16 GB version of the iPhone basically because I liked the idea of carrying a single device with all of my stuff on it as opposed to carrying multiple special purpose ones.

That said I'm now running an iPhone with a Vodafone (Germany) flat data tariff and hugely enjoy it. In Germany T-Mobile owns the exclusive rights to sell iPhones but the tariffs attached to their offering are so ridiculously nonsense (over the course of 24 months an iPhone will cost you + 1.000,00 € if you decide for T-Mobile) that I decided to jailbreak my device and enjoy full consumer freedom.

Left aside the geeky emotions that arise when you SFTP or SSH into your iPhone's Unix the first time, jailbreaking the iPhone has been simple and straight forward with the current version (1.1.4) of Apple's firmware.

Once the basic steps were done it took me a while to get rid of three major annoyances:

  • The Vodafone carrier logo is a bit too long for the space reserved in iPhones UI so it ends up being cut to "Voda..." which simply does not look nice.
  • If you have activated call diverts - possibly to send callers to your voice box after a while - whenever you make a call you get an annoying "Call diverts active" popup which you have to acknowledge by tapping the screen before the dial pad can be used again.
  • The EDGE data services did not work right away.

There are thousands of sources out there on how to solve each of the issues. It took me quite some time however, to separate the simple approaches from the more complicated ones, so I repeat these easy steps here for others to follow along.

Obligatory disclaimer: I have executed all steps outlined here on my 16 GB US iPhone with firmware version 1.1.4. I'm not taking any warranty of any kind as to the instructions given here. You operate on your own risk! ;-)

With that out of the way let's start:

Changing the "Voda..." text / carrier logo

From my research there seem to be multiple options when it comes to carrier logos. Most of them involve running a patched version of the springboard and replacing PNG graphics via SFTP. I have not tried any of these as I was not really requiring a graphical logo. All I wanted is getting rid of the shortened text. It turned out being absolutely easy with Erica Sadun's Make it Mine application which can easily be installed from the Community Sources. Once installed simply select the MIM app from the springboard, enter a new text and there you go. No reboot required. So my iPhone now neatly says "AT&T" as an homage to the SIM which shipped with it. :-)

Stop annoying "Call diverts active" messages when making a call

This one has been a bit tougher. Partially because there are again numerous different ways to get rid of this odd behavior and the ones which Google gave good ranks did not work for me. So this worked perfect for me:

    1. SFTP into your iPhone. Use root as the username and alpine as the password.
    2. If your iPhone runs on Nate True's jailbreak download com.apple.carrier.plist from /var/root/Library/Preferences/.
    3. If your iPhone runs Dev Teams' jailbreak  download carrier.plist from /private/var/mobile/Library/Carrier+Bundle.bundle/.
    4. In case you're on a Windows machine and don't have a property list editor (the downloaded file comes in a binary Mac format), you have to convert the downloaded file to XML before you proceed. Simply do so by using this nice web based conversion service.
    5. In the XML file change the settings for ShowCallForwarded and ShowCallForwarding from true to false as indicated in the below snippet:

    <key>ShowCallForwarded</key>
    <false/>
    <key>ShowCallForwarding</key>
    <false/>

  1. Upload the file. (Windows users: Don't worry about the format, iPhone will read XML files just fine, so you don't have to convert back.)
  2. Reboot the iPhone by turning it off and on again.
  3. That's it. You're done.

Give it a try and make a call. You no longer have to acknowledge the annoying message.

Using Vodafone Germany EDGE with the unlocked iPhone

This again was an easy one after doing some research. Here's what to do:

    1. Via the update Installer install the TMOBILE.DE EDGE EDIT fix from the Tweaks (1.1.4) category.
    2. Go to Settings > General > Network > EDGE. (Note: The EDGE option will not be available if the patch did not install correctly.)
    3. For Vodafone Germany clear all fields and enter web.vodafone.de into APN.
    4. Reboot your iPhone by turning it off and on again.
    5. That's it. Enjoy EDGE.

 

Besides the patches and tweaks outlined above I've done numerous other things to optimize my iPhone to my personal needs. One application which I really enjoy is Cucusoft's fantastic iPod Video Converter + DVD to iPod Converter Suite (direct download here) which I've used to convert entire DVD's to carry them with my iPhone.

I'm going to post more about my personal experience with Apple's power toy once I move forward. In the meantime, happy hacking.

 


Windows Vista Service Pack 1 will be available soon:

March 18, 2008

SP 1 available on Windows Update, Download Center, MSDN & TechNet

April 18, 2008

SP1 pushed via automatic download

 

I have run SP1 Release Candidate for quite a while now and it has dramatically improved my Vista experience.

 


Microsoft recently announced WorldWide Telescope - their Google Earth for the Sky.

The WorldWide Telescope (WWT) is a rich visualization environment that functions as a virtual telescope, bringing together imagery from the best ground and space telescopes in the world for a seamless, guided exploration of the universe.

 
WorldWide Telescope, created with Microsoft's high-performance Visual Experience Engine™, enables seamless panning and zooming across the night sky blending terabytes of images, data, and stories from multiple sources over the Internet into a media-rich, immersive experience.

Pretty fascinating and welcome to the 21st century!

Another surprising project Microsoft Research is currently executing is MySong.

In a nutshell, the software records your singing (preferably in tune) through a microphone, and it systematically generates an instrumental accompaniment for your song. The quality is even comparable with a professional accompanist, not to mention the cost and time involved.

This might even change the way Pop Idol might work. :-) Read the full story here and actually see how it works!