Archives

Archives / 2005 / October
  • [link] Connection String generation Visual Studio macro

    Speaking of useful macros, this is one I've used for a a few years and thought might be usefull.  It calls the ADODB Data Link Properties dialog (shown below).  After you go through the dialog picking your data source, database, and connection settings, it dumps out the connection string for your configuration into code window where your cursor is located.

    Public Sub ConnectionStringWizard() < /SPAN >

    Read more...

  • [wish] Microsoft P2P download system

    Visual Studio 2005, .NET Framework 2.0, and SQL Server 2005 release to MSDN today, and so of course MSDN downloads got hit pretty hard this morning. After a shaky start, the download speeds appear to be picking up.

    Still, it seems like a lot of wasted bandwidth on Microsoft's part. 2.8GB x 100,000 = some huge number. It would be great if they had a P2P download system so that popular downloads required less bandwidth from Microsoft's datacenters, not more.

    Unfortunately right now, if you talk about P2P download systems like BitTorrent, people figure you're either (1) a high volume pirate, or (2) an open source zealot. The point is, though, that P2P download systems just make good sense from a technical point of view, both for the distributor and the consumer.

    I'd like to see a professional alternative to BitTorrent proposed by Microsoft. It should support security, policy, DRM, etc. - it should be like WMA is to MP3. Waiting too long on something like this will make BT the de facto standard. I'd like to see MSDN ISO downloads use something like BT - you could elect to download direct from server, or could get better speed if you elect to use "cooperative download". Now, granted, file distribution doesn't necessarily have to include the DRM if you're handling security at the file level - product keys, media licenses, etc. However, if DRM isn't built into a system from the start it's very tough to add it in later (digital music is an example there).

    Maybe Avalanche from MS Research will will fill this void. There was some buzz about it back in the April - June timeframe, and a short article in InfoWorld. No word about it since then, though (see "Whatever happened to Microsoft Avalanche?" on Channel9).

    Read more...

  • [tool] MozBackup - copy your Firefox profiles

    I'm setting up a new dev computer and used MozBackup to migrate all my Firefox extensions. It goes better than that - it also supports copying the extension settings, saved passwords, history, and a bunch of other stuff[1]. It was kind of spooky when I restored it on my new computer and (since I'm using the SessionSaver extension) seeing all my tabs restored exactly like the old computer.

    [1] It also supports Thunderbird, but I don't use that.

    Read more...

  • GMail: "oops...the system was unable to perform your operation"

    I've been using GMail as my primary e-mail for the past month, and it's worked pretty well. Searching e-mail is nice, the tagging features are helpful (for instance, I added a tag for a client which automatically includes every e-mail which contains contains their domain name), and it integrates well with the Google personalized desktop.

    However...

    Last week I wasn't able to access my e-mail for most of an afternoon. I kept getting a Javascript popup that said:

    "oops...the system was unable to perform your operation"

    I checked with friends via chat, and they were able to get their GMail just fine - it was just my account. I tried other browsers, cleared cookies, even tried other computers; same message. Searches revealed others who'd had the same problem, but no solutions which worked for me.

    This was a problem, since my e-mail contained conference call numbers, important project information, etc.

    GMail does provide a POP interface, so I'll probably run an e-mail client to keep a local e-mail copy in case this happens again. I'm posting this in case someone has come up with a solution to this problem and to recommend an offline e-mail backup (which is just good sense, anyways, in case the internet connection goes down).

    Read more...

  • The hidden feature in Media Center 2005 UR2

    MCE 2005 Update Rollup 2 includes support for DVD changers. "But", you say, "I don't own a DVD changer." Yeah, me neither. What's cool is that you can very easily use this feature on DVD image files stored on your hard drive.

    Read more...

  • Yet another command line parsing system

    First Mike has linked to a command line parser library for .NET called Param.NET. Then Roy proposeda better command line parsing class which is attribute based. So, now's the time to mention a command line parameter class that worked well for me recently.

    I used another arguments parser from Code Project, "C#/.NET Command Line Arguments Parser ". I like it because it works like the ASP.NET querystring parser - it handles the parsing (quoted strings, different delimiter styles) and exposes a string dictionary with the results.

    I use a GetSettings accessor that reads the default from the app.config file, but allows overrides via command line. I like this approach because settings are their standard location (app.config), and any config setting can be overriden via command line without an attribute change and a recompile.

    [STAThread]
    private static int Main(string[] args)
    {
        Processor processor1 = 
    new Processor(args);
        
    return processor1.Process();
    }
    private Arguments arguments;

    public Processor(string[] args)
    {
        
    this.arguments = new Arguments(args);
    }

    public Process()
    {
        Console.WriteLine(
    this.GetSetting("PreventEvil"));
    }

    private string GetSetting(string key)
    {
        
    string setting = string.Empty;
        
    if (this.arguments[key] != null)
        {
            setting = 
    this.arguments[key];
        }
        
    else
        
    {
            setting = ConfigurationSettings.AppSettings.Get(key);
        }
        
    if (setting == null)
        {
            
    return string.Empty;
        }
        
    return setting;
    }

    Read more...

  • Transparency on DRM and Windows Mobile upgrades

    I've really appreciated a few recent posts from Microsoft developers on the practical reasons behind some frustrating restrictions on Microsoft products - DRM and the inability to upgrade some Windows Mobile 2003 devices to Windows Mobile 5.

    First, Peter Rosser discusses DRM as both a Microsoft employee and a consumer of digital media.

    ...Microsoft makes a big, inviting target for lawsuits if we even appear to be soft on protecting copy protected content.... There's more to this than most people realize, though.  Not only do companies like Microsoft and Apple have to guard against lawsuits, etc., but they have to make the studios and other content producers happy enough with the DRM solutions that they will go *farther* and give us more content in more flexible ways.  Do you think that Comcast, DirecTV or EchoStar would agree to attach a digital tuner to a PC that can decode their signal without an ironclad guarantee that the content would not just end up on the net?  They are terrified of that prospect... and with (arguably) good reason.  DRM is what we need to open up PC-based solutions for all of our content.

    I know there are a lot of folks out there who vociferously oppose DRM on principal.  The "information should be free" crowd argues on the principal that you cannot own information, and content is just information.  That isn't reality, though, and the courts and laws agree that people who create content can sell it.  I won't pontificate further on that, but leave with a parting piece of information relating to the prior paragraph: if the "no DRM" crowd wins, we won't have lots of content with no DRM suddenly... what we'll have is broadcasters and content creators that won't have any reason to share their content.  Hollywood will release it's next generation of DVD replacements, this time with something less laughable than CSS protection, and that'll be it.  No PC viewing of digital content, just analog.  Depressing to me...

    Source: DRM in MCE Rollup 2

    Next, Mike Calligaro explains why upgrades aren't offered for some Windows Mobile devices, even though the hardware and operating system can support it:
    Why Can't I Upgrade 
    They Why Do You Get To Upgrade? (quote: We don't call it "dogfood" because it tastes good)

    Read more...

  • [link] Riya - Photo search with face recognition

    I've been looking for this exact product for a few years now:


    Riya is a free photo search service built around facial recognition. Sure, they support searching based on who's in the picture, but they've taken it further than that by treating the faces as people with identities and e-mail addresses. If I upload a picture of you, it'll show up in your searches[1]. That's cool!

    Read more...

  • Installing Windows Vista October CTP (Build 5231) on VPC with VM Additions

    I installed the Windows Vista October CTP (Build 5231) on Virtual PC yesterday. There were a few gotchas that I thought I'd share in case it saves anyone else some time.

    1. Virtual PC can't capture an ISO image greater than 2.2 GB, so you need to use something like Daemon Tools on your host machine to mount the ISO as a virtual drive, then capture it as a physical drive in VPC.
    2. Vista won't install on a RAW partition, which is what an unformatted VPC Virtual Hard Drive (VHD) image gives you. You can do some tricky commandline DISKPART stunts, or you can just create the partition in the install process knowing that Vista still won't like it, reboot the VPC instance, and this time VPC will recognize the partition it created. I went with the second option.
    3. This Vista build can't access Windows Update. You just get a message saying you need to use Automatic Updates and tells you how to set that up. Knowing that unpatched machines on the net can get haxxor'd in 20 minutes on average, I set the Auto Update time to the next hour and disabled the VPC network connection until that time. Silly me, there weren't any Auto Updates since it had just been released, but I still think minimizing Internet time before patching a machine is the best plan.
    4. The VPC VM Additions Installation hangs on this Vista build, and the graphics are absolute hell without them (640x480 at 8 bit, I believe). The trick is as follows: leave the hung installation running, go into the Control Panel and remove the VGA Display Driver, and say Okay when prompted to reboot. When the system comes back up, you'll have the state of the art S3 Trio display driver. It got wiggy on me when I tried to change the Display Resolution, so I rebooted again and was able to change the resolution and things were great. Dog slow, but great. If you cancel the install or kill the wrong msiexec process, the install rolls back and the drivers get removed, causing the magic not to happen.
    5. I kind of lied about the VM Additions. The video drivers are installed, and they make a big difference, but the rest of the VM Additions aren't installed. That means no folder sharing, etc. They might release VM Additions for Vista Beta 1, but I'm not holding my breath.
    I'll leave it to the pundits to describe what's new in this build, but the most interesting things for me so far are WMP 11, Media Center Vista (which it sounds like is going to be inclueded in Vista, no longer a separate product), and the latest IE7 build.

    Read more...

  • How exactly would you like me to "Quote values differently inside a '<% ... "value" ... %>' block"?

    Visual Studio freaks out when your HTML contains nested quotes. Roy's solution (using single quotes for the attribute and double quotes for the databinder or function arguments) works unless you need to nest quotes, which occurs if you're including a Javascript call in a databinding statement:

    <asp:TemplateColumn>
        <ItemTemplate>
            <
    href="javascript:showPopup('\Popups\Edit.aspx?ID=<%# DataBinder.Eval(Container.DataItem,"itemID")%>')">edit</a>
        <
    /ItemTemplate>
    <
    /asp:TemplateColumn> 

    The problem here is that you need quotes around your href attribute, quotes around your javascript function argument, and quotes around your DataBinder.Eval string parameter. Tim sums it up pretty will here, but you're pretty much stuck with either  "Quote values differently inside a '<% ..."value"... %>' block." or "Place quotes around a '<% %>' block used as an atribute value or within a SELECT element." I haven't seen a good discussion on how to handle this well, so here's what I've come up with - please recommend something else if you've got a better solution.

    We need a third quote, right? Well, one common solution is to use \u0022 - the VS UI doesn't see it as a quote and doesn't get confused, but the ASP.NET rendering engine writes it out as a quote:

    <asp:TemplateColumn>
        <ItemTemplate>
            <
    href ="javascript:showPopup(\u0022\Popups\Edit.aspx?ID=<%# DataBinder.Eval(Container.DataItem,"itemID")%>\u0022)">
            
    edit/a>
        <
    /ItemTemplate>
    <
    /asp:TemplateColumn> 

    A better solution is to just escape the quote with a backslash (\"). The VS IDE handles that just fine:

    <asp:TemplateColumn>
        <ItemTemplate>
            <
    href ="javascript:showPopup(\"\Popups\Edit.aspx?ID=<%# DataBinder.Eval(Container.DataItem,"itemID")%>\")">
            
    edit/a>
        <
    /ItemTemplate>
    <
    /asp:TemplateColumn> 

    Another solution is to use code behind to actually construct the links. I normally wouldn't use that unless there was a good amount of formatting, and even then you can get away from that with a format string in the DataBinder.Eval call. I usually see people recommend one-off functions for that kind of thing, but I prefer using something more generic. The following function will work in a page code behind, but could be made a static function and placed in a code library class: 

    protected string BuildJavascriptLink(string format, params string[] input)
    {
        format = format.Replace("{quote}","\"");
        
    string retval = string.Format(format,input);
        retval = retval.Replace("'","\"");
        
    return retval;
    }

    Now we could reference it in the code front with something like this:

    <href='<%# BuildJavascriptLink("javascript:showPopUp({quote}/PopUps/{0}{1}{quote},{2},{3})","StreetLevelMap.aspx?ID=",Convert.ToString(DataBinder.Eval(Container.DataItem,"Entity_ID")),"600","450") %>'>Street Map</a>

    Read more...

  • [link] Connecting to Terminal Services When All Active Sessions are Used

    Here's a little trick for getting into a box via Terminal Server when all sessions are in use. Phil and I came up with it yesterday and I was going to write it up, but he beat me to it with a pretty nice writeup. Here it is:

    We use Remote Desktop (Terminal Services) to remotely manage a Windows 2003 server that is not part of our domain. Recently we ran into the two user limit for remote desktop connections, which barred anyone from connecting. Jon discovered a neat little trick that got us in. He ran the following command from the command line: mstsc -console It turns out that mstsc.exe is the remote desktop connection application. The -console flag specifies that we want to connect to the console session of a server. Since we generally launch Remote Desktop from the icon, we almost always leave this console session free. Nice! ... [via haacked - Connecting to Terminal Services When All Active Sessions are Used]

    Read more...

  • [asp.net] Simple utility function to return all selected values from a CheckBoxList

    The ASP.NET CheckBoxList.SelectedValue property only returns first item selected. The MSDN solution is ugly - iterate the CBL items checking each one to see if it's selected.

    Five minutes of Google-Fu didn't turn up anything, so here's a simple utility function to get a string array of selected values.

    public string[] CheckboxListSelections(System.Web.UI.WebControls.CheckBoxList list)
    {
     ArrayList values = 
    new ArrayList();
     
    for(int counter = 0; counter < list.Items.Count; counter++)
     {
      
    if(list.Items[counter].Selected)
      {
       values.Add(list.Items[counter].Value);
      }    
     }
     
    return (String[]) values.ToArray( typeofstring ) );
    }

    Posted so:

    1. I can find it later
    2. I can maybe save the next guy some time
    3. The piranha haters community can point out how this could be done better.

    Read more...

  • JavaScript only pretends to support function overloading

    I frequently use method overloading a lot in my C# code to allow optional parameters, so when I wanted to implement a simple popup function with optional support for virtual root and website based on the url, here's what I came up with:

    function showPopUp(virtual, url, height, width)
    {
     
    if(location.pathname.indexOf(virtual)>=0)
     { 
      
    //we're running in the virtual root, so prepend it to the url
      
    url=virtual+url;
     }
     showPopUp(url, height, width);
    }

    function showPopUp(url, height, width)
    {
     window.open(url, 
    'PopUpWindow''toolbar=no,directories=no,menubar=no,resizable=no,status=no,height=' + height + ',width=' + width);
    }

    Javascript sneakily pretends to support this - no script error - every time I called the function, the virtual root wasn't being added on. That's because Javascript doesn't support method overloading; it just uses the function which was defined last (thanks, Bertrand, for verifying my hunch). I had to give the second function a different name, and it all worked.

    Here's an easy way to verify - this will show the second message:

    <html>
    <
    head>
    <
    script>
    function test(one,two)
    {
    alert('expected: first function with two parameters');
    }

    function test(one)
    {
    alert('surprise! second function with one parameter');
    }
    </script>
    <
    /head>
    <
    body onload="javascript:test('first','second')">
    <
    /body>

     

    Read more...