Scott Hanselman's Computer Zen
The Weekly Source Code 37 - Geolocation/Geotargeting (Reverse IP Address Lookup) in ASP.NET MVC made easy
First, let me remind you that in my new ongoing quest to read source code to be a better developer, Dear Reader, I present to you thirty-seventh in a infinite number of posts of "The Weekly Source Code."
I'm working on a side-project with Rob Conery, Dave Ward and others and I want to be able to do a search immediately as the user arrives on the site, using their location derived from their IP Address. I want to use "Geolocation" or Reverse IP Address Lookup, and take an IP like 127.0.0.1 and turn it into "New York, NY."
There are lots of services and databases that you can buy that will let you make a web service call and get back a location. Some will include latitude and longitude, some include the city name. Some are REALLY expensive, like $500 or more.
I found two solutions, one server-side that's a community project and one client-side from Google!
Community-based Geotargeting from hostip.infoIf you hit http://www.hostip.info/ with your browser, it'll guess where you are and show a map with your estimated location, usually within 50-100 miles. It's a community-based project with a freely available database. They've got over 8.6 million entries in their database!
More interestingly, they have a nice clean API for Geotargeted IP Address Lookup.
For example:
http://api.hostip.info/get_html.php?ip=12.215.42.19&position=true Country: UNITED STATES (US) City: Sugar Grove, IL Latitude: 41.7696 Longitude: -88.4588if you add just call:
http://api.hostip.info/?ip=12.215.42.19You'll get an XML document back with lots of good information.
So, I wrote a quick .NET wrapper for this service. Note the sample XML file in the comment in the middle there. I also put in a default location for debugging. It's not the cleanest code in the world, but LINQ to XML made it easy and it either works or it doesn't.
public class LocationInfo{
public float Latitude { get; set; }
public float Longitude { get; set; }
public string CountryName { get; set; }
public string CountryCode { get; set; }
public string Name { get; set; }
}
public class GeoLocationService
{
public static LocationInfo GetLocationInfo()
{
//TODO: How/where do we refactor this and tidy up the use of Context? This isn't testable.
string ipaddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
LocationInfo v = new LocationInfo();
if (ipaddress != "127.0.0.1")
v = GeoLocationService.GetLocationInfo(ipaddress);
else //debug locally
v = new LocationInfo()
{
Name = "Sugar Grove, IL",
CountryCode = "US",
CountryName = "UNITED STATES",
Latitude = 41.7696F,
Longitude = -88.4588F
};
return v;
}
private static Dictionary<string, LocationInfo> cachedIps = new Dictionary<string, LocationInfo>();
public static LocationInfo GetLocationInfo(string ipParam)
{
LocationInfo result = null;
IPAddress i = System.Net.IPAddress.Parse(ipParam);
string ip = i.ToString();
if (!cachedIps.ContainsKey(ip))
{
string r;
using (var w = new WebClient())
{
r = w.DownloadString(String.Format("http://api.hostip.info/?ip={0}&position=true", ip));
}
/*
string r =
@"<?xml version=""1.0"" encoding=""ISO-8859-1"" ?>
<HostipLookupResultSet version=""1.0.0"" xmlns=""http://www.hostip.info/api"" xmlns:gml=""http://www.opengis.net/gml"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:schemaLocation=""http://www.hostip.info/api/hostip-1.0.0.xsd"">
<gml:description>This is the Hostip Lookup Service</gml:description>
<gml:name>hostip</gml:name>
<gml:boundedBy>
<gml:Null>inapplicable</gml:Null>
</gml:boundedBy>
<gml:featureMember>
<Hostip>
<gml:name>Sugar Grove, IL</gml:name>
<countryName>UNITED STATES</countryName>
<countryAbbrev>US</countryAbbrev>
<!-- Co-ordinates are available as lng,lat -->
<ipLocation>
<gml:PointProperty>
<gml:Point srsName=""http://www.opengis.net/gml/srs/epsg.xml#4326"">
<gml:coordinates>-88.4588,41.7696</gml:coordinates>
</gml:Point>
</gml:PointProperty>
</ipLocation>
</Hostip>
</gml:featureMember>
</HostipLookupResultSet>";
*/
var xmlResponse = XDocument.Parse(r);
var gml = (XNamespace)"http://www.opengis.net/gml";
var ns = (XNamespace)"http://www.hostip.info/api";
try
{
result = (from x in xmlResponse.Descendants(ns + "Hostip")
select new LocationInfo
{
CountryCode = x.Element(ns + "countryAbbrev").Value,
CountryName = x.Element(ns + "countryName").Value,
Latitude = float.Parse(x.Descendants(gml + "coordinates").Single().Value.Split(',')[0]),
Longitude = float.Parse(x.Descendants(gml + "coordinates").Single().Value.Split(',')[1]),
Name = x.Element(gml + "name").Value
}).SingleOrDefault();
}
catch (NullReferenceException)
{
//Looks like we didn't get what we expected.
}
if (result != null)
{
cachedIps.Add(ip, result);
}
}
else
{
result = cachedIps[ip];
}
return result;
}
}
I did put some naive caching in here. I would probably put in some cleanup so the cache could only get so big, maybe a few thousand IPs. Perhaps a FIFO queue, where I start yanking the old stuff after it gets full. Or, use the ASP.NET Cache and just let it manage memory and eject stuff that hasn't been touched in awhile.
This worked great for a while, but at some point, if my site became successful I'd want to send these guys money, or regularly download their free Geolocation database and run the whole thing locally.
Then, while looking at Google's Ajax Libraries API site as a place for my site to download the jQuery libraries rather than me hosting them, I noticed…
Free Geotargeting is built into Google's AJAX Libraries APIGoogle offers a free service called google.load that lets you load your favorite Javascript APIs using Google's Javascript Loader API, rather than hosting them locally. This means that you and your site get a few excellent benefits:
- The files are loaded fast because they are on Google's CDN (Content Distribution Network)
- The files are loaded asynchronously by newer browsers because they aren't stored on your site (most browsers open up to 6 HTTP connections per DNS/site, but older ones do 2.
- This is why back in the 90's we had www.800.com and images.800.com in order to get some parallelizm. It's also recommended by YSlow, although you should balance this knowledge remembering that there's a cost for a DNS lookup. That said, newer browsers like Chrome include their own local DNS cache which mitigates that issue. Moral of the story? Know all this stuff, but know that it'll all be obsolete and moot soon. ;)
- They offer a versioning API, so you can say, "get me version 2 of something" you'll get 2.24 if it's the latest.
What does this have to do with Geotargeting? Well, you know when you get Google.com they know where you are. They'll offer Spanish if you're in Spain. Since they ALREADY know this stuff, they are making in available to your script via google.loader.ClientLocation for free. They announced this in August and I missed it until today!
I'm doing this:
<script src="http://www.google.com/jsapi?key=YOURAPIKEY" type="text/javascript"></script><script>
google.load("jquery", "1.2.6");
google.load("jqueryui", "1.5.2");
var yourLocation = google.loader.ClientLocation.address.city + ", "
+ google.loader.ClientLocation.address.region;
</script>
Note that you need to sign up for a free API KEY for your domain so they can contact you if there's a problem with the script.
Later on, I use the yourLocation JavaScript variable and put it in a Search Box for my app and go searching based on your location. If your location is wrong, I remember if you typed in a different city in the Search Box and I'll use that again, so I only annoy you once.
If that's not enough information, you can use the proper Geolocation API, which is much more sophisticated but requires Google Gears.
Enjoy!
Technorati Tags: Google,ASP.NET,ASP.NET MVC,Geotargeting,Geolocation,jQuery,JavaScript© 2008 Scott Hanselman. All rights reserved.
Hanselminutes Podcast 138 - Paint.NET with Rick Brewster
My one-hundred-and-thirty-eighth podcast is up.
Well, actually a few weeks ago, but I totally forgot to update my website with the details. You'd think somewhere around 100 shows I'd had automated this somehow. Hm. If I only I know a programmer and the data was available in some kind of universal structure syndication format…;)
Scott talks with Paint.NET author Rick Brewster about some of the internals of his popular freeware application. They focus on deployment and setup, how Rick does it and what we can learn from him.
- Download: MP3 Full Show #138
- Play in your browser.
Do also remember the complete archives are always up and they have PDF Transcripts, a little known feature that show up a few weeks after each show.
Telerik is our sponsor for this show!
Building quality software is never easy. It requires skills and imagination. We cannot promise to improve your skills, but when it comes to User Interface, we can provide the building blocks to take your application a step closer to your imagination. Explore the leading UI suites for ASP.NET and Windows Forms. Enjoy the versatility of our new-generation Reporting Tool. Dive into our online community. Visit www.telerik.com.
As I've said before this show comes to you with the audio expertise and stewardship of Carl Franklin. The name comes from Travis Illig, but the goal of the show is simple. Avoid wasting the listener's time. (and make the commute less boring)
Enjoy. Who knows what'll happen in the next show?
Technorati Tags: MSR,Microsoft Research,Podcast,PDC© 2008 Scott Hanselman. All rights reserved.
Hanselminutes Podcast 137 - Microsoft PDC and Windows 7 Reaction Show with Richard Campbell
My one-hundred-and-thirty-seventh podcast is up.
Well, actually a few weeks ago, but I totally forgot to update my website with the details. You'd think somewhere around 100 shows I'd had automated this somehow. Hm. If I only I know a programmer and the data was available in some kind of universal structure syndication format…;)
Scott catches up with Richard Campbell at DevConnections in Las Vegas and they chat about the announcements at the 2008 Microsoft PDC and how/if the new stuff will affect our lives.
- Download: MP3 Full Show #137
- Play in your browser.
Do also remember the complete archives are always up and they have PDF Transcripts, a little known feature that show up a few weeks after each show.
Telerik is our sponsor for this show!
Building quality software is never easy. It requires skills and imagination. We cannot promise to improve your skills, but when it comes to User Interface, we can provide the building blocks to take your application a step closer to your imagination. Explore the leading UI suites for ASP.NET and Windows Forms. Enjoy the versatility of our new-generation Reporting Tool. Dive into our online community. Visit www.telerik.com.
As I've said before this show comes to you with the audio expertise and stewardship of Carl Franklin. The name comes from Travis Illig, but the goal of the show is simple. Avoid wasting the listener's time. (and make the commute less boring)
Enjoy. Who knows what'll happen in the next show?
Technorati Tags: MSR,Microsoft Research,Podcast,PDC© 2008 Scott Hanselman. All rights reserved.
Hanselminutes Podcast 136 - MSR@PDC - Microsoft Research at the Professional Developers Conference
My one-hundred-and-thirty-sixth podcast is up.
Well, actually a few weeks ago, but I totally forgot to update my website with the details. You'd think somewhere around 100 shows I'd had automated this somehow. Hm. If I only I know a programmer and the data was available in some kind of universal structure syndication format…;)
One of the hidden gems this year at the PDC conference was the Microsoft Research section. It was buried in the back of the convention center, unfortunately, so a lot of people didn't know it was there. Scott talks to each team at length and gets the scoop on what project are coming to an IDE near you sometime soon.
- Download: MP3 Full Show #136
- Play in your browser.
Do also remember the complete archives are always up and they have PDF Transcripts, a little known feature that show up a few weeks after each show.
Telerik is our sponsor for this show!
Building quality software is never easy. It requires skills and imagination. We cannot promise to improve your skills, but when it comes to User Interface, we can provide the building blocks to take your application a step closer to your imagination. Explore the leading UI suites for ASP.NET and Windows Forms. Enjoy the versatility of our new-generation Reporting Tool. Dive into our online community. Visit www.telerik.com.
As I've said before this show comes to you with the audio expertise and stewardship of Carl Franklin. The name comes from Travis Illig, but the goal of the show is simple. Avoid wasting the listener's time. (and make the commute less boring)
Enjoy. Who knows what'll happen in the next show?
Technorati Tags: MSR,Microsoft Research,Podcast,PDC© 2008 Scott Hanselman. All rights reserved.
Hanselminutes Podcast 135 - StackOverflow Behind The Music - Unedited Outtakes Show
My one-hundred-and-thirty-fifth podcast is up.
Well, actually a few weeks ago, but I totally forgot to update my website with the details. You'd think somewhere around 100 shows I'd had automated this somehow. Hm. If I only I know a programmer and the data was available in some kind of universal structure syndication format…;)
Here's some raw audio from the last show. We left the recorder on after the show was over, and the discussion continued for another 30 minutes! It's a different conversation in a raw style, but we hope you enjoy it.
- Download: MP3 Full Show #135
- Play in your browser.
Do also remember the complete archives are always up and they have PDF Transcripts, a little known feature that show up a few weeks after each show.
Telerik is our sponsor for this show!
Building quality software is never easy. It requires skills and imagination. We cannot promise to improve your skills, but when it comes to User Interface, we can provide the building blocks to take your application a step closer to your imagination. Explore the leading UI suites for ASP.NET and Windows Forms. Enjoy the versatility of our new-generation Reporting Tool. Dive into our online community. Visit www.telerik.com.
As I've said before this show comes to you with the audio expertise and stewardship of Carl Franklin. The name comes from Travis Illig, but the goal of the show is simple. Avoid wasting the listener's time. (and make the commute less boring)
Enjoy. Who knows what'll happen in the next show?
© 2008 Scott Hanselman. All rights reserved.
Web Platform Installer now supports XP - And the Master Plan continues
Remind me to tell you some time why the IIS team is so evil clever. It' cool to see the first steps of a master plan to make things awesome start to come to fruition.
I've said over and over that IIS7 is rocking sweet and once you start using it, you'll never want to go back. It's all part of the whole /web platform and it's always been ridiculously tedious to install. It's getting WAY easier, all as part of a super-secret master plan I can't tell you about or I'd have to kill you.
Seriously, the Web Platform Installer, or Web-PI, hit Release Candidate last night. The #1 complaint on my last post about this was that it didn't support XP. Bam:
Supported Operating Systems are: Windows Vista RTM, Windows Vista SP1, Windows XP, Windows Server 2003, Windows Server 2008
How ya like me now, son? ;) Also works for Server 2003, so that's cool.
Web-PI's got a number of cool things, but one subtle one you might take note of is the Web Deployment Tool Beta (MSDeploy) that I mentioned before. This tool makes it very easy to package up all the configuration schmutz of your application and (re)deploy it elsewhere. As such, it supports synchronizing your sites and applications across server farms, which was a huge problem for me when I was in banking. It integrates nicely with IIS Manager too.
Also of note is the inclusion of ASP.NET MVC Beta as an option, as well as URL Scan 3.1 and IIS 7.0 manager which lets you manage IIS7 from non-IIS7 machines like, ahem, XP machines. Basically all the things that were hard to find, now, less so.
Now, my first worry when I saw this was, "well, some small team is doing this applet and it's neat and all but soon it will fall into disrepair and fade away, like calc.exe." Well, I just got a personal call from Bill Staples who manages all this stuff and he told me
"oh no, we've got a master plan."
He then proceeded to tell me the master plan and it was good™. I can't tell you, but I'm working on ways to tell you without Bill firing me. Regardless, there's some cool stuff coming in the /web space. It's very tidy, very open, very clean, very sourcey, very appy, very nice.
So, go get the Web Platform Installer and the Web Application Installer and ponder on why there's a "A - F | G - L | M - R | S - T | U - Z" navigation thing on a page that only has 7 products for download.
Web Platform Installer AnnouncementView SlideShare presentation or Upload your own. (tags: microsoft web)
Discuss!
Related Posts
- Web Platform Installer: Trying to make it easier to setup for web development
- Web Application Installer - Open Source Web Apps Delivered and Installed
- Get Started with IIS7
© 2008 Scott Hanselman. All rights reserved.
Do you have to know English to be a Programmer?
An interesting comment thread broke out in a recent post on Using Crowdsourcing for Expanding Localization of Products. Someone linked to a post and used the phrase:
"If you don't know English, you're not a programmer."
The post linked to didn't make the statement so boldly, but it's an interesting "link bait" phrase, isn't it? It's defintely phrased to get your attention and evoke opinions. I don't agree with it, but I wanted to dig more into the concept.
This whole conversation caught the eye of Fabrice Fonck, General Manager (GM) of Developer Content & Internationalization for DevDiv. He wrote this email to me and I wanted to share it with you. He's was a programmer before he became a manager, and English is not his first language, so I thought it fitting. I also added emphasis in spots. Fabrice believes very strongly in the usefulness of translation and translated content and has an entire organization dedicated to it, so you can understand why he'd feel strongly about this.
I began studying computer science and programming in 1985 as a freshman in a business school in France, my native country. At the time , localized versions of programming tools were not available and I will always remember when I picked up that version of GW-Basic only to realize that it was all in English. Learning programming seemed already daunting, but doing it in a foreign language only increased my level of fear. Over 20 years have gone by and English does not feel quite as foreign to me anymore, but I cannot help but think that for billions of people around the world, taking on such a double challenge may not necessarily lead to the same outcome.
Over the past 17 years in the Developer Division at Microsoft, I have devoted a large portion of my time and energy making sure our products and technologies are available in as many languages as possible because I believe it is important to make them accessible to as many people as possible around the world. During all these years, I have had the privilege of traveling to many countries around the world and I have talked to many of our customers, a number of which through interpreters. I have met many brilliant developers out there whose English language skills were limited if not practically non-existent. This anecdotal evidence is supported by our sales figures. In Japan for instance, where we have one of our largest developer population in the world, over 99% of our product sales are in Japanese. Entering that market with an English-only product is a recipe for failure. That same is true in counties such as France, Germany, Spain, Russia or China where our localized products represent over 80% of our sales. The list of countries goes on and on.
While it is true that a number of people overseas for whom English is not their native tongue will eventually learn and benefit from the vast amounts of technical content available in English, a greater number will not. That is why we continue to expand the number of languages in which Developer Division products and technologies are localized into. Cost is obviously an important factor here, especially for smaller geographies. That is why we continue to invest in technologies such as machine translation, translation wikis and CLIP, and concepts such as crowdsourcing and community engagement to drive down costs and make these languages a reality for the millions of developers out there (and aspiring developers) that do not speak English. By making our products available in all these languages, we also foster more community engagement in these languages, through blogs, forums, chat rooms, etc.
Here's some choice comments from the previous post:
Erling Paulsen: "Most articles, knowledge bases, books and so on are in English, so if you want to read up on something in depth, you need to have at least basic reading skills in English. Translating tooltips inside Visual Studio could end up causing confusion for at least new developers, as what they would see on-screen potentially did not match up with what the tutorial/book they were following." and "...I truly do appreciate that Microsoft is trying to make an effort, and I believe that MSDN has had a vast improvement in usability the past year or so. And the fact that MSFT are allowing community contribution is absolutely fantastic, but at least to me, the translation effort just seems a bit unnecessary." and "I never said, or meant to say that you need to be fluent in english to be a good programmer. And as Scott points out, the side-by-side translation feature would actually be a great way for learning english."
Paul van de Loo: "Developers might as well get used to learning new languages (even if they aren't programming languages)."
Spence: ""A programmer who doesn't at least understand English is not a programmer" that's an outrageous statement. That's like saying "a musician who is deaf is not a musician" patently untrue and ridiculous. plus pretty offensive to millions of programmers."
Ramiro: "I believe that in an ideal world every programmer should speak and read enough English to be able to work, learn and interact. However (and specially in Latin America) this is still a long term goal. I really applaud the effort being put in by Microsoft and other companies to make resources more available for everyone."
Robert Höglund: "I do think we developers need a common language. When you have a problem, get a strange exception, 9/10 just googling the error message will get you the answer. I have tried developing on a Swedish version of XP but trying to search for those error messages doesn't work. Can't say i agree with the statement "If you don't know English, you're not a programmer" but it does make life easier."
Farhaneh: "I can not speak and write english very well , but i'm taking classes and reading english books in my major to make it better. because i want to be a good programmer."
Filini: "The english syntax that has been used in programming languages for the last 50 years."
John Peek: "To say that if you don't know English, you're not a programmer is a perfect example of ethnocentrism in this country."
What do YOU think? Is learning English the #1 thing a Programmer should do (after learning to type)? Can you be an awesome programmer and speak little or NO English?
The comment that *I* personally agree with the most is from Ryan:
"It would *seem* (totally non-scientific sampling) that the non-english speakers (as a first language anyway) tend to agree with the statement "If you don't know English, you're not a programmer" more than native english speakers."
What do YOU think, Dear Reader?
© 2008 Scott Hanselman. All rights reserved.
Xbox 360 NXE - Forget Games, The Xbox is a Media Center
What's all this talk about gaming on the Xbox 360? I can't remember the last time I actually played a game on the thing, but I can say that both The Wife and I use it daily. I'd even say she uses the Xbox 360 more than I do.
She plays music from the Zune and iPod, she runs photo slideshows for the boys and when we have company.
Recently we had a party for my Dad and the Xbox was showing slideshows of him over the years with his favorite music running in the background. My wife and I didn't think anything of it (it seems pretty obvious to us) but oddly enough it was the hit of the party. A half-dozen people were literally freaking out. The Xbox can do that?
Why You Should Buy an Xbox 360 Even If You Don't Play GamesHere's my list. What's yours?
- You can just plug in any MP3 player or Digital Camera that uses USB connectors and immediately view photos and play music.
- I've had company come over a number of times with a camera or an SD card, and I've just attached them to the Xbox and we've watched their slides. Just use a USB adapter for camera cards or plug the camera USB connector into the Xbox directly. The same works with Zunes or iPods.
- You can stream movies from Netflix (some in HD)
- This is new and pure hotness. I've been beta testing the New Xbox Experience (NXE) and I don't miss the old Xbox at all. I cancelled by Blockbuster account 6 months ago in anticipation of this. There's about 12,000 movies and 300 in HD. I just happed to watch "Outsourced" (recommended) and it was in HD. The Wife digs it, and we can easily catch up on TV. I hope that someone gets Hulu.com in there and then I could die happy.
- You can easily stream video and music from your Windows (or Mac) machine to your Xbox.
- You can use any uPNP streaming software like Twonky, or just use Windows Media Player. Click the down arrow on "Library" and click "Media Sharing." It's even easier in Windows 7. Just click the Windows button and type "Share." You can share throughout your network, or on a device by device basis.
- We have a Zune Pass which basically lets you "lease" music for $14.99 a month. Basically for the price of 1 CD a month we can listen to all the music we like on our two Xboxes and two Zunes. The music streams from my main machine that runs the Zune software.
- The Xbox360 can console H.264 and MPEG4 video files, but the device you're streaming FROM needs a codec, like 3ivx. I discovered that the Flip video camera that I bought includes the 3ivx codec. I connected to my Windows Home Server and installed the Flip Software by connecting the Flip to the Windows Home Server (WHS). That got me a free 3ivx codec, and now I can easily stream those files to my Xbox. Bam. (Totally unsupported, remember, I don't work for ANY of those teams.)
- You can use Connect360 to stream content from your Mac to your Xbox360.
- The Xbox 360 is a Windows Media Center Extender.
- You can basically remote into your Windows machine and watch TV if you have a tuner card, watch saved shows and movies, and browse the web (with a Media Center add-on app). It looks and acts just as if you're running Media Center on your PC.
We use the Xbox in this way so often that we have two, one old Xbox 360 bought early on and an Xbox Elite with HDMI bought more recently. Both of them seamlessly upgraded to the final NXE this morning.
I won't even try to review the NXE, but suffice to say, it's awesome. Check out the Joystiq videos and reviews of the Xbox NXE for great details.
Buying a Xbox 360Here's a screenshot of the very awesome and complete Xbox 360 SKU chart from Joystiq, trimmed to remove discontinued models.
If you're looking for balance, the Pro is the best deal. It's $300, has decent storage and supports HiDef via RGB Component Cables. If you want HDMI, you'll need the Elite, but you'll double your hard drive space. (Update: It USED to be the case that the Elite had HDMI but now all Xboxes have at least the port, although the Elite comes with a cable also.) You can use that space to store movies, videos, photos, etc, but really it's only useful for storing games or ripping CDs.
OK, I'm off to NOT play games on my Xbox.
Technorati Tags: Xbox360,Xbox,NXE,Zune,Review,Games,Gaming© 2008 Scott Hanselman. All rights reserved.
Update on the GDR that is coming for .NET Framework 3.5 SP1
As I've you've probably heard, we are working on an update for .NET3.5 SP1 and its 2.0/3.0 sub-components which will contain fixes for the small number of bugs reported by customers since the release of 3.5 SP1 this summer. More information regarding the specific bug fixes included in the update will be provided in a knowledge base article that will be released with this update, although at the end of September I blogged about this upcoming "GDR" (General Distribution Release) update to .NET 3.5 SP1 and listed the bugs I've been able to confirm so far as being fixed.
In that post I said:
"Later this year, probably November-ish, the .NET Framework 3.5 SP1 will begin show up on Windows Update in a rolling and throttled fashion so that all machines that have .NET 2.0 or higher will be automatically upgraded to 3.5 SP1."
Turns out I was wrong on this, and the update will be available for download from the web in November, and will be up on Windows Update in January. There's a number of reasons for this but the primary one is that customers in general prefer not having any updates during the holidays (IT staff that needs to handle enterprise wide deployments are on vacation, etc) there is no non-security “refresh” for the fourth Tuesday in December, so the next earliest possible release date for our .NET Framework update on WU (Windows Update) is going to be early in into the next year (tentatively a Tuesday in January). As you might suspect the potential audience for such updates on Windows Update (WU) is very large (the vast majority of 1 billion windows PCs worldwide) so we err on the side of caution.
Once testing is complete and we’re ready to release the update, the release schedule needs to snap to a predetermined release cadence for updates shipping on WU. In general Microsoft releases security updates on the second Tuesday of every month and non-security updates such as this one on the fourth Tuesday of every month. We release on a cadence because large enterprise customers need a predictable schedule for all updates so they can in turn plan their own enterprise wide deployments for updates once we release this.
The extended testing process and release cadence takes time but the processes are designed to ensure we provide a broad and diverse set of customers with a high quality update combined with a smooth deployment experience.
Once this is released to Windows Update, you'll be much more likely to find 3.5 SP1 installed on the majority of the 1 billion or so Windows PC worldwide. It'll be nice to have a common baseline for developers to target. Remember also that WU is automatic and unattended, so the .NET Framework 3.5 SP1 will just show up on machines one day (of course Enterprises have additional controls over deployment). All this should make it easier for us developers to figure out which framework to target.
I hope this post gives you some more information and context on what's going on with this update. It takes a while to dig all this up and bring it to you, so I hope it provides you some value. Spread the word.
© 2008 Scott Hanselman. All rights reserved.
Using Crowdsourcing for Expanding Localization of Products
Not everyone in the world speaks English. Such a silly thing to say, but if you live in an English-speaking country it's easy to forget that many (most?) people in the world would prefer to do their work in the language of their choice.
Microsoft ships documentation in Visual Studio that is human-translated (a huge effort) into 9 major world languages. That's millions and millions of words * 9 languages. How can we cover more languages? How can we make documentation easier for folks who are trying to learn about our products and don't speak English fluently? How can we make English interfaces easier to use for non-English speakers who want to learn English?
Last month, I spoke to members of the internationalization/globalization team in DevDiv (Developer Division) about some of the little-known stuff they are doing. I think deserves more attention as there's some pretty innovative things being done. Some are experimental, but there's hope to expand them if they succeed.
MSDN uses Machine Translation and Crowdsourcing for DocumentationDoing a lot of work with a few people is hard. Doing a lot of work with a lot of people is confusing and expensive. However, doing a little bit of work with a LOT of interested people can be useful, cheap and fun if you "crowd-source" rather than outsource. Check out the screenshot below or visit the Brazilian MSDN site and check out the Translation Wiki v2.
You'll see there's the English MSDN documentation on the left, and Brazilian Portuguese on the right.
Make sure to select "side-by-side" or "Lado a Lado." If you hover over a sentence on the Portuguese side, a small Edit button will appear.
Click Edit, and you can suggest a better translation, and they'll go into a queue for community moderators to approve. Notice also that under "Other Suggestions" you'll see existing suggested translations that are in the queue for moderation.
The initial Portuguese text comes from the Machine Translation team. For some reason, Portuguese is the best language that the Machine Translation team understands.
The text on the site is roughly 80% MT (Machine Translated) and 20% humans via these technique, and growing. There's a goal to include more languages for the next version of Visual Studio, including possibly Arabic, Czech, Polish and Turkish, although things are still a little up in the air.
If you know a Brazilian developer, spread the word about this project and encourage them to make edits to the Brazilian MSDN site and check out the Translation Wiki v2.
Big thanks to our community partners: a group of 30 CS students, partly from the team of Prof. Hirata and Prof. Forster of Instituto Tecnologico de Aeronautica and the team of Prof. Simone Barbosa from Pontifícia Universidade Católica who post-edited 1.8 million words of MT'ed content; the Brazilian Terminologist who managed the glossary project with our MVPs; and finally the Academic Evangelist Team in DPE in Brazil who gave us their support throughout the project.
It'll be interesting to see how far this project goes and what other languages can benefit from it.
Captions Language Interface Pack (CLIP) - includes 9 more partial language translations for Visual StudioHere's a description of the CLIP from a launching page:
"The Microsoft Captions Language Interface Pack (CLIP) is a simple language translation solution that uses tooltip captions to display results. Use CLIP as a language aid, to see translations in your own dialect, update results in your own native tongue or use it as a learning tool."
This is pretty clever. It's a background application that will show balloon tooltip help in your language while you work in the English version of Visual Studio. For example, in the screenshot below, I'm hovering my mouse over Start Debugging, and the Arabic CLIP pops up with a human translation of that menu item.
It'll even help with other applications within Windows if it thinks it's got a decent translation, but for now, it is focused on correct translation for common Visual Studio options.
Even better, you can add translations of your own. In future versions, there's talk about setting up sharing (I figure you can hack it today, though, unsupported, by sharing the language database.
Visual Studio CLIP is available in these languages so far, all created with community and student help!
- Arabic (المنطقة العربية)
- with students from King Fahd University of Petroleum and Minerals (KFUPM), managed by Prof. Abdullah Al-Zamel
- Czech (Česká republika)
- with students from VŠB-TU Ostrava managed by Eng. Jan Martinovič
- Hebrew (ישראל)
- with students from the Computer Department of the College Of Management managed by by Prof. Samuel Itzikowitz
- Hindi (हिन्दी) and Tamil (தமிழ்)
- with a team from the Central Institute of Indian Languages
- Malayalam (മലയാളം)
- in cooperation with a team from the Central Institute of Indian Languages
- Oriya (ଓଡ଼ିଆ)
- with students from Ravenshaw University in India, managed by Prof. Mishra
- Polish (Polska)
- with students from Wroclaw University managed by Prof. Zbigniew Fryžlewicz
- Turkish (Türkiye)
- with students from Hacettepe Üniversitesi lead by Prof. Ercin Töreci
In addition to the CLIP, there's also the ability to do a Language Pack for the Visual Studio interface itself, as exemplified by the Brazilian Visual Studio Express Language Pack for SP1 that does about a 70% translation of VS into Portuguese. There's talk to do more of these also. That should make Carlos Quintero happy!
There's a lot of cool possibilities for all this technology, expanding MSDN and VS to as many languages as possible!
If you think this kind of thinking is pretty cool, leave a comment or blog about it and maybe we'll be heard by *ahem* the boss when he next (soon) reviews plans for this kind of community involvement. ;)
© 2008 Scott Hanselman. All rights reserved.
Fixed: "Windows Process Activation Service (WAS) is stopping because it encountered an error."
I'm not yet clear what I did, but I'm blogging it so it can be found if someone else has this issue.
For whatever reason, last week both of my Vista 64-bit machines suddenly stopped being able to start IIS (Internet Information Server). The service just wouldn't start. I started getting this error instead "Cannot start service W3SVC on Computer '.'" which wasn't too helpful.
A visit to the System Event Log via the Event Viewer in Computer Management told me these four errors:
"The World Wide Web Publishing Service service depends on the Windows Process Activation Service service which failed to start because of the following error: The system cannot find the file specified."
and
"The Windows Process Activation Service service terminated with the following error:
The system cannot find the file specified."
and
"Windows Process Activation Service (WAS) is stopping because it encountered an error. The data field contains the error number."
and
"The directory specified for the temporary application pool config files is either missing or is not accessible by the Windows Process Activation Service. Please specify an existing directory and/or ensure that it has proper access flags. The data field contains the error number."
Unfortunately there's little information to go on in any of these error messages. However, it's clear (as mud) from the last error that there's a directory missing or not accessible. I'll add "anymore" to that because it worked before. That means that something changed.
If IIS won't start because Windows Process Activation Service won't start, then I need to get WAS started up first. However, I don't know what directory it doesn't have access to.
I can see from the Services application that WAS isn't its own executable, but rather lives inside of an instance of svchost.exe, where a lot of services live.
So I'll fire up Process Monitor and set the filters (filters are VERY important if you want to avoid being overwhelmed quickly in procmon) to show only svchost.exe processes.
Even still, there's a lot of svchost.exe processes out there and they will quickly fill the monitor up. I'll need to setup some strategic (read: guessed) highlighting as well.
The hotkey to stop capturing in procmon.exe is Ctrl-E. Basically I'll clear the screen, hit Ctrl-E to capture, try to start WAS (pronounced WAAZ), watch it fail, the stop capture with Ctrl-E.
Based on the vague message about application pools temporary files and a directory I'll make a guess and configure highlighting to find paths that contain "temp," "log," "config" or "app" in Process Monitor as seen in the screenshot below.
After I run the capture, I scroll around looking for suspicious stuff. One of the nice things about Process Monitor is that you can EXCLUDE things in a given capture after that fact. For example, I saw a pile of Audio and Media related stuff that was visually confusing and cluttering the point, so I excluded it.
The result is here:
It looks like there SHOULD be a folder call c:\inetpub\temp\apppools and on my Vista 64 machines, in the last two weeks to a month, it just disappeared. No idea why. I just noticed recently when I tried to move from a local web development service to IIS itself.
I created the folder, started WAS, then IIS and I was back up and running.
I'll pass the feedback on to the WAS team about the obscure error messages, but I thought I'd share this little ten minute debugging session to point out a few things that I think are important and possibly helpful, Dear Reader:
- Know What Your Processes Are Doing (or at least, know how to find out)
- Knowing how to look INSIDE the Windows "Black Box" using tools like ProcMon makes you realize that no OS is a Black Box at all. It's very empowering to know that you CAN see inside.
- TASK: Learn Process Monitor and Process Explorer.
- Enable Your Intuition
- Debugging is 95% tools and 5% intuition. Know what tools can get you that next bit of information you need to take the next step in your analysis.
- If you feel you've hit a wall in your analysis, knock that wall down. Your process is doing IO to a file/registry/device/network/etc. Watch it. Look for failures.
My next mission is to find out WHY and HOW this directory disappeared on both my machines. What did I install or run recently? Enjoy!c
© 2008 Scott Hanselman. All rights reserved.
Viewing a LOT of Images Effectively (plus 700 Obama Newspaper Covers in Silverlight Deep Zoom )
digg_url = 'http://digg.com/politics/730_Obama_Newspapers_from_66_Countries_DeepZoom_Collection'; I don't talk politics as a rule on this blog. However, regardless of your political affiliation, the last week has generated a lot of news. When I saw these 730 Newspaper images from 66 countries at the Newseum, Scott Stanfield and I immediately said Silverlight Deep Zoom!
There's a number of good ways to view LOTS of images at a time. I'll share the ones I use. First, here's our Silverlight DeepZoom Obama News page.
Scroll…zoom…
Scroll…zoom…
Cool. I had to manage these files and check them out before we made the Silverlight DeepZoom version, so I tried these programs:
Windows ExplorerSo, the story is, the Newseum assembled 730 newspaper front pages from all over. I downloaded them with DownThemAll and put them in a folder in Explorer. I run 64-bit Windows Vista and didn't have to much trouble with Windows Explorer with only ~700 images. I could use the View Thumbnails feature and zoom in and out and it worked pretty good.
Windows Photo Gallery (the Default Preview)If you double click on an image in Windows, you'll get the Windows Photo Gallery by default, which just shows the image. You can then navigate around the folder with the left and right keys. It works pretty well, although the previewer fills the screen completely and starts up maximized which I find kind of irritating. Also, there's no way to see previews of the images that are coming up next. The thumbnail view is gone.
Windows Live Photo GalleryThis is a big improvement on the default one. It's a much more polished version of the default one. The most dramatic feature addition is face recognition. If you click on an image, it'll find people:
If you click on "people found," the system will highlight the face that you can then identify, and more importantly, search on.
Picasa 3 from GooglePicasa 3 is pretty much on par with Windows Live Photo Gallery. They are both fast, they both have some face recognition, although WLPG is much more granular while Picass just has a "show me photos with faces" option.
Where Picas really shines is with its replacement of the default image previewer. If you let it take over as your default image viewer, when you double click on a file you'll get a nice animation, a gray curtain that falls over your desktop, but more importantly a "FilmStrip" of all the files. This little touch lets you much more easily navigate while still previewing files.
Expression Media 2A commenter suggested I add Expression Media 2 as the whole point of Expression Media is to catalog butt-loads of media assets. It shouldn't blink at 700 images…and it didn't.
It's very bare bones from a Consumer point of view, as it's not meant for organizing the family photos. However, it's power is hidden in its keyboard shortcuts. It's obscenely fast. Truly. Everything moves at the speed of thought, and you can batch rename, tag, change, your photos.
It also notably has a ridiculous number of sorting options, like dozens. You can sort by height, width, author or whatever metadata you like. Definitely something I'd return to if I had several thousands images.
Silverlight DeepZoomFirst I tried using DeepZoom Composer, which is a free tool for making DeepZoom collections really easily. We figured we'd drag these 700+ files into DeepZoom and bam! We're done. Well, DeepZoom Composer currently can't handle single collections with THAT many images. This isn't a limitation of DeepZoom, it appears, but the editor which hit 2 gigs of RAM and died. Additionally, with that many files, it's easier to just position the images programmatically. I talked to the PM for the product and they're already on it. However, I can still use the DeepZoom tools programmatically. It's not DeepZoom Composer that does ALL the work, in fact. There's a "SparseImageTool.exe" that we can call programmatically.
Giorgio Sardo has a blog post about this (latest version here), and I was able to use his code directly to make a local DeepZoom collection. Here's a snippet of his code with my changes. It's rough, but it's a one off, so be forgiving:
static void Main(string[] args){
// Collection name
string collectionName = "ObamaZoom";
// Folder containing images to be processed
string sourceImagesFolder = @"C:\\Users\\Scott\\Desktop\\Obama\\";
// Destination folder of the batch process
string outputFolder = "D:\\DeepZoomObamaNews\\";
// Eventually create the output directory
if (!Directory.Exists(outputFolder))
Directory.CreateDirectory(outputFolder);
CreateCollection(collectionName, sourceImagesFolder, outputFolder);
}
/// <summary>
/// Create a Test collection using automation
/// </summary>
static void CreateCollection(string collectionName, string sourceImagesFolder, string outputFolder)
{
// Create a collection converter
CollectionConverter collectionConverter = new CollectionConverter();
// Required parameters
collectionConverter.SparseImageToolPath = GetSparseImageToolPath();
collectionConverter.ImagesCollection = GetImages(sourceImagesFolder); // IEnumerable<string> containing the path of the images
collectionConverter.ImagesDestinationFolder = outputFolder;
// Optional parameters
collectionConverter.CollectionName = collectionName;
collectionConverter.CollectionFormat = CollectionConverter.CollectionFormats.XML;
//collectionConverter.ConvertedOverlapPixels = ...
//collectionConverter.ConvertedTileSize = ...
//TODO: You can customize the exporting experience here, by setting the according parameters such as:
// Tile Size, File Format, Collection Format, Compression, Quality, ...
// Attach to completion handler
collectionConverter.BatchCompleted += delegate
{
Console.WriteLine("Conversion completed\nPRESS <ENTER> TO EXIT");
};
try
{
collectionConverter.BatchCollectionExport();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
Console.WriteLine("Conversion started...");
Console.ReadLine();
}
This code takes the input folder and creates an output folder with the DeepZoom processed files you need. ScottS then said he thought the result would look better if it looks more like the HardRock Cafe Memorabilia site, so we used Vertigo Software's "BigPicture" application (it's internal for now, but he's looking into what to do with it. Contact him if you want more details.) which easily handles all the dynamic positioning of the images in their collections.
The result is pretty cool. Even cooler if you press the Full Screen button (fourth from the left):
I think it'd be interesting if this technology wasn't just used as an occasional showcase when an event happens, but as a regular everyday thing. I wonder if it would be hard/cool/interesting/compelling to read a regular newspaper like this? Or of PDF files supported this kind of view? For me, the fun is just the buttery smoothness of the zooming. The frame-rate is crazy fast. Enjoy.
Thank Scott Stanfield and Vertigo Software for hosting it!
© 2008 Scott Hanselman. All rights reserved.
ASP.NET and jQuery
It looks like many of you have already noticed that there's an official Visual Studio autocomplete file for jQuery posted up at the jQuery site. It's significant that it's hosted by the jQuery team in that it's a contribution by the Visual Studio team but it's not up at CodePlex, because it really belongs to jQuery so there's where you'll find it.
This isn't a new jQuery file and nothing's been "forked" so don't freak out. It's just a documentation file, as you can see if you go to the Download jQuery page.
- 1.2.6 (Release Notes)
- Minified, Packed, Uncompressed
- Documentation: Visual Studio
Now, the Visual Studio-specific aspect of this is a temporary thing, as it's planned for Visual Studio to support a more standard syntax at some future date, but until then, there's this file and we'll make sure it's kept updated.
Jeff King has details on how to use this file in your projects. In the VERY near future there will be a hotfix that will cause Visual Studio to look for files that end in "-vsdoc.js" for intellisense which will make including it in your project automatic.
UPDATE: The very near future is NOW. You can now download a small hotfix that causes Visual Studio to automatically look for intellisense files named *-vsdoc.js" next to the runtime file. From Jeff King's blog:
Last week I mentioned we would be releasing a Hotfix to accompany our new jQuery VSDoc file. This Hotfix is now available at the MSDN Code Gallery. Here's a direct download link for this small (2MB) patch:
http://code.msdn.microsoft.com/KB958502/Release/ProjectReleases.aspx?ReleaseId=1736
I want to emphasize that this patch is intended for all JavaScript files, not just those related to jQuery. Generally, we will opportunistically look for documentation files related to the script file. For example, given "mylibrary.js", we will search in the same directory for:
- mylibrary-vsdoc.js, then if we don't find it we will search for...
- mylibrary.debug.js, then if we don't find it we will search for...
- mylibrary.js
There's a few things that are nice about this jQuery file is that it supports and understands jQuery plug-ins. If you're into jQuery and ASP.NET, go check it out.
Related Links
- Stephen Walther's ASP.NET and jQuery presentation at PDC
- jQuery IntelliSense documentation file available
- Rich IntelliSense for jQuery
- jQuery to ship with ASP.NET MVC and Visual Studio
© 2008 Scott Hanselman. All rights reserved.
The Weekly Source Code 36 - PDC, BabySmash and Silverlight Charting
First, let me remind you that in my new ongoing quest to read source code to be a better developer, Dear Reader, I present to you thirty-fifth in a infinite number of posts of "The Weekly Source Code."
At the end of my crazy babies talk at PDC (Tips on how I prepared here) I had a big demo where I gave a URL to a Silverlight version of BabySmash that Grant and I built for the show. You can watch the presentation online if you like and fast forward to the end (around 60 minutes in) and see the big demo. Basically we had the Silverlight BabySmash talk via ADO.NET Data Services (I'll post in detail in the near future) to a SQL backend. Then I had an MVC reporting site that had some charts that would update as folks smashed. There were over 90,000 smashes during the talk.
The chart was updating as folks were smashing and we even had a Baby vs. Baby fight break out where the "A" people and the "J" people were going at it. Jeff Atwood started the bloodbath with this tweet as he urged on the overflow room along with Phil Haack. That man's trouble, I tell you.
In the talk, I started out with a old .NET 1.1 chart from 2003 and showed it working, unchanged, in ASP.NET 3.5 SP1. It's just a nice reminder that things usually work just as they should. Then I upgraded it to a new .NET 4.0 ASP.NET Chart that I'll blog about in detail soon. Then, I showed the final site with the new Silverlight Charts. Tim Heuer has a great post on how to databind with these new charts.
What's really cool about these Silverlight Charts is that they are Ms-PL (Microsoft Public License) which is a REALLY relaxed license. They're released as part of the larger Silverlight Toolkit up at http://www.codeplex.com/Silverlight. There's a bunch of controls in there. It is a preview release though, so things will change, and hopefully only get better:
- Components in the Preview Quality Band
- Components in the Stable Quality Band
You can check out the Toolkit Chart samples and run them yourself here. It's nice that the chart sampler actually includes the source code within the Silverlight sample app. You can browse dozens of charts, then switch tabs and see the XAML and code-behind. This all lives in Microsoft.Windows.Controls.DataVisualization, the namespace (so far) for these controls.
My reporting page included a Silverlight Chart and a Virtual Earth control to show where people were smashing from. The data is coming from the Astoria ADO.NET Data Service, which is easy to get to via either JavaScript or from Silverlight.
You add the charts to your Silverlight application by adding a reference to the assembly then assigning a namespace to them:
xmlns:charting="clr-namespace:Microsoft.Windows.Controls.DataVisualization.Charting;assembly=Microsoft.Windows.Controls.DataVisualization"
xmlns:datavis="clr-namespace:Microsoft.Windows.Controls.DataVisualization;assembly=Microsoft.Windows.Controls.DataVisualization"
Them, lay them out. I've got two charts here, one column and one pie. I also did some stuff like the linear gradient for the background, etc. Still, pretty simple.
<charting:Chart Grid.Column="0" Height="300" StylePalette="{StaticResource PaletteColors}" Style="{StaticResource ChartStyle1}" ><charting:Chart.Background>
<LinearGradientBrush EndPoint="1.332,1.361" StartPoint="-0.107,-0.129">
<GradientStop Color="#FF6CA9D5"/>
<GradientStop Color="#FFFFFFFF" Offset="1"/>
</LinearGradientBrush>
</charting:Chart.Background>
<charting:Chart.Axes>
<charting:Axis x:Name="colAxis" Orientation="Vertical" AxisType="Linear" Minimum="0" Maximum="1"></charting:Axis>
</charting:Chart.Axes>
<charting:Chart.Series>
<charting:ColumnSeries x:Name="colSeries" ItemsSource="{StaticResource BasicValues}" DependentValueBinding="{Binding Count}" IndependentValueBinding="{Binding Character}" Title="Character">
</charting:ColumnSeries>
</charting:Chart.Series>
</charting:Chart>
<charting:Chart Style="{StaticResource ChartStyle1}" Grid.Column="1" Height="300" StylePalette="{StaticResource PaletteColors}" >
<charting:Chart.Axes>
<charting:Axis Orientation="Vertical" AxisType="Linear" Maximum="100000"></charting:Axis>
</charting:Chart.Axes>
<charting:Chart.Series>
<charting:PieSeries x:Name="pieSeries" ItemsSource="{StaticResource BasicValues}" DependentValueBinding="{Binding Count}" IndependentValueBinding="{Binding Character}" Title="Character">
</charting:PieSeries>
</charting:Chart.Series>
</charting:Chart>
We had a generic list of "CharacterSmash" data, as in List<CharacterSmash> that we'd be binding to the chart.
private readonly List<CharacterSmash> characterData = new List<CharacterSmash>();For the purposes of the presentation, I just polled for the data by making an asynchronous call to the service, then updating the bar and pie chart when it returned:
private void RequestSmashCountData(){
var container = new SmashMetricsContainer(new Uri("/BabySmashPDC/SmashService.svc", UriKind.Relative));
// Setup data query
var query = container.SmashCount;
// Start the async query
query.BeginExecute((asyncResult =>
{
// Get the matching results from the service call
var matches = query.EndExecute(asyncResult);
UpdateCharacterData(matches);
UpdateBarChart();
UpdatePieChart();
}), null);
}
See how the BeginExecute includes the "do this when you return" as a lambda? It's a tidy syntax.
UPDATE: Tim Heuer emailed me to say that we're re-databinding the results. Instead, he wisely points out:
"On the code where you are getting the smash metrics for the silverlight charts…I see that you are re-binding the data?
If you bind to an observablecollection and just change that the chart s







