Category Archives: Tech

Top 10 Snarky Apple Predictions for 2010

Well, it’s a new year, a new decade (according to some), and that means it’s time for the pointless predictions about what’s going to happen this year! Being a cranky Apple fan as I am, I present my list of Apple predictions for 2010.

  1. Apple will reveal a new award-winning ad campaign…Microsoft will copy it and embarrass themselves.
  2. Phil Schiller will have more face-time during keynote presentations than we want him to.
  3. Apple will reveal at least one new product that no one is expecting and that changes the world
  4. Apple will reveal at least one new product that no one is expecting and that confuses everyone and is quietly ignored or removed before the year is over.
  5. Apple will update various product lines in ways that make them harder to mod. The Mac Moders will mod them anyway.
  6. The Wall Street analysts will be wrong about Apple sales estimates and earnings.
  7. Apple will wait until a lawsuit hits class action status to issue a product recall.
  8. Kevin Rose will make press with an Apple rumor, and we’ll find out later that he was completely wrong.
  9. Apple will charge iPod Touch owners money for something iPhone owners get for free and claim that ‘the accountants made us do it’.
  10. Steve-Jobs will non-ironically use the term “greenest” in a keynote.

Come to think of it, I can probably recycle this same exact list next year as well :)


Getting Firefox to zero out the margins…like for realz this time.

This problem can hit anyone working with Firefox, but especially ASP.NET developers. The old-school html way of making sure that you don’t have an ugly space on the top or sides of your page was to specify zeros in the body tag like so:

<body leftmargin=”0″ topmargin=”0″ marginwidth=”0″ marginheight=”0″>

The problem is that all four of those are not valid in XHTML 1.0 Trasitional, and if you are using Visual Studio you will most likely get warnings or errors because if it.

The proper way to do this is using CSS, like so:

BODY {margin:0px; padding: 0px;}

The problem that I had was that this worked fine in IE, but still had the margins in Firefox! Grrr. After googleing and bashing my head on the desk for a while, I finally came up with the answer. Most browsers set some default css values for certain elements if none is specified in your code. Even though I had set the body to have zero padding and zero margins, there was still an element that was getting a default margin by Firefox. It turned out to be the FORM tag. If you create a new aspx page with Visual Studio, it will automatically put a form tag as the first thing inside the body of the page. You also have to set the margins here to get rid of that space, and fortunately that is very simple once you know what the problem is. Just add one more line to your css. Both of them together will look like this:

BODY {margin:0px; padding: 0px;}
BODY FORM {margin:0px; padding: 0px;}

Poof! The annoying space goes away. This same issue can crop up if anytime a margin hasn’t been set for whatever element is at the top of your page, a <p> tag, an <h1>, <h2> or <h3>, or pretty much anything else as well.


Keyboard Shortcut for Visual Studio 2005

This is a stupid little thing that I should have figured out a long time ago, but I am VERY excited about it!

I love keyboard shortcuts. I especially love being able to do things without using the mouse. Today I discovered that in Visual Studio 2005 (this might work in other versions too, I haven’t tried it) there is a great keyboard shortcut that lets you switch between the files you have open for edit. To use it just hold down Ctrl and press Tab. It pulls up a little box in the middle of the screen that is simmilar to what you see when you use Alt+Tab, but instead of a list of open programs it has two columns, one with a list of the files you have open for edit, and one with a list of available windows such as your toolbox or the Solution Explorer.

This also works in Firefox for Windows. Enjoy!


How to bounce (restart) IIS

When I first started using IIS, the only way that I knew how to restart it was going to the services control panel, finding the IIS admin service and restarting it that way. That method was annoying on a number of levels, one of which is that for whatever reason, it takes for ever. That might be because it also restarts the ftp and smtp services if you have those running.

There are two other methods that I use on a regular basis.

1) From the command line. Just open a cmd window and type in IISreset (and like normal, that’s not case sensitive. Doing it that way takes a noticably shorter amount of time than from the command line. You can also do IISreset /stop or IISreset /start. I use that if there is something I’m doing that I need IIS off for.

2) From the IIS management snap in. Anyone who works with IIS a lot will probably already be familiar with this tool, but a lot of people don’t realize that you can also use it to restart IIS. When can find a shortcut to the Internet Information Services Management snap-in in the administrator tools folder. In the tree view on the left, the top node is called Internet Information Services. Right under that should be the node representing your local computer (or whatever computer you have connected to). Right click on that, go to All Tasks, and then click on Reset IIS. It’s that easy!


Commerce Server 2007 Catalog Import Breaks Inventory

I have noticed this annoying problem with the Commerce Server 2007 Catalog Manager tool. I have to admit that I haven’t done a lot of research on this topic, so I don’t know what the root cause is, or what fixes there might be available.

We have a staging area that the business folks use to massage data before getting released to production. To get our dev area in sync with stage we can use the Commerce Server Catalog Manager to export the product catalog from our staging server, which creates an xml file, and then use that to import the more up to date catalog on our dev box.

The problem is that when we do the import to the dev box the inventory catalog gets corrupted. I get arround this annoyance by doing a backup export of the dev inventory catalog first, then importing the stage product catalog, and then importing the inventory catalog back again to fix the corruption.

If anyone knows how to fix this little annoyance, please email me.


Apple iPhone to use GPS?

During Steve Job’s Macworld Keynote speach today, a new ipod iphone device was accounced. Part of the demo included integrated use of Google Maps to connect you with local retail stores. The phone seemes to know where you are, so does this mean integrated GPS? If so, this could be the ultimate Geochaching device. I’m hoping they expose an api for the GPS so that I can start developing geocaching widgets for it.

[EDIT]: Sadly, it turns out this is not the case. No GPS for the iPhone. In fact, there is question now weather or not we will be able to write custom widgets of any kind for it! That would majorly suck.


ASP:Menu control broken in Safari Browser in ASP 2.0

I recently built a shiny new web site using ASP.NET 2.0 and thought it was all finished until I looked at the home page in the Safari browser from an Apple Mac computer. The site uses the new asp:menu control and it looked horrid in Safari. There were actually bare html tags showing up on the top of the page!

At first I thought it had to either be my code or the data populating the menu that wasn’t compatible with Safari, but when I viewed the source of the page from within Safari I noticed that the html was totally different than the code that IE was getting. I knew that it wasn’t my code doing any kind of browser detection, so that meant that ASP.NET was dynamically generating incompatible code at run time. There was a lot more to the asp:menu control than I thought.

It turns out the asp:menu control is designed to be able to gracefully handle older browsers for you and do things like detect if the browser can’t support JavaScript and if so it will only generate html menus. So, that means that ASP.NET incorrectly thinks that Safari can’t handle the dynamic menus and is sending it downgraded code that renders like crap.

To fix this you are going to have to get your admin hat on because you need to edit some files in your %system% directory. Your web.config and machine.config files have sections called “Browser Caps” that define for it what browsers can do what. Starting with ASP.NET 2.0 the settings are also contained within files with the .browser extension that you can find at:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\Browsers

The browser caps sections are still supported for backward compatibility. The sections that affect the display of the asp:menu control for Safari are found in the mozilla.browser file in that directory. When looking through there I was confused at first because everything seemed to have sensible settings, but I finally found the culprit. Underneath this section:

<browser id=”Safari” parentID=”Gecko”>

You will find this little guy:

<controlAdapters>
    <adapter controlType=”System.Web.UI.WebControls.Menu” adapterType=”System.Web.UI.WebControls.Adapters.MenuAdapter” />
</controlAdapters>

Apparently the ASP.NET 2.0 menu control has a system of “adapters” that do the generation of the back-versioned code. I’m sure you can access and modify those adapters or create your own, but I haven’t bothered to research how to do it because I knew that the menu worked fine in Firefox and should be working fine in Safari, so I just removed the controlAdapter section from the Safari browser section of the config file. This will cause the behavior to be inherited from the parent, which in this case is Gecko which happens to be the same parent that Firefox inherits from in that file.

After removing that section there is one last step. Unlike the web.config, ASP.NET will not automatically read the changes to the .browser files and change the behavior of your web site. I tried bouncing IIS, as well as rebooting before doing a bit more research and finding out that there is an ASP utility called Aspnet_regbrowsers.exe that you need to run that will take those .browser files and compile them into a dll called ASP.BrowserCapsFactory.dll that gets placed in the same directory as the .browser files. The information also gets placed in the global assembly cache so you don’t have to bounce IIS in order to get the changes to take affect after running the tool. To compile the files issue the following command from a command prompt:

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regbrowsers.exe -i

If you take another look in the Browsers folder you will see the addition of three files. BrowserCapsFactory.cs, ASP.BrowserCapsFactory.dll, and browserCaps.token. If you now try your page again in Safari you should see better results. Or at least I did.

This problem is a classic example of the hidden costs associated with developing with Microsoft software, and also a perfect example of the advantages of an open source community model. This whole system was designed by Microsoft so that developers could keep up with the mobile market that is rapidly changing and becoming increasingly online. At first they were going to keep the .browser files up to date but eventually didn’t want to keep up with all the changes so they just dropped it. The .browser files are sitting dormant, and if you are just now making the switch to ASP 2.0 from 1.1, the settings for Safari (and probably a lot of the other ones) are out of date before you even install the software. If this was an open source project, the community would be keeping them up to date. As soon as a new device or browser hit the market, the developers that had to code for it would be submitting the correct browser definition file for it.

Here is an official Microsoft statement about this:

Q: Why will Microsoft not provide device specific updates?

A: Our original plan was to provide regular updates, however, based on the evolution of the market we needed to change our approach in order to better address the rapid proliferation of different kinds of devices around the world…If customers would like assistance with building support we can put them in touch with 3rd party companies who specialize in mobile development with ASP.NET, or with Microsoft PSS.

Or in other words, do it yourself or pay someone else to do it. I bet your CTO didn’t cover that in his budget proposal!


TFS says I have files checked out, but there is nothing in my Pending Changes screen!

This is a “feature” of TFS that has bugged me a number of times, and it is much easier to avoid when you know you should be looking for it.

TFS uses a combination of your user name AND your computer name to track the status of files (pending changes, check-outs, etc). So here’s how this bit me. One day my development box died. Some kind of gnome ate my hard drive. Not a big deal right? That’s why the network has roaming profiles, and all of our current development work is stored in SQL thanks to TFS. I got a new box and eventually got logged back into TFS to continue working.

When I looked at my “Pending Changes” screen there was nothing listed. I thought that was odd because I knew I had some files checked out. I took a look in the source control explorer and saw that the files that I had been working on were STILL checked out by me, but they didn’t show in the pending changes screen. Odd. So I tried to check them out to work on them, and it wouldn’t let me! On my old box I had checked them out exclusively, and even though it showed my user name as having them checked out, it still didn’t let me get them. Grrr.

The only way I have found to solve this issue is to either log back in to the box that you had checked them out originally (obviously not an option in my case), or have the TFS admin delete the files. The admin tried to undo the checkout but it wouldn’t let them to that either. Deleting them worked however. Sigh. Fortunately TFS keeps the change history for deleted files too, so the code wasn’t lost.


TFS says the paths are “more than the allowed 260 characters”

For the unaware, TFS (Team Foundation Server) is Microsoft’s latest enterprise source control software. I’ve been on it since beta, and it’s still got some bugs and quirks, but it’s shaping up to be a great solution. It is build on a SQL server backend instead of access files, and will eventually replace Source Safe.

Shortly after I started using it I had this annoying little problem when trying to get latest on a folder full of code (Ironicly it was code provided to us by Microsoft, an SDK for software we were testing). It said to me that the paths are “more than the allowed 260 characters”. This can happen if your workspace is set up deep within a file structure which makes for a long path. The limitation is actually one with Windows, not with TFS, and there isn’t much you can do other than shortening up your path. Try changing your workspace to a simpler path.

In the Source Control Explorer, click on the “Workspace” dropdown and choose “Workspaces…”. In the “Manage Workspaces” window highlight the proper workspace and click “Edit”. In the “Edit Workspace ” window, in the “Working folders” panel, if the “Local Folder” looks something like this:C:\Documents and Settings\username\My Documents\Visual Studio 2005\Projects, Change it to be something like C:\code.

If that doesn’t fix the problem then you will need to edit the files in source control in order to shorten file names or simplify the file hierarchy. Perhaps this hard limit will be improved with Windows Vista.


Using SelfSSL to create your own SSL certificates for IIS 6

If you are developing a web site using ASP.NET or any other language being served by IIS, you will not be able to serve HTTPS pages unless you have an SSL certificate installed. Most companies pay good money to get certificates from places like Verisign or Thawte for their live production boxes, but for your development boxes which are safely tucked behind the corporate firewall it would be silly to pay the money for a full blown certificate. If you are a developer living under the tyranny that is Sarbanes-Oxley then you probably don’t have the option of just exporting the cert from your production box and importing a copy of it on your dev box, and if there are portions of your site such as the “my account” page that require a secure connection then you might find yourself unable to do your work without a certificate.

Some certificate vendors try to meet this need by selling “development” certificates for a lower price but if you are using IIS 6 you can generate your own certificates for this kind of situation using a little tool called SelfSSL from Microsoft.

SelfSSL is part of the Microsoft Internet Information Services (IIS) 6.0 Resource Kit which can be downloaded here.

To create a certificate, download and install the resource kit, making sure that SelfSSL was included in the list of items being installed. Once the installation is complete you can access SelfSSL by clicking on Start > Programs > IIS Resources > SelfSSL, and then click SelfSSL.

This will open a command prompt window. To see a list of command line options type SelfSSL /? and to install a certificate in the default web site type “Selfssl /T /V:365″, and then press ENTER. The /T option will add the certificate to your machine’s trusted certificates pool (which is a good idea), and the /V:365 is what specifies the length of time that the certificate will be valid. I don’t know if there is an upper limit to how long the cert can be valid, but I’ve tried it as high as 700 days and it still worked fine.

I said above that this method will install the cert in the default web site. It is more accurate to say that this will install the cert in the web site that has a Site ID number of 1. Before dealing with this utility I had never heard of any kind of Site ID before, and this gave me a lot of trouble. It turns out that this is a unique number that IIS uses behind the scenes to tell the different web sites apart. The number is assigned when you create the site and does not change. The default web site that comes pre-made with IIS has a Site ID of 1, but if you have deleted it, even if you create another one with the same name, it will not have the same ID.

That is exactly what happened to me. I had deleted the default site, and when I ran the SelfSSL tool using the command I gave above, it failed and said “Error opening site metabase key: 0×80070003″. After a while of pulling my hair out and finding nothing useful on Google, I figured out that the default site number of 1 didn’t exist anymore. I had five sites installed, so I tried using the /S switch to specify the site number and didn’t have any luck at all. I tried /S:2, /S:3, all the way up to twenty something and still couldn’t get it to work. I hunted all over the IIS manager tool and could not find anywhere that showed what the ID numbers were.

The answer, ironically, came from a utility contained within that same IIS resource kit that you have just installed! One of the other utilities is one called the IIS Metabase Explorer, and all the info is contained in there. Open it up and expand the LM node, then expand the W3SVC node, and you will see a list of the site IDs. In my case the ID was 1,169,018,952. It would have taken me quite a while to guess that one, huh? Once you know the ID you can go back to SelfSSL and use the /S switch to generate the cert for the correct site.

The IIS Metabase Explorer is actually a nifty little utility that I might eventually cover in another post.