Paulo Morgado

.NET Development & Architecture

This Blog

Syndication

Search

Tags

News

Unit Test Today! Get Typemock Isolator!

Projects

Books

 

Visitors

Visitor Locations

Community

Email Notifications

Archives

Profile

Disclaimer

The opinions and viewpoints expressed in this site are mine and do not necessarily reflect those of Microsoft, my employer or any community that I belong to. Any code or opinions are offered as is. Products or services mentioned are purchased by me, made available to me by my employer or the manufacturer/vendor which doesn't influence my opinion in any way.

March 2009 - Posts

MSDN Code Search Preview

(Just read about this on CoDe Magazine)

Microsoft launched MSDN Code Search Preview.

The MSDN Code Search Preview lets you search for code in the MSDN Library, MSDN Code Gallery, and CodePlex.

You can read all about it on the about page or this post from the MSDN & TechNet Search Blog.

Posted Tue, Mar 31 2009 0:38 by Paulo Morgado | with no comments

Filed under: ,

redgate .NET Reflector 5.1.5.0 Released

Today redgate released version 5.1.5.0 of .NET Reflector.

It was a bumpy release. Early today, at work, as soon as @antsprofiler was announced the deployment of the new version I tried to upgrade and was offered an upgrade to the version 5.1.4.0 over and over again.

Early tonight, at home, when I tried to upgrade I was offered to upgrade to 5.1.5.0.

The funny thing is that, if I try to run it from C:\Program Files I get a UAC dialog the mentions Reflector 5.1.3.

Just moved to my C:\Program Files (Utils) and it all works fine.

Posted Mon, Mar 30 2009 23:47 by Paulo Morgado | with no comments

Filed under: , ,

Adobe Reader Fails To Upgrade/Install

Yesterday I was offered an update to Adobe Reader (the latest version for Windows Vista is version 9.1) on my company’s laptop.

I accepted the update but it failed. It was late and a failed update to Adobe Reader was the least of my worries at the time.

Today, when I tried to use Adobe Reader, I noticed it had been uninstalled.

It’s not nice having to download and install something like Adobe Reader when I need to open a document, but the worst came when I tried to install it.

Adobe Reader requires elevated privileges to install but, due to the way the installer works, being a local administrator (I running Vista x64 Enterprise joined to a corporate domain) is not enough to install Adobe Reader on C:\Program Files (x86), because it was still failing.

I had already created C:\Program Files (Utils), to install the Windows Sysinternals tools (in particular, Process Explorer) and did the same for Adobe Reader.

Do you know what was the first name I thought of for this folder? C:\Program Files (Bad)

Just blame it on Vista.

Posted Mon, Mar 30 2009 23:41 by Paulo Morgado | 2 comment(s)

MIX09 Session Presentation Slides

On a previous post I introduced the feeds I created to subscribe to Mix09 session videos.

I’ve decided to also create a feed for the presentation slides:

Posted Thu, Mar 26 2009 2:51 by Paulo Morgado | with no comments

Filed under: , , , , ,

MIX09 Session Videos – How I Did It

On my last post I introduced the feeds I created to subscribe to Mix09 session videos.

In case someone is interested on how I did it, here it is:

<%@ WebHandler Language="C#" Class="mix09" %>

using System;
using System.IO;
using System.Web;
using System.Linq;
using System.Xml.Linq;
using System.Net;
using System.Xml;

public class mix09 : IHttpHandler, IHttpAsyncHandler
{
    class WebClientOpenReadAsyncResult : IAsyncResult
    {
        private AsyncCallback callback;

        public WebClientOpenReadAsyncResult()
        {
            this.IsCompleted = true;
            this.CompletedSynchronously = true;
        }

        public WebClientOpenReadAsyncResult(AsyncCallback callback)
        {
            this.callback = callback;
            this.IsCompleted = false;
            this.CompletedSynchronously = false;
        }

        public object AsyncState
        {
            get { return null; }
        }

        public bool CompletedSynchronously { get; private set; }

        public System.Threading.WaitHandle AsyncWaitHandle
        {
            get { throw new InvalidOperationException("ASP.NET should not use this property ."); }
        }

        public bool IsCompleted { get; private set; }

        public Stream Stream { get; private set; }

        public void Completed(object sender, OpenReadCompletedEventArgs e)
        {
            this.IsCompleted = true;
            this.Stream = e.Result;
            if (this.callback != null)
            {
                this.callback(this);
            }
        }

    }

    private static Uri mixSessionsUri = new Uri("http://sessions.visitmix.com/RSS");

    private HttpContext context;

    private string type;

    #region IHttpHandler Members

    public bool IsReusable
    {
        get { return true; }
    }

    public void ProcessRequest(HttpContext context)
    {
        WebClient wc = InitializeRequest(context);

        if (wc == null)
        {
            return;
        }

        OutputFeed(wc.OpenRead(mixSessionsUri));
    }

    #endregion

    #region IHttpAsyncHandler Members

    public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData)
    {
        WebClient wc = InitializeRequest(context);

        if (wc == null)
        {
            return new WebClientOpenReadAsyncResult();
        }

        WebClientOpenReadAsyncResult ar = new WebClientOpenReadAsyncResult(cb);

        wc.OpenReadCompleted += ar.Completed;

        wc.OpenReadAsync(mixSessionsUri, extraData);

        return ar;
    }

    public void EndProcessRequest(IAsyncResult result)
    {
        Stream stream = (result as WebClientOpenReadAsyncResult).Stream;

        if (stream != null)
        {
            OutputFeed(stream);
        }
    }

    #endregion

    private WebClient InitializeRequest(HttpContext context)
    {
        this.context = context;
        this.type = context.Request.QueryString["type"];

        if (string.IsNullOrEmpty(this.type))
        {
            return null;
        }

        WebClient wc = new WebClient();
        wc.Headers[HttpRequestHeader.UserAgent] = "Required User Agent";
        return wc;
    }

    private void OutputFeed(Stream source)
    {
        XmlReader feedReader = XmlReader.Create(source);

        XDocument feed = XDocument.Load(feedReader);

        var rss = feed.Element("rss");
        var channel = rss.Element("channel");
        var title = channel.Element("title");

        title.Value = string.Format("{0} ({1})", title.Value, this.type.ToUpper());
        channel.Element("link").Value = "http://cli.gs/Mix09Sessions";

        foreach (var item in channel.Elements("item"))
        {
            string link = item.Element("link").Value;
            string session = link.Substring(link.LastIndexOf('/') + 1).ToLower();
            string enclosureUrl = string.Format("http://mschannel9.vo.msecnd.net/o9/mix/09/{0}/{1}.wmv", this.type.ToLower(), session);

            item.Add(
                new XElement("enclosure",
                    new XAttribute("url", enclosureUrl)));
        }

        this.context.Response.Write(feed.ToString());

        this.context.Response.ContentType = "application/rss+xml";

        HttpCachePolicy cache = this.context.Response.Cache;
        cache.SetCacheability(HttpCacheability.ServerAndPrivate);
        cache.SetExpires(DateTime.Now.AddHours(1));
        cache.VaryByParams["type"] = true;
        cache.SetValidUntilExpires(true);
    }
}

Posted Mon, Mar 23 2009 2:04 by Paulo Morgado | with no comments

MIX09 Session Videos

Updated (2009Mar25): Added MP4 feed. 

Mix09 is over and I would like to watch some sessions.

I like to watch these kind of videos by subscribing them using the Zune Software as a podcast. I like the Zune Software because it downloads the “episodes” and I can watch them in any order and it never forgets where I was – even if I was watching it in the Zune.

Unfortunately, the only feed available (http://sessions.visitmix.com/RSS) does not include the videos.

Fortunately, the address of the videos is very predictable and I was able to build my own feeds:

The session videos are not available in all formats for every session (at least, not now) but, if you subscribe to all, you’ll get videos for all the sessions.

Subscribe and enjoy.

Posted Mon, Mar 23 2009 1:06 by Paulo Morgado | with no comments

ASP.NET Futures: Control ClientID Generation

ASP.NET is expected to have some improvements on the generation of client IDs.

Although this is a major improvement, it comes short by not allowing the generation of shorter client IDs for server controls.

My good friend Nuno Gomes has done some work on generating shorter client IDs for controls (*).

Jeff has taken it one step further with his How to shorten ASP.NET automatically generated control IDs article on CodeProject.

If you want to see a running example, check out http://www.biocompare.com/.

Posted Wed, Mar 18 2009 2:44 by Paulo Morgado | with no comments

Filed under: , , , , ,