Wednesday, October 21, 2009

404 errors on IIS6 with ASP.NET 4.0 Beta 2

After installing Visual Studio 2010 and .NET framework 4 on Windows Server 2003 (IIS6) I was getting nothing but 404 errors.  Turns out .NET 4 had somehow been disabled in the IIS metabase.

Here's the comment I posted to server fault:

Check the metabase.xml file ... is there a '1' at the start of the line for Framework\V4.0.21006 in WebSvcExtRestrictionList?

I had the same problem and setting it to '1' (enabled) cured the problem. ASP.NET 4.0 Beta 1 did not have this problem. The problem only appeared on install of ASP.NET 4.0 Beta 2.

Here's what it looked like BEFORE fixing the problem:

        WebSvcExtRestrictionList="0,C:\SERVER\system32\inetsrv\httpodbc.dll,0,HTTPODBC,Internet Data Connector
                0,C:\Perl\bin\perlis.dll,1,,Perl ISAPI Extension
                0,C:\SERVER\system32\inetsrv\httpext.dll,0,WEBDAV,WebDAV
                0,C:\Perl\bin\PerlEx30.dll,1,,PerlEx ISAPI Extension
                0,C:\Perl\bin\perl.exe "%s" %s,1,,Perl CGI Extension
                1,C:\SERVER\system32\inetsrv\asp.dll,0,ASP,Active Server Pages
                1,C:\SERVER\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,0,ASP.NET v2.0.50727,ASP.NET v2.0.50727
                0,*.exe
                0,*.dll
                0,C:\SERVER\system32\inetsrv\ssinc.dll,0,SSINC,Server Side Includes
                0,C:\SERVER\Microsoft.NET\Framework\v4.0.21006\aspnet_isapi.dll,0,ASP.NET v4.0.21006,ASP.NET v4.0.21006"


And here's an easier way to change that setting:

http://neilkilbride.blogspot.com/2008/02/windows-2003-iis-returns-404-for-aspnet.html

Mixed mode assembly errors after upgrade to .NET 4.0 Beta 2

I began receiving this error after upgrading to .NET Beta 2 ...

System.IO.FileLoadException: Mixed mode assembly is built against version 'v1.1.4322' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

I suspect it's the Managed.DirectX DLL that I'm using.

Adding the following to the application config file appears to have solved the problem for now:-

<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
  </startup>
</configuration>

Thursday, October 15, 2009

Balloon Boy was much ado about nothing - Twitter

So the whole #balloonboy thing turned out to be a non-event today. The traffic on Twitter around this must have been huge. Here's a few of the more witty comments:-

saymayday UPDATE: kid flying away in a balloon is fake!! It's all fake!!!

candidgyal Black Hawk sent to rescue little boy in helium balloon. Someone will be lowered to attach to the balloon and rescue boy.

QuinnK Major anxiety about this balloon boy situation, and the number of people on Twitter that can't spell ballon baloon balon BALLOON!

boxwood17 Hey, 6-year-old in the hot air balloon, I'mma let you finish, but John Denver had the best crash landing of all time.

ProgGrrl RT @HitFixDaniel I've temporarily switched from CNN to Fox News, because I'm curious how Balloon Boy is Obama's fault.

pasquinade My other car is a helium balloon with a 6-year-old child inside. (Too soon?) #bleakbumperstickers

SpigotTheBear ***BREAKING NEWS*** A SECOND KID IN A SECOND BALLOON HAS JUST CRASHED INTO THE WORLD TRADE CENTER

azbubba RT @tdhurst: The balloon kid would be a lot cooler if he was live tweeting this.

ebonymystique this balloon boy is gonna be the most popular kid in school tomorrow. wait...why wasnt he at school TODAY?

jennknitsalot i'm ok with #boyinballoon crashing twitter as long as the balloon doesn't crash

michelleyus Is it me, or does this balloon thing seem like it shouldn't be that hard? I saw Executive Decision. Mid-air solutions CAN be devised.

kella_bella when i was 6, i wanted to fly away in a hot air balloon.

drewdavies @gregeh The balloon "expert" on CNN pointed out that if the boy isn't separated from the helium chamber, he's not going to have any oxygen.

zamoose 6 year-old boy floating away in helium balloon on CNN. Anchors refuse to address lack of Federal funding for airborne Lassie research.

TiricoSuave "Well, it's obviously landed." - Stan Hess, CNN's experimental balloon expert.

Neomic RT (via @justrod); If we couldnt find #balloonboy in his own house what makes ya think we ever gonna find Osama

bootypirate Just ordered a weather balloon kit from the back of Parents Magzine. #fb #balloonboy

OntieC #balloonboy story just so much hot air.

@EthanSuplee Has America run out of wells to fake falling down?

tsand: http://twitpic.com/loa1c - Working on prototypes of our #balloonboy Halloween costumes.

Yarhoza Yo Balloon Boy was probably in Narnia while all this was all going on. #balloonboy #balloonboy #balloonboy #balloonboy #balloonboy

reverendnathan Ballon Boy's favorite song? "I believe I can fly" by R. Kelly. He thinks about it every night and day. #balloonboy

jaimebradley #balloonboy if you name a child after a bird, he's going to want to fly

Saturday, October 10, 2009

Shortened URLs should be treated like a Codec ...

Codecs are used to compress data to send over the wire, but when it gets to the other end it is decoded back to its original form for display.

Shortened URLs are used to compress long URLs to send over Twitter.

So why aren't they expanded again on the other side? Why do Twitter clients show short urls instead of expanding them back out to a long URL, or at least a display that tells you what the real web site is.

This has implications for reducing attacks hidden in short URLs and for allowing you to see at a glance that "Check out http://bit.ly/a567as" is actually the same site you've already read once today from another Tweet.

So for my own Twitter client I decided to expand all shortened URLs as far as I could go. Here's a code snippet to do that:-

        /// 
        /// Follow any redirects to get back to the original URL
        /// TODO: Move this to Utility
        /// 
        private string UrlLengthen(string url)
        {
            string newurl = url;

            bool redirecting = true;

            while (redirecting)
            {

                try
                {
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(newurl);
                    request.AllowAutoRedirect = false;
                    request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 4.0.20506)";
                    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                    if ((int)response.StatusCode == 301 || (int)response.StatusCode == 302)
                    {
                        string uriString = response.Headers["Location"];
                        //Log.Debug("Redirecting " + newurl + " to " + uriString + " because " + response.StatusCode);
                        newurl = uriString;
                        // and keep going
                    }
                    else
                    {
                        //Log.Debug("Not redirecting " + url + " because " + response.StatusCode);
                        redirecting = false;
                    }
                }
                catch (Exception ex)
                {
                    ex.Data.Add("url", newurl);
                    //Exceptions.ExceptionRecord.ReportCritical(ex);
                    redirecting = false;
                }
            }
            return newurl;
        }

The EntityContainer name could not be determined

If you encounter this error, make sure your constructor is calling the base constructor for an ObjectContext and passing the EntityContainer name.

System.ArgumentException: The EntityContainer name could not be determined. The
provided EntitySet name must be qualified by the EntityContainer name, such as
'EntityContainerName.EntitySetName', or the DefaultContainerName property must
be set for the ObjectContext.

Tagging File Systems

Adam James has an interesting post on his blog about file systems based on tagging: http://blogs.msdn.com/alexj/archive/2009/10/10/tagging-file-systems.aspx

I think it's a great idea, Windows UI today is bound far too closely to the physical disks in our machines and the logical directory structure on top of that. Moving to an abstraction where the physical and logical location matters less and content can be found using tags is a better idea.

I've done some experiments on a similar concept for my multi-channel music player where everything is handled using tags: tags for artist, album, genre (obviously) but also free form tags for playlists, songs to play only at certain seasons, ... It works really well.

Friday, October 09, 2009

A great site for developing and testing RegEx expressions

Came across this one today and found it very handy for checking some complex regex expressions I was developing: http://www.gskinner.com/RegExr/

Thursday, September 17, 2009

WMPnetwk.exe started using 50% of my CPU

I'm not even using Windows Media Player on Windows 7 and I certainly haven't turned on any network sharing features so why is this service using up so much CPU?

Now disabled thanks to advice on the CNet forums here.

Some witty comments there too like "3. Uninstall Windows Media Player 11...I mean if after 11 versions it still doesn't work right then its probably not gonna is it!"

Thursday, August 27, 2009

Introducing Jigsaw menus

I'm writing this blog post because I couldn't find any other reference to what I believe to be a new form of web site navigation, one that I've been developing for http://www.signswift.com.

Traditionally web sites normally have menus and maybe a breadcrumb bar. The menu shows you where you can go and the breadcrumb bar shows you where you have been. Breadcrumb bars haven't tested that well in usability studies and many sites don't bother with them because they also take up precious vertical screen space. My thought was - why not combine these two into a single consistent navigation system? Why not give the user some clear way to see where they have been and where they can go from here? Why not use colors and shapes to show them how each click will change where they are in the site hierarchy? And thus the Jigsaw menu was born.

But before explaining it in more detail you need to understand that this isn't for every site. It works best with smaller web sites. If you really do need to give your users every single option at every point in the site then you need a normal menu. If on the other hand you are trying to simplify things down to show just a few choices for ways to go forward and a way to go back then I think this new navigation scheme may help.

Here's what a Jigsaw menu looks like:


On the left you can see we are at 'home' and from here we can go to 'projects', 'images', 'displays' or 'account'. It's clear that when you click projects it will add onto home and that will be your new location. It's clear, but more subtle until you've used it, that when you go to 'projects' there will be further options but when you go to 'account' that's a dead end.

Here's another example, viewing a single image and there's an 'upload' option. By its shape and color you can see that clicking this will replace 'image' with 'upload'.



And one last example:


Here you can see we are looking at a single project, we have the slides below and we have options for 'play', 'download', 'RSS', 'settings' or 'delete'.

Conclusion
So far this new menu system appears to be working well. Our users report that it is easy to learn and easy to get around. Nobody has complained yet that 'I can't get there from here' even though we are in effect forcing them up the hierarchy and back down a different branch if they want to get there. Clearly it's not going to work for some vast complicated site but if you are building a simple site, you are welcome to try it and let me know what you think.

Thursday, July 23, 2009

Entity Framework in .NET 4.0

I recently tried the latest release of .NET 4.0 to see what improvements have been made to the Entity Framework. Overall it's good news BUT I'm disappointed to see that things that worked in Linq-To-Sql still don't work in Linq-To-Entities. For example, simple DateTime manipulation like checking the DayOfWeek doesn't work.

In Linq-To-Sql you could use an expression like this:

var dayOfWeekCondition = (dt => dt.DayOfWeek == dayOfWeek);

But in Linq-To-Entities you have to use this expression:

int dow = (int)dayOfWeek + 1; // SQL Day of week
var dayOfWeekCondition = (dt => SqlFunctions.DatePart("weekday", dt) == dow);

AND by doing that you have now bound your expression to working only with SQL Server. If you want an expression that works with CLR types you'll need to build that separately.

If anyone builds the code to automatically convert an Expression tree to SqlFunction calls from regular C# expressions do let me know!