AspNetHost deprecated in SignalR 0.5


Now that SignalR 0.5 is out you can scale out using Windows Azure Web Roles and the Service Bus. So if you want to do so you can follow the steps laid out by Clemens Vasters. The problem I had is that I couldn’t find AspNetHost anywhere. After an hour and a half found out that AspNetHost was deprecated in 0.5 in favor of GlobalHost. So

   1: AspNetHost.DependencyResolver.UseWindowsAzureServiceBus(“{namespace}“,”{account}”, “{key}”, "{appname}", 2);

becomes

   1: GlobalHost.DependencyResolver.UseWindowsAzureServiceBus(“{namespace}“,”{account}”, “{key}”, "{appname}", 2);

 

Happy Signaling across multiple nodes!

author:  | posted @ Wednesday, May 09, 2012 1:04 PM | Feedback (0)

Using Windows 8 Tablet as a Hotspot


If you were lucky like me and were at the Microsoft BUILD conference last September then you probably have a Samsung Series 7 Tablet repurposed for the Windows 8 preview. The good thing about that tablet is that it also came with a free 1 year of AT&T 3G. I have since replaced the developer preview with the consumer preview and wasn’t able to find an easy way to share my 3G connection as a hotspot. I remember that used to be very easy in the developer preview, but for some reason it is not in the consumer preview. A little searching online and found this tutorial on how to create a hotspot, but had to do it in different order:

  1. Since there is no keyboard on the tablet, just bring the Charms Barand search for cmd
  2. Swipe down on the only found item and click on Run as administrator
  3. Type:
    • NETSH WLAN SET HOSTEDNETWORK MODE = ALLOW ssid=”NETWORKNAME” key=”YourWpa2Key”
    • NETSH WLAN START HOSTEDNETWORK
  4. Bring the Charms Bar again and search for ncpa.cpl and click on the only result it finds.
  5. You should have the list of network adapters, including the one we just created. Right click (touch and hold) on the 3G one (mine is called Mobile broadband) and click properties
  6. Go to sharing tab and check the “Allow other network users to connect through this computer’s Internet connection”
  7. Select the just created network connection under the “Home networking connection:”. Mine is called Wi-Fi 2.
  8. Hit OK.

Enjoy your free hotspot. I’m on my way to Starbucks to give this a try!

Happy hotspotting!

author:  | posted @ Thursday, May 03, 2012 7:56 PM | Feedback (0)

Join me at the 2012 Orlando Code Camp


Today I will be presenting “An inside look into a successful Windows Phone app” at the Orlando Code Camp. We will take a look at the source code of the famous Champions League Tracker application for Windows Phone 7. We will look into the architecture and implementation of the app: MVVM, WCF Rest, SQL CE, Live Tiles, and Background Tasks.

See you there!

author:  | posted @ Saturday, March 31, 2012 10:32 AM | Feedback (0)

Join me at the Weston Learning Group


Today I will be presenting my famous Programming Web for Beginners at the Weston Learning Group. Programming Web is a combination of Programming Web 101 and 201, two sessions I usually give at Code Camps and user groups across the south east. This session is intended for developers who want to learn the basics of programming for the web. We will start with theory, show some classic ASP and then move on to ASP.NET. If you are just starting programming, learning how to program, or are an experience Windows developer that wants to learn about web programming then you should not miss this session. We will also do some hands on coding with the demos from the presentation, so bring your laptop.

See you there!

author:  | posted @ Wednesday, February 15, 2012 9:50 AM | Feedback (1)

Debugging the Windows Phone Ad Control


I’ve written previously about my lessons learned of the Windows Phone 7 ad control and it appears as I haven’t learned my lesson yet. About a month ago Champions League Tracker hit the Marketplaceand it appears to be very successful: from 11/28/2011 to 12/17/2011 the app has been downloaded 2,084 times. Go ahead, download it, I’ll wait for you. There is a small problem, though, I haven’t made a single dime yet. Why? Because I decided to go with an ad based model on this one, but the pub center did not register a single impression since launch. To me it seemed weird, because during development I was seeing ads and then at one point they disappeared. I thought it was Microsoft limiting my ads or they figured the app was being used from the emulator so I paid no attention to it and published the app to the Marketplace. Then I realized there was a problem, so I decided to fix it along with other bugs. Sometimes I had ads and sometimes I didn’t. Since I had a fallback mechanism (another post on this later) for when no ads were available I didn’t worry too much. So today was the first day of the new version out in the wild and after checking for ads several times throughout the day I noticed there were still no ads. Furthermore, I asked a few of my peers to check it out and they came back with the same result. So I decided to investigate.

I figured the Ad Control would make some sort of HTTP call, so I decided to fire up Fiddlerand inspect the traffic. I followed this post on how to intercept the traffic from the emulator and started sniffing away. Since the Ad Control uses HTTPS, you also have to install Fiddler’s root cert into the emulator by following these directions. So I fired up the emulator and I’m anxiously watching Fiddler for some data to popup when I see this beautiful sighting:

image

I then went ahead and inspected the request only to see the following URL being used: /v3/Delivery/Placement?pubid=[someguid]&pid=[someid]&adm=2&cfmt=text,image&sft=jpeg,png,gif&w=480&h=80&fmt=json&cltp=app&dim=le&lc=en-US&idtp=mid&uid=[someotherguid].

I copy the URL in my browser and get a JSON response which basically said there were no ads to display. Thank you, Sherlock! So I decided to check the querystirng parameters one by one. As it turns out, pubid is the Application ID. At this moment I decided to compare it with the actual ID and low and behold, it was WRONG! It was very similar, but not exact! Maybe at some point in time of my development I changed the ID by mistake or something. So I change it back to the right one and my ads start working again.

So to conclude, just like I said more than a year ago:

If it doesn’t work on the emulator it will probably not work on the device.

So debug it before you submit to the marketplace!

Happy programming!

author:  | posted @ Friday, December 23, 2011 12:01 AM | Feedback (0)

We must stop the censorship now before it is too late!


I've censored the following, in protest of a bill that gives any corporation and the US government the power to censor the internet--a bill that could pass THIS WEEK. To see the uncensored text, and to stop internet censorship, visit: http://americancensorship.org/posts/11801/uncensor

We ████ ████ the ██████████ now ██████ it is too ████!

Uncensor This

author:  | posted @ Wednesday, December 14, 2011 11:53 AM | Feedback (0)

Create an SMS Task Using the Contact’s Name in Windows Phone


You can use the SmsComposeTask to create an SMS with Windows Phone. As the code below shows, it is very easy to do.

   1: <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
   2:     <Button Content="Number Only" Height="72" HorizontalAlignment="Left" Margin="12,6,0,0" Name="btnNumberOnly" VerticalAlignment="Top" Click="btnNumberOnly_Click" />
   3:     <Button Content="Name Only" Height="72" HorizontalAlignment="Left" Margin="12,84,0,0" Name="btnNameOnly" VerticalAlignment="Top" Click="btnNameOnly_Click" />
   4:     <Button Content="Name and Number - Contact" Height="72" HorizontalAlignment="Left" Margin="12,162,0,0" Name="btnNameAndNumber" VerticalAlignment="Top" Click="btnNameAndNumber_Click" />
   5:     <Button Content="Name and Number - No Contact" Height="72" HorizontalAlignment="Left" Margin="12,240,0,0" Name="btnNameAndNumberNoContact" VerticalAlignment="Top" Click="btnNameAndNumberNoContact_Click" />
   6: </Grid>
   1: private void btnNumberOnly_Click(object sender, RoutedEventArgs e)
   2: {
   3:     SmsComposeTask task = new SmsComposeTask();
   4:     task.Body = "Number Only";
   5:     task.To = "305-555-1212";
   6:     task.Show();
   7: }
   8: private void btnNameOnly_Click(object sender, RoutedEventArgs e)
   9: {
  10:     SmsComposeTask task = new SmsComposeTask();
  11:     task.Body = "Name Only";
  12:     task.To = "Chris Sells";
  13:     task.Show();
  14: }
  15:  
  16: private void btnNameAndNumber_Click(object sender, RoutedEventArgs e)
  17: {
  18:     SmsComposeTask task = new SmsComposeTask();
  19:     task.Body = "Name and Number - Contact";
  20:     task.To = "Chris Sells <206-555-0003>";
  21:     task.Show();
  22: }
  23:  
  24: private void btnNameAndNumberNoContact_Click(object sender, RoutedEventArgs e)
  25: {
  26:     SmsComposeTask task = new SmsComposeTask();
  27:     task.Body = "Name and Number - No Contact";
  28:     task.To = "Chris Sells <206-444-0000>";
  29:     task.Show();
  30: }

The first “Number Only” button creates a new task and sets the To to a number. This generates the following SMS:

Capture0    Capture1

When clicking on the number, the phone prompts us with some options where we can open the contact and see the contact’s information:

Capture2     Capture3

In this case we can see that since the number doesn’t exist in the contacts address book we are displayed with a temporary contact’s card (unknown). Furthermore, if the number were to belong to a contact it would display that contact’s information:

Capture4     Capture5

It is also important to notice that the formatting of the number doesn’t affect the OS’s ability to relate it to an existing contact. As you can see the SMS was created with the format xxx-xxx-xxxx and the contact was saved with the format (xxx)xxxxxxx. Very nice and expected detail for the Redmond guys!

The next button, “Name Only”, creates a new SMS with a name. For some reason, the OS is not capable of tying this name to a contacts (even though it exists):

Capture6    Capture7

As you can see it linked to a temporary contact and treats the To as an email. Weird.

Continuing to the next button, “Name and Number – Contact”, we are creating a new SMS specifying the To in the format of “Name <Number>” (similar to the email format: “Name <Email>”). In this case the result is similar to the number only, but with the exception that the To line of the SMS app shows the name instead of the number. A much better user experience for your users:

Capture8    Capture5

Finally, the “Name and Number – No Contact” button, creates a new SMS the same way as the previous case, but using the name of a contact that exists and a phone number of a contact that doesn’t exists. This results in an unknown contact:

Capture9    Capture10

It is very important to mention that the OS always ignores the name and uses the number as a link to a contact. For example, using the same example as above using “John Doe <206-555-0003>” will result in Chris Sells contact card to appear, but John Doe’s name will show in the SMS app.

Happy Programming!

author:  | posted @ Thursday, November 24, 2011 9:00 AM | Feedback (0)

Querying Contacts After Converting to WP7 Mango


If you are working in an application that has been converted from WP7 to WP7.1 (Mango) and are trying to query the contacts like the code below you might get a helpless exception of type System.Exception with the message “Exception”, no InnerException and a StackTrace similar to:

at Microsoft.Phone.UserData.QueryDataEnumerable`1.EnsureInteropInit()
at Microsoft.Phone.UserData.QueryDataEnumerable`1.GetNextBatch(Int32 nextIndex)
at Microsoft.Phone.UserData.QueryDataEnumerator`1.MoveNext()
at Microsoft.Phone.UserData.Contacts.GetContacts(Object state)
at System.Threading.ThreadPool.WorkItem.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadPool.WorkItem.doWork(Object o)
at System.Threading.Timer.ring()

   1: Contacts contacts = new Contacts();
   2: contacts.SearchCompleted += (s, e) =>
   3: {
   4:     //Some Code Here
   5: };
   6: contacts.SearchAsync("John", FilterKind.DisplayName, null);

Not very useful!

The problem is that you haven’t indicated Windows Phone to give you capabilities to access the user’s contacts. During the migration from 7.0 to 7.1 Microsoft forgot to append the new capabilities to the WMAppManifest.xml and hence the error.

To solve this simply add the capability to the WMAppManifest.xml

   1: <Capability Name="ID_CAP_CONTACTS"/>


Happy programming!

author:  | posted @ Wednesday, November 23, 2011 9:03 AM | Feedback (1)

Debugging Tombstoning with WP7 (Mango)


A new feature of Mango (WP 7.5) is fast app switching, a much needed feature, which every developer should implement in their apps. Before mango, every time the application was deactivated the developer had to maintain state and restore it once the application was re activated. That resulted in very slow transitions between apps and a bad user experience. With fast app switching and the WP 7.1 SDK, the phone maintains all state of the app when it is deactivated and when the user activates it again the app starts right away. It is a much better user experience! Windows Phone tries it’s best to maintain the state, but it is not 100% sure that when the user comes back to your app the state will be preserved, so we can check whether the state is still there and if not restore it ourselves.

   1: private void Application_Activated(object sender, ActivatedEventArgs e)
   2: {
   3:     if (!e.IsApplicationInstancePreserved)
   4:     {
   5:         RestoreState();
   6:     }
   7: }

Very easy to do! This is great, but it doesn’t mean we don’t have to implement tomstoning (please note the article refers to WP 7.0, not 7.1), since we still want to maintain a good user experience, we should restore everything as it was even if the phone wasn’t able to persist the state. You can read the article linked above and it’s second part for a great explanation of how to do so.

The question then arises, how do we debug tombstoning if the application is persisted every time we reactivate the app? We have two options:

  1. Deactivate the app and play around the emulator (or phone) by opening as many apps as you can and pray the phone doesn’t preserve the state when it is reactivated.
  2. Right click on your project file and go to properties. Navigate to the Debug tab and check the “Tombstone upon deactivation while debugging”.

image_thumb4

As you might imagine option 2 is the recommended approach as it is probably a much more efficient way to debug tombstoning! Next time your application is activated e.IsApplicationInstancePreserved will be false.

Happy Tombstoning!

author:  | posted @ Friday, November 18, 2011 11:44 AM | Feedback (1)

Multiple Language Keyboard in Windows Phone 7.5


I’m loving my Mango update on Windows Phone 7. With many new features incorporated into the phone there is one that I was really looking forward to: The multiple language soft keyboard. I’m used to having a hard keyboard on my phones and therefore I got the Dell Venue Pro because of the awesome vertical keyboard. The more I used the phone the more I noticed that the soft keyboard did a great job in auto correcting my spelling and found myself using the hardware keyboard less and less. The only problem I had was that I use my phone both in English and Spanish and I have my phone culture setup to English. So typing in Spanish with the soft keyboard resulted in incorrectly autocorrected words. Therefore I was still tied to the hard keyboard. With Mango I can now setup the keyboard to have multiple languages and change the language within the keyboard making my hardware keyboard useless.

To setup the multiple languages go to Settings – Keyboard and check all the languages you want to have:

Keyboard2_thumb Keyboard_thumb

Then while the software keyboard is opened you can press on the bottom right button (ENU while in English) to switch between languages:

SoftKeyboard_thumb SoftKeyboard3_thumb SoftKeyboard2_thumb

Notice in the picture above, that while in Spanish the keyboard even added an “Ñ”. You can also press and hold to list all possible values as the third picture shows

Now you can see that the auto correction automatically uses the selected language:

SoftKeyboard4_thumb SoftKeyboard5_thumb

Update 10/10/2011
It seems as if the current version of the OS only remembers the last language you used. If you want the OS to remember the language on a per user basis, then make your voice heard by voting on this feature suggestion.

I now know that my next Windows Phone will not have a physical keyboard. Happy Typing!

author:  | posted @ Thursday, October 06, 2011 12:37 PM | Feedback (0)