Usman ur Rehman Ahmed's blog

Getting Started with Windows Phone 7 Development

Windows Phone 7 is to going to create hype in the market in coming days since recently collaboration between Nokia and Microsoft was made as a resultant of which Microsoft’s Windows Phone 7 operating system will be running on top of Nokia’s hardware. Also Windows Phone 7 allows development in .NET in a more controlled environment which is going to make the process of creating mobile phone apps as well as games a lot easier.

I am from Pakistan and I can tell you that out of every 10 mobile phone consumers, 7 are carrying Nokia sets with them. This powered by the fact that Nokia is to launch the Windows Phone 7 supported models in year 2011 and 2012 will bring a boost in developer market. Since there is a healthy competition already in the web development domain, it is encouraging for young developers to take a shift in paradigm and get hands on Windows Phone 7 development.

Keeping this under consideration, in this first tutorial I will take a look at setting up the environment for Windows Phone 7 development.

Note:

Before we begin please understand that there are two domains available for Windows Phone 7 development,

1-      Silverlight based mobile applications development

2-      XNA Game Studio based mobile games development

I will speak on each of these in more detail in a coming blog post.

Programming Language Barrier

Please note that C# is the recommended language for development of Windows Phone 7. VB .NET is supported for development of Silverlight based applications (using an extension kit Visual Basic CTP for Windows Phone Developer Tools to be installed after RTW package); there is no support currently for XNA Game Studio or Expression Blend for Windows 7 with VB .NET.

Pre-Requisite to Developer Tools

-          One of the required tools (Visual Studio 2010 Express for Windows Phone) for windows phone 7 can’t be installed on Windows XP. You need to be at-least running on Windows Vista or preferably Windows 7. Trying to do so will stop installation with following prompt,

Windows_phone_7_required
Contrary to that, XNA Game studio as a standalone package can be installed on Windows XP.

-          Please ensure you have Visual Studio 2010 installed. If you are running on top of Visual Studio 2008, upgrade to 2010 first before continuing.

Required Developer Tools

Next you need to have Windows Phone 7 RTW installed on your system. At the time of this writing you can get this from,

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=04704acf-a63a-4f97-952c-8b51b34b00ce&displaylang=en

With Windows Phone 7 RTW you get a bunch of tools,

-          Visual Studio 2010 Express for Windows Phone  (Not required if already running on Visual Studio 2010 Professional or Ultimate)

-          Windows Phone Emulator

-          Silverlight for Windows Phone

-          XNA 4.0 Game Studio

As mentioned above you might intend to install XNA Game Studio 4.0 alone. It is available as a stand along package at,

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=9ac86eca-206f-4274-97f2-ef6c8b1f478f

Review

Tool

Purpose

Separately Available

Windows XP Support

VB .NET support

Visual Studio 2010 Express for Windows Phone

Mobile Applications Development

No

No

Yes

Windows Phone Emulator

No

Silverlight SDK for Windows Phone

Yes

Expression Blend for Windows Phone

Yes

No

XNA 4.0 Game Studio

Mobile Games Development

Yes

Yes

No

 Package for VB .NET can be found at,

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=a808a69d-6119-47b7-b858-262be5c49915&utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+MicrosoftDownloadCenter+%28Microsoft+Download+Center%29

 

Reference Reading: http://create.msdn.com/en-us/home/getting_started

Regions Style I use in Visual Studio

More or less inspired by or mimicking the organization found within DNN source code, I tend to use following set of regions in my C# classes. From the toolbar, a quick drag drop helps me achieve readable and clean code organization,

        #region | Fields |

        #endregion

        #region | Enumerations |

        #endregion       

        #region | Constructor/Destructor |

        #endregion

        #region | Properties |

        #endregion

        #region | Event Handlers |

        #endregion

        #region | Methods [public] |

        #endregion

        #region | Methods [protected] |

        #endregion

        #region | Methods [private] |

        #endregion

Here’s how it looks within Visual Studio after cleaning of non-required regions,

Regions
Please post here if you follow a different region style since sharing is caring.

Black Duck's Visual Studio's smart search plugin review for Koders

Over past few years Open Source has find the path to a platform that is proprietary in nature; Microsoft .NET umbrella and now the shift in paradigm is coming along with more open source projects hosted using .NET suite of languages. Collaborative efforts from individuals and companies are increasing open source adaption across the globe and this trend not only facilitates development for thousands of individuals but also gives birth to new dimensions and richer applications.

As part of such an effort, Koders was acquired by Black Duck two years back. This news was shared as a cover story on Linux website   (http://www.linux.com/archive/feature/133411) which is a proof how open source community welcomes such efforts. Black Duck now offers Visual Studio, Eclipse and Mozilla FireFox plug-ins/add-on for open source or enterprise code search across a pool of selected languages and configurable selected licenses. At the time of this writing you can download these from http://corp.koders.com/downloads/

The installation of plug-in for Visual Studio 2010 was pretty smooth and as soon as I did reboot Visual Studio the Black Duck window was appearing which I pinned with my solution repository. I made a basic search and found that it is returning every language as part of the search results so I had to specify the language of choice as following,

Language-selection
If there is a Black Duck personal reading this, I think it will be great if you provide context sensitive search. What I mean by that is a search similar to Visual Studio search pane: if a file is open then search relative to the language of that file (.cs, .vb) OR search relative to currently selected project type (VB, C#, etc)

Since I had seen the demo for Black Duck Visual Studio 2010 plug-in (found right here: http://corp.koders.com/downloads/demo) I was interested in finding out the accuracy of smart search but I figured out that it is not also enabled by default and can be turned on as following,

Enable-smart-search

Again, I think an image for relative language file will create a better quality product rather than Utilities.java in the smart search enable dialog box (highlighted in red in above picture).

Smart search feature lists matches as you complete a method signature while typing in real time but what about already completed methods? I think rather than going to BlackDuck box and searching explicitly, it will be good to have feature to find relative matches for all methods when loading an existing file in. (Just the way Visual Studio backend threads highlight code errors or prepare regions boundary).

Another important consideration is that the context of searches you set is not saved across multiple visual studio reloads. Take a look at this,

Black-duck-panel-reload
The add-on since makes searches on behalf of web service sometime times out with response which is not gracefully handled and shows an error on visual studio screen. To me, it would be better if in terms of timeouts, this notification dialog is never presented,

Assertion-failed

Curious in identifying what parameters were sent behind the scene; I inspected the requests using fiddler,

POST http://www.koders.com/ws/1.0/ClientServices/Default.asmx HTTP/1.1

User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.1)

Content-Type: text/xml; charset=utf-8

SOAPAction: "http://www.koders.com/ws/GetNumberOfSearchResults"

Host: www.koders.com

Content-Length: 513

Expect: 100-continue

 <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetNumberOfSearchResults xmlns="http://www.koders.com/ws/"><key /><searchSpec><Terms>SendEmail</Terms><Language>C#</Language><License>*</License><SearchMode>Default</SearchMode><SearchTypeHint>MethodDefinition</SearchTypeHint></searchSpec></GetNumberOfSearchResults></soap:Body></soap:Envelope>

Search
I may intend to write down my own application on top of this web service since I don’t find any authentication or authorization, not even a pattern sequence no. that validates search is made from authenticated client (plug-in itself and not by a third party). Black Duck should introduce a sophisticated authorization in the plugin to restrict tons of vague searches. It will definitely help them refine their searches.

The plug-in has potential issues while disposing on Visual Studio close event. Everytime I close Visual Studio now, I face this error,

Visual-studio-error
This is what event viewer says about this crash,

EventType clr20r3, P1 devenv.exe, P2 10.0.30319.1, P3 4ba1fab3, P4 kodeshareaddin, P5 1.3.3974.7440, P6 4ce4ecf1, P7 af, P8 1, P9 system.objectdisposedexception, P10 NIL.

Clearly an exception on object dispose (assuming the black duck search panel dialog or the search thread object).

Overall, the idea is powerful (factilitate and reduced development effort) for end users but there are potentially many issues with black duck koder's plug-in which is only part of the cocept. The actual essence of the product lies in the serach results returned but unless the plug-in is attractive enough, black duck won't be able to make a good market out of it. I will be glad to hear your thoughts on this review.

12
To Posterous, Love Metalab