September 2009 - Posts - More Wally - Wallace B. McClure
in

MoreWally.com

Giving people what they want, More Wally. This is the technical and personal blog site of
Wallace B. (Wally) McClure.

This Blog

Syndication

News

Please goy buy 3-4 copies of my book on MonoTouch titled "Professional Android Programming with Mono for Android for .NET/C# Developers." They make great gifts all year round. Plus, I get about $.25 when you buy a copy.

Technical Sites

More Wally - Wallace B. McClure

This blog will have all kinds of posts about Wally McClure. In it, there will be tons of .NET and computer programming posts as well as Wally's views on life in general. As you might guess, this site and blog help you get More Wally in your life. What more could anyone want? iPhone, Android, MonoTouch, MonoDroid, Mobile, HTML5, .NET, ADO.NET, ASP.NET, AJAX, jQuery, jQuery Mobile, ASP.NET AJAX, and Windows Azure............follow me on twitter at Wally

September 2009 - Posts

  • MonoTouch 1.0 released

    MonoTouch 1.0 was released today.  I think that is a very exciting release.  With MonoTouch, developers can build applications with C# and run them on the iPhone.  Now, these apps are NOT straight ports of an existing application.  These apps have to be compiled against the iPhone SDK, which only runs on the Mac. That's not a huge deal, but something you need to be aware of.  I have owned an Intel based Mac for a couple of years, so it was no big deal to me.  Heck, I bought the Mac in 2007, when I thought that there would be a MonoDevelop for the Mac was coming RSN.  It should be out in October, 2009 with MonoDeveleop 2.2.

    There has been all kinds of talk today about MonoTouch.  The key discussion seems to be centered around "Is this thing worth $399 per year for an individual license."  Here is my answer:

    • If you already doing development with Objective-C, PhoneGap, or some other tool, the answer is a resounding NO.  There is no value in spending additional money on this tool if you are already doing iPhone development.  Why would you?
    • If you are a .NET developer and want to develop on the iPhone, the answer is a resounding YES. You will be able to justify the $399 cost in time saved by not having to relearn a completely new programming language (C#).
  • Get the real error for "Role instances did not start within the time allowed."

    Do you get the error "Role instances did not start within the time allowed." when you are working in Visual Studio and attempting to debug a Windows Azure application?  I just rebuilt my laptop and bang, I was getting the error.  Its not a very helpful error at all.  How do you find out the real error?  I've been googling for this off and on all afternoon.  Bang, here's the solution:  "Start things in Visual Studio spinning up, and in the 30 seconds before everything came crashing down, try to hit http://127.0.0.1:81 (the default location for Azure web roles)." By pointing my browser at the url, I got the real error, which happened to be a couple of missing assemblies, and I was off and running again.

     

  • .NET code in the iPhone - Asynch Http Web Request

     I just wrote the following code and ran it in the iPhone simulator on my mac using MonoDevelop and MonoTouch.  With this code, I wrote it in .NET and then opened it in MonoDevelop, massaged appropiately, and then built it.  It ran!  Very cool.  Here's a copy of the code from VS.NET.  It ran perfect in the MonoDevelop IDE and the iPhone simulator.  A word of warning, running in the simulator is no guarantee it will run in a physical iPhone or iPod Touch.

    Code:

                string Url = "http://somewhere";
                string Body = "{\"ld\":{\"UserName\":\"blah\",\"PassWord\":\"blah\",\"AppKey\":\"blah\"}}";
                byte[] byteData = UTF8Encoding.UTF8.GetBytes(Body);
                try
                {
                    // Create the web request
                    HttpWebRequest request = WebRequest.Create(Url) as HttpWebRequest;
                    request.ContentLength = Body.Length;

                    // Set type to POST
                    request.Method = "POST";
                    request.ContentType = "text/json";
                   
                    // Write the parameters
                    StreamWriter stOut = new StreamWriter(request.GetRequestStream(), System.Text.Encoding.ASCII);
                    stOut.Write(Body);
                    stOut.Close();
                  
                    request.BeginGetResponse(new AsyncCallback(ProcessHttpResponse), request);
                }
                catch (WebException we)
                {
                    Console.Error.WriteLine("Exception: " + we.Message);
                }
                catch (System.Exception sysExc)
                {
                    Console.Error.WriteLine("Exception: " + sysExc.Message);
                }
     

    Here is the callback:

            private void ProcessHttpResponse(IAsyncResult iar)
            {
                HttpWebRequest request = (HttpWebRequest)iar.AsyncState;
                HttpWebResponse response;
                response = (HttpWebResponse)request.EndGetResponse(iar);
                Console.Error.WriteLine("get response.");
                System.IO.StreamReader strm = new System.IO.StreamReader(
                    response.GetResponseStream());
                string responseString = strm.ReadToEnd();
                response.Close();
                Console.Error.WriteLine("response: " + responseString);
            }
     

    Using statements from my MonoTouch app:

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Net;
    using System.Linq;
    using System.Text;
    using System.Xml;
    using MonoTouch.Foundation;
    using MonoTouch.UIKit;

  • .NET and MonoTouch and the iPhone

     I don't know if you know this, but you can write .NET code, modify it, and then run it natively on your iPhone or iPod Touch device.  I'm currently working on an ebook about this topic for Wrox.  It should be out later this year.  I'm so pumped about this.

2006 - Wallace B. McClure
Powered by Community Server (Non-Commercial Edition), by Telligent Systems