Friday, April 15, 2011
Career Transitions Presentation to Ball State University
Wednesday, April 13, 2011
SQL Saturday #67 Chicago
Most of the sessions I attended involved improving performance. Whether it was proactive (design for performance) or reactive (troubleshooting), most sessions included some coverage of indexes. Surprisingly there very little duplication of content by the different speakers. Because of the quality and relevance of the all sessions offered, it was difficult to decide which sessions to attend. Below is a brief recap of the ones I chose.
Sessions
Performance Tuning Made Easy with Thomas LaRock
Being a certified Six Sigma Black Belt, I appreciated the way Tom (blog|twitter) described a simple systematic process for performance tuning based on the Six Sigma DMAIC (Design, Measure, Analyze, Improve, Control) approach.
The Optimizer, Statistics, and Indexes with Grant Fritchey
Grant (blog|twitter) gave a great primer to the internals of the Relational Engine, the components of which have really cool names like Query Parser, Algebrizer, and Optimizer. He also spent more time discussing the Statistics histogram, which appeals to my six sigma senses, than I generally see in an hour long presentation.
WIT (Women in Technology) Panel: Energizing the Next Generation
This session seemed to have a balanced number of men and women in attendance. It was nice to hear the perspective of multiple women with different backgrounds sharing their experiences in the field. I’m really happy that most of their experiences sounded positive even in the face of adversity.
Refactoring SQL with Jeremiah Peschka
Jeremiah (blog|twitter) really highlighted the importance of using consistent naming conventions and common alias names. He touched on SQL unit testing and some open source test frameworks. He also showed refactoring examples such as, re-writing where clauses to move functions from the left side of the operator to the right side for performance gains.
Database Design Contentious Issues with Karen Lopez
This was one of my favorite sessions. It was interactive as the participants had to walk to the front of the room and anonymously vote (via post-it note) on a scale of 1 to 5 on our opinion/view of two issues which people often passionately argue about, such as, surrogate keys vs. natural keys. People that admitted to voting on the extremes (one or five) were asked to explain why they voted the way they did and open the topic for group discussion. Karen liberally made effective use of Canadian SWAG (like ketchup flavored Pringles) to persuade the edge-case voters to plead their case in the face of possible peer criticism. Karen (blog|twitter) expertly moderated the discussion and provided great pro/con examples on both sides even where it conflicted with her own views. It was both fun and educational.
Index Internals for Mere Mortals with Michelle Ufford
At a lightning quick pace, Michelle (blog|twitter) brought a great deal of insight to index internals. She showed actual representations of index pages and pointed out key elements of it, including the “uniqueifier”. She covered a great deal of information in the short one hour, but it was very clear, understandable, and educational.
Lunch
The lunch was provided by Meaty Balls. It was plenty of tasty meat and mushrooms for the price.
Check-in
The organizers offered a “Speed Pass” option where I printed my name tag, lunch ticket, and raffle tickets off in advance which meant I could sleep in a little before heading to Chicago.
Venue
The conference was hosted at the DeVry University Addison Campus which had great classroom spaces. There were ample power outlets available on the table tops for each attendee to plug in, if desired. I wish I had remembered to bring the AC adapter for my GPS for the trip home since my car lighter adapter stopped working before the trip.
Networking
I was within a SWAG keychain throw of several SQL Celebrities like Kevin Kline (blog | twitter) and Brent Ozar (blog|twitter). Brent was sitting behind me in three out of five sessions I attended - and no, I’m not a SQL Stalker.
I finally got to meet Wendy Pastrick face-to-face after several email and twitter conversations over the last year.
Credit-worthy
I’ve been running the fwPASS User Group for a few years and to do just an average job takes a surprising amount of time and effort. See my case study on continuous improvement in a professional association for more information. The organizers did an exceptional job that deserves more thanks than I can provide. I’m not sure if this is inclusive of all the organizers (which I copied from Doug Lane’s blog), but THANK YOU:
Wendy Pastrick (blog|twitter)
Ted Kruger (blog|twitter)
Norman Kelm (blog|twitter)
Jes Borland (blog|twitter)
Bob Pusateri (blog|twitter)
Aaron Lowe (blog|twitter)
Bill Lescher (twitter)
Rich Rousseau (twitter)
Thursday, April 7, 2011
IIS is Missing XAP Mime Type for Silverlight Application
Upon navigating to the web page hosting a newly deployed Silverlight application, I received the following error:
Error: Unhandled Error in Silverlight Application
Code: 2104
Category: InitializeError
Message: Could not download the Silverlight application. Check web server settings
Thanks, but which server settings? In my case the MIME type for the .xap extension was missing in IIS7. I’m not sure why it was missing since .xaml and .xbap were already defined. I simply added the “.xap” extension and it’s corresponding MIME Type “application/x-silverlight-app” and all was well.
photo credit: e v a . p é b a r / CC BY 2.0
File URI invalid for WCF HTTP Endpoint
System.ArgumentException: The provided URI scheme 'file' is invalid; expected 'http'.
The error occurred when debugging a Silverlight app that uses Windows Communication Foundation (WCF). When running the debugger, the IDE was launching the html file hosting the Silverlight application, but it was launching it in the browser using a file path, F:\Projects\MyLOBApp\Bin\Debug\TestPage.html, not through IIS as http://localhost/MyLOBApp/TestPage.html. The application was using the following code in a global application class to set the URL to the WCF service.
public static string WebServiceUrlPath
{ get {Uri uri = new Uri(Application.Current.Host.Source, "../AppDataService.svc");
return uri.AbsolutePath.ToString(); }
}
My solution consists of two projects:
- The Silverlight application project
- The WCF service project
Upon closer inspection of the file path, Visual Studio was launching the test page from the Silverlight project when it should have been launching the test html page from the WCF project. The simple solution was to set the WCF project as the StartUp Project. That should have been more obvious especially in light of the following message box that popped up before the debugger started, but it was initially overlooked because of the similar project names and html page filenames in the two projects.
photo credit: satemkemet / CC BY-SA 2.0
Friday, April 1, 2011
Javascript Deserialization Error Converting Ajax JSON in ASP.Net Web Service
The .Net framework makes it very easy to do fast lightweight AJAX calls to an ASP.Net web service using jQuery or other frameworks using json (JavaScript Object Notation) and XMLHTTPRequest (MUCH faster and lighter weight than the UpdatePanel).
Because the data in json is delimited by apostrophe’s, having them within the text (as the data itself) can throw a deserializing error when ASP.Net parses the json text body into the web service method parameters. A simple way to prevent is to wrap your javascript variable with the escape() method. It will convert an apostrophe to %u2019. On the server side within your web method before you pass the data to the database, you can wrap it with Server.UrlDecode() to convert it back to an apostrophe.
Javascript jQuery Ajax call
Below is an example of a typical jQuery asynchronous call to a web service. Note the webservice name is AppWebService.asmx. UpdateComments is the web method being called. The UpdateComments web method takes two parameters an integer RecordID and a string RecordComments. Note the use of escape(RecordComments) to encode the RecordComments field in the event that it contains apostrophes (or other special characters).
var options = { type: "POST", url: "/Application/AppWebService.asmx/UpdateComments",data: "{'RecordID':" + RecordID + ", 'RecordComments':'"
+ escape(RecordComments) + "'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (response) {if (response.d == "") {
jQuery('#saving').hide();}
}, //end successerror: function (response) {
alert("Sorry, the update failed. \n\n Details follow: " + response.responseText);
} //end error
};
//Call the Web servicejQuery.ajax(options);
Raw Request Captured in Fiddler
The text below is the contents of the HTTP request that is sent to the web service. In this case the actual data is much smaller than the request header information. You can see how much less data is being sent back to the server for processing compared with a complete page postback or even an ASP.Net AJAX UpdatePanel. The json data itself is:
{'RecordID':10629, 'RecordComments':'cat%u2019s%20meow'}
The RecordComments text is an encoded version of “cat’s meow” (without the quotes).
POST http://domain/Application/AppWebService.asmx/UpdateComments HTTP/1.1
x-requested-with: XMLHttpRequest
Accept-Language: en-us
Referer: http://domain/Application/RecordMaintenance.aspx
Accept: application/json, text/javascript, */*
Content-Type: application/json; charset=utf-8
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0
Host: kestrel
Content-Length: 148
Connection: Keep-Alive
Pragma: no-cache
{'RecordID':10629, 'RecordComments':'cat%u2019s%20meow'}
Web Method accepts json
Behind the scenes ASP.Net parses the json data and uses it to populate the web method parameters. If there was an apostrophe in the json text body as shown below:
{'RecordID':10629, 'RecordComments':'cat's meow'}
ASP.Net would not correctly parse the data correctly, because it would be expecting a closing bracket } immediately after 'cat'. Since we escaped the data, it is parsed correctly using the following web method. Note the use of Server.URLDecode to convert the RecordComment from “cat%u2019s%20meow” back to “cat's meow” before passing it to the helper method as a parameter for a stored procedure.
<WebMethod()> _
<ScriptMethod()> _
Public Function UpdateComments(ByVal RecordID As Integer, ByVal RecordComments As String) As String
Dim result As String = String.Empty
Try CommonSQL.ExecuteNonQuery("sproc_name", _RecordID, _
Server.UrlDecode(RecordComments))
Catch ex As Exception
Return ex.ToStringEnd Try
Return resultEnd Functionphoto credit (wave runner): db2r / cc BY-SA 2.0
Wednesday, March 16, 2011
Lessons Learned in the Windows Phone 7 Marketplace
The following are a few of the things I learned during the development process and submitting a first application to the Windows Phone Market Place. Hopefully they can be of some help to others.
Application Name
If your application name is more than about 15 characters, the whole application name may be truncated on the various WP7 screens. This is also true in the thumbnail view in the Market Place. Note how the text fades to white toward the right side of the name in the screenshot below.
Iconography
Graphic design in the consumer market space is a necessity. Your icons are displayed immediately adjacent to other professional designs - regardless of app quality.
Application Icons
Initially I created a 31px application icon. I think that was the size used during the RC or beta version of Visual Studio Express for Windows Phone 7. The following are the default icon sizes for Windows Phone 7 application certification:
- ApplicationIcon.png 62px (transparency allowed)
- Background.png* 173px (transparent allowed)
* Tip: don’t put the application name in this image (or any important cosmetic detail at the bottom) as the Application title text from the Visual Studio property page will be rendered on top of the 173px icon near the bottom of the image (see the “Start Screen” in the screen shot below).
The following is a composite image containing multiple screen shots:
- Phone Windows menu screen (left)
- Visual Studio project properties, application tab (center)
- Phone Start screen (right)
Note in the image where the text is displayed and which images are used on the various app screens. Click the image for full size.
Market Place Icons
The following square icons (without transparency) are required for display in the Market Place:
- 99px
- 173px
- 200px
WP7 application screen shots can be uploaded to showcase key functionality.
- 480 x 800px screenshots
- vertical orientation for upload
- set zoom level on emulator to 100% for correct screenshot resolution (need a high enough resolution monitor to capture the screenshots. 1024X768 is not good enough)
Marketplace Detailed description
I copied my description from a website where the application is described. I’m not sure I would do that in the future as it did not display properly on the app hub submission page (note the incorrect text wrapping at the end of the lines. There doesn’t appear to be an option to edit the description without re-submitting the application.
I was pleasantly surprised the text looked correct when my application was certified as approved, but I don’t know if the person testing the app corrected the description text formatting during prior to approval/publishing.
Another developer had the misfortune of an unfortunate example using a bullet list format.
Submission and Certification
I submitted my application to the App Hub on a Sunday evening and it was certified by the following Wednesday morning. It was accepted on the first submission, but the feature set (and graphic design) was kept intentionally simple in the first version.
Thursday, March 10, 2011
Windows Phone 7 Testing a Date Change in the Emulator
I wrote a WP7 application that stores a bit of data based on today’s date. Tomorrow when the date changes, yesterday’s data gets cleared out to start fresh. Before submitting the app to the App Hub I needed to test whether it would work as expected when the date changes. At the time, I didn’t have an actual Windows Phone 7 for testing so I used the Emulator. The testing process didn’t work out quite as I expected.
Happy Path
- Load Emulator
- Deploy app to the emulator
- Run app
- Click some buttons that store today’s data
- Change the date on the development box (assuming that is where the emulator gets its current date)
- Click the windows key to unload the app
- Return to app (which should have a different date since I changed the date on the development box)
- The app data should be empty because it is a new day
Fail
There were a few misconception to the above.
- It appears that the emulator loads today’s date when the emulator starts up, because it didn’t change when I changed the date in my development environment.
- When you click the back button it unloads the application and you lose the data stored in Isolated Storage.
Fix
Replace steps 5 & 6 in the above “Happy Path” with the following steps to effectively test the date change: