Archive for the 'Software development' category

Going to SD West 2008 - a planning worksheet

March 1, 2008 2:37 pm

Hi! It looks like you're new here. Welcome! If you like what you see, I encourage you to subscribe to my RSS feed. If you're worried about adding another RSS feed that will add to your information overload, don't! I'm not a prolific poster. Thanks for visiting!

I have the good fortune to be able to attend SD West this year. I’ve heard people at work rave about this conference right in my backyard, and was lucky to get approval to go this year.

Unfortunately I’ve been so swamped with work (really exciting new stuff, too) that I haven’t been able to prepare at all. In other words I still have no idea about what sessions to go to. Argh. To add to that frustration, the SD West website doesn’t make it really easy to plan your days for maximum efficiency. Double Argh.

Here’s how I like to plan my attendance: I have an idea at a high level about what kind of sessions I’d like to focus on (in my case .NET and People, Process & Methods mostly). So I need to be able to filter all sessions by those high-level criteria. Next, I need to figure out which sessions in those high level tracks are available at what time and how they may conflict relative to how interesting they sound to me.

The information provided on the SD West website provides some ability to filter and search for sessions, but it doesn’t help you with detailed planning.

So I decided to spend a little time pulling down all sessions as an Excel sheet (which the site allows, thank goodness), and started to shape and mold the sheet to my needs. The result is available for you to use as well, in case you’re as late as I am: sdwest08_all.xlsx (update: rename this file to have an .xlsx suffix after downloading, WordPress changed the extension on me).
(I think I have all sessions in there, but I noticed that one session seemed to not be fully downloaded (a session with quotes in the description), so I added it back by hand. Maybe there are others missing too, but I think that was the only one.)

You’ll see all sessions sorted by time, color coded by time slot/event type (keynotes, birds-of-a-feather), color coded by track, and with filters on each column. I also added a priority column at the beginning to perhaps help making decisions if you change your mind while at the event.

And, yes, I will most likely be wearing my Geek Tie at the event (it has a Red Verbatim Store’n'Go USB memory stick and a gray CaseLogic case at the end).

WPF ControlTemplate Trigger tip

January 5, 2008 2:11 am

I didn’t fully realize how ControlTemplate Triggers work (or don’t) until I solved a problem with a UserControl today, with the help of this post on the MSDN forums.

A Triggers’ EnterActions or ExitActions don’t seem to get fired when a UserControl is constructed. If you want, say, an animation in your control to start on a property change, you can put a BeginStoryboard element into a Trigger’s EnterActions and a reverse BeginStoryboard into the ExitActions.

But for the control to start out right at initialization you also need to have the right Setter element on the Trigger to set initial states (in addition to setting the opposite initial states on the elements to be animated/initialized.)

Here’s a tiny example:

 1 <UserControl> <!– Namespaces omitted for brevity –>
 2   <Grid>
 3     <ToggleButton x:Name=”Toggle”>
 4       <ToggleButton.Template>
 5         <ControlTemplate TargetType=”{x:Type ToggleButton}>
 6           <Grid>
 7             <!– Initial opacity is 1 for the initially unchecked ToggleButton state. A trigger changes it to 0 for an initial checked state. –>
 8             <Grid x:Name=”HideMe” Opacity=”1″>
 9               <TextBlock Text=”Hidden”/>
10             </Grid>
11             <!– Other parts of the control go here –>
12           </Grid>
13           <ControlTemplate.Triggers>
14             <Trigger Property=”ToggleButton.IsChecked” Value=”True”>
15               <!– This setter hides the desired element when the ToggleButton’s initial state is checked –>
16               <Setter TargetName=”HideMe” Property=”Opacity” Value=”0″/>
17               <Trigger.EnterActions>
18                 <BeginStoryboard>
19                   <Storyboard>
20                     <DoubleAnimation BeginTime=”00:00:00″ Duration=”00:00:00.05″ Storyboard.TargetName=”HideMe” Storyboard.TargetProperty=”(UIElement.Opacity)” To=”0″ />
21                   </Storyboard>
22                 </BeginStoryboard>
23               </Trigger.EnterActions>
24               <!– ExitActions go here to make the Grid with the TextBlock visible again –>
25             </Trigger>
26           </ControlTemplate.Triggers>
27         </ControlTemplate>
28       </ToggleButton.Template>
29     </ToggleButton>
30   </Grid>
31 </UserControl>

The ToggleButton contains a TextBlock in line 9 that I want hidden when the ToggleButton’s IsChecked state is True. The animation in line 18 takes care of doing that when the user interacts with the control, but when the control is initialized, I need the Setter in line 16 to hide the TextBlock initially if the ToggleButton is checked by default (through data binding, for example.)

The software free-conomy

December 19, 2007 11:50 pm

Richard Stallman, the prophet of free software, St. IGNUcius After looking through the comments to Jeff Atwood’s recent post on software product keys, I noticed that quite a few went down the rabbit-hole of  free versus paid software. People suggesting that if you don’t like paying for software, typing in license keys, managing them and other hassles, you can always go to using free software.

I can see where these people are coming from. I use plenty of free software myself: Windows Live Writer, Audacity, WinMerge, Process Explorer, PowerMenu, WiX, Notepad2, Firefox, Reflector, JAlbum, Gallery, Linux (contribs.org), Paint .NET, etc. etc. etc. Many of these are essential for productive work and I’m glad they let me accomplish things.

In October 2002 I attended a talk by Richard Stallman, where he was spreading the gospel of free software, which is often equated with open source software, or OSS. It wasn’t the first time I’d started thinking about the implications of OSS, but his comments sparked further puzzlement: Is it really possible for programmers to make a living on open source software? Seeing the comments on Jeff’s blog brought back that question.

It seems to me that a lot of the more successful open source projects out there had their origin in the world of what I want to call the free-conomy, or perhaps the carefree-conomy. It’s the world all around us consisting of people who do not have to worry about real-world problems connected to making a living: Students, living on their parents’ money or borrowed money; programmers employed by large corporations (that have other means of generating income that enable them to pay the programmer to work on free software); professors in tenured positions at universities, contributing as part of their research. You get the idea.

I’d be curious to know how many of the commenters to Jeff’s post fall into that category. I’d also be curious to know how all the people who contribute to open source, or free software make a living, or how they sustain themselves. These are honestly things I’m curious about. If you’re one of them, please tell me.

I think once you transition from the free-conomy to the reality-based economy (”real life”?), your perspective changes. You start realizing that you need an income to pay the rent, clothe yourself and your family, buy food, utilities and transportation. You begin to see that if you don’t pay for the music you like to listen to, the programs you like to use, the books you like to read, the movies you like to watch and the games you like to play, the people who produce those things will not be able to support themselves, and thus there may come a time when you will no longer have that music, those programs, those books, those movies or the games.

So all the hassles that the producers of software or other digitizable content make you go through to access their creations begin to seem like a small inconvenience to pay for the privilege.

Of course, you can still debate what a fair price for such creations is, but that’s a topic for a different post. You can also debate the principles of “fair use” of the creations you may have paid for. That’s also a topic for another post.

What’s your perspective on the implications of open source software for people who make a living at software programming/development?

Introducing CardSharkV

November 25, 2007 1:06 am

Check out this program I’ve developed, called CardSharkV. It’s a digital picture storage card/camera “downloader” with a twist.

It’s a bit of an experiment, and I’m looking for some real-world “beta” testers. My plan is to try my hand at charging for the program. But to see if word will spread, I’m planning to give out 50 or so licenses without charge while I work out any kinks that might be in the program.

If you’re interested in trying it out, download the program, install and run it, and then click the “Request License” button.

Read more about it on the CardSharkV page.

Update (2007-11-25): CardSharkV depends on the .NET Framework 3.0. It’s thus meant to be installed on Vista systems only. If you have XP and the .NET Framework 3.0, it should still work. Also, since I posted the whole thing Saturday night after a whole day of re-shaping my first, never published version, I didn’t test the install too well. I’ve since had a little time to test and found some issues, especially with the license mechanism. I’ve posted version 1.0.2.0 to correct those issues and to improve the installer as well.

Microsoft deprecates support for XBAP WPF apps in version 5.3 of the Media Center SDK

November 19, 2007 10:02 pm

I downloaded and installed the latest version of the Media Center SDK just now, and was a bit surprised to see that WPF apps are now officially deprecated as a supported way of extending Windows Media Center on Vista. There’s no big announcement around this so far, it’s almost just a footnote in the “What’s New” section:

Deprecated features

The following features have been deprecated:

  • Hosting for Microsoft .NET Framework 3.0 Extensible Application Markup Language (XAML) browser applications (XBAPs).
  • The Triple-tap/Soft-keyboard ActiveX control for hosted HTML applications.
  • Support for using alternative shells to run and host HTML applications.

The reason I’m surprised is that Microsoft announced the support for WPF based extensibility apps at PDC05 with some fanfare.

I guess interest among developers just hasn’t been there for WPF-based Media Center apps, and Microsoft needs to make judgment calls on where to invest in their extensibility platform. The rest of the deprecated features seem to have been made for the same reason: limited interest among developers for these features. In addition I think there might be issues of an architectural nature that just make the three things that got dropped too expensive to maintain or improve.

I’m sad about this development, mostly because I still don’t see a great set of development and design tools around for MCML. WPF seems to me to have a whole lot more momentum than MCML (WPF has the Expression suite of tools and has been billed as the “GDI for the next 20 years”), but who knows what may be coming for Windows 7, or even an earlier interim update for Media Center?

How to parse "special" .lnk files, aka. MSI shortcuts aka. Windows Installer advertised shortcuts using C#

9:21 pm

This is a problem that’s been bugging me for about a year and I finally found time to dig in and work on how to solve it. A big thank you goes to Aaron Stebner for pointing me in the right direction. Thanks Aaron!

Anyway, for various reasons I’ve wanted to display a list of applications the user has installed on the computer. Getting at the All Programs folder in the Start Menu is not too big a problem. You can get parts of it via Environment.GetFolderPath(SpecialFolder.Programs) and other parts of it (for all users) via a bunch of P/Invoke incantations that I’m not going into here. Iterating through all subfolders and picking out the .lnk files is not a problem either.

What is a problem (at least it was for me) is what to do with those .lnk files that you can’t get parsed correctly via WshShell.CreateShortcutFile() after adding a reference to the Windows Script Host Object Model to your project. The .TargetPath will usually return something down in a C:\Windows\Installer\{GUID} directory.

I had noticed that the Windows Installer XML 3.0 project creates shortcuts like that, and since Aaron is involved in that project, I asked him about it. He graciously told me that those shortcuts are “advertised” shortcuts, a kind of Windows Installer shortcut that enables putting a link in the Start Menu (or elsewhere) while not necessarily installing the whole product that the link points to. So I started digging in with Google. A CodeProject article contained a comment about two functions that can be used in combination to find the real target of and advertised shortcut: MsiGetShortcutTarget() and MsiGetComponentPath(). After some more digging, I had P/Invoke declarations for both of these from this SourceForge project.

I ended up with this bit of code, which I use first on any shortcut file I need to interpret; then if it returns null, I use the WshShell way instead.


public static string ParseShortcut(string file)
{
    StringBuilder product = new StringBuilder(MaxGuidLength + 1);
    StringBuilder feature = new StringBuilder(MaxFeatureLength + 1);
    StringBuilder component = new StringBuilder(MaxGuidLength + 1);   

    MsiGetShortcutTarget(file, product, feature, component);   

    int pathLength = MaxPathLength;
    StringBuilder path = new StringBuilder(pathLength);   

    InstallState installState = MsiGetComponentPath(
          product.ToString(),
          component.ToString(),
          path,
          ref pathLength);
    if (installState == InstallState.Local)
    {
        return path.ToString();
    }
    else
    {
        return null;
    }
}
 

If you’re interested, you can download the class with the rest of the needed declarations.

Silicon Valley Code Camp impressions

October 29, 2007 10:19 pm

I’m just about recovered from two interesting days at Silicon Valley Code Camp. Overall I found the time I spent there well invested. It was fun seeing the diversity of software developers we have here, and the talks were of high quality overall.

Here’s part of the lunch line from the second day:

IMG_9714

Of all the sessions I attended, I’d say the top four were the introductory LINQ talk by Beth Massi, the Architecture talk by Kim Greenlee, the Project talk by Jeff Atwood and the UI Designer talk by Uday Gajendar. This picture is from Ujay’s talk (a bit fuzzy, sorry):

IMG_9715

The talk on what makes agile projects succeed by Chris Sims was not a traditional presentation, but a highly interactive workshop, where Chris introduced us to the Nominal Group Technique; a way to brainstorm while making sure nobody gets to dominate the process. I think this was the session I enjoyed the most because it was so different and engaging. In that session we got a glimpse of the soon to be released XO laptop (one laptop per child), and later in the day, I got to grab a hold of it for a few minutes. It’s a very well made product. Check it out at www.laptop.org (or www.xogiving.org, if you’re inclined to be charitable and help out a child in a developing country.)

I had quite a bit of fun trying out a new toy, too: a digital sound recorder. I used it to record a few of the sessions I attended. If the speakers permit it, the recordings might get placed on the Code Camp Wiki over the course of the next few days.

To give you a bit of an impression of what it was like to be at Foothill College early on a Saturday morning (9 AM), here is a picture:

IMG_9711

I have a sound recording to go with it, too. The dog in the picture is Milo. How do I know? Listen to the recording.

I can recommend going to Code Camp next year, if you can make it. It’s worth it trying to step out of the typical programmer “introversion” and talk to people. It’s hard to overcome that initial shyness, but once you do, you’ll have a much better time. I’ll need to do more of that next time. Barring any serious scheduling problems, I’ll definitely be back next year.

Thanks to Peter Kellner and all the other people who supported the event. Also a big thank you to all the presenters, especially the ones I got to hear (Chris Sims, Kim Greenlee, Jeff Atwood, Uday Gajendar, Peter Kellner, Deborah Kurata, Beth Massi, Wesley Chun and Mathias Brandewinder.)

Windows Live Writer Beta 3 startup problems solved

September 11, 2007 12:21 pm

I like Windows Live Writer. Except for one thing: I couldn’t get it to start up on my machine at work. Beta 1 worked, but Beta 2 and Beta 3 just wouldn’t. I’d always get a UriException (not sure of the precise name anymore) thrown at some point after the splash screen.

During Beta 2, I dutifully sent the crash reports to Microsoft, and even contacted their support email address once, hoping the problem would be addressed with Beta 3.

It wasn’t. Live Writer Beta 3 still crashed on me after the splash screen.

So I started digging into why it crashed. Luckily it’s a .NET app, so Reflector came in handy. So did Deblector. I finally tracked it down to a registry key that contained a setting for a blog at work, where the HomePageUrl was a path of the form /some/path. I deleted the entire tree for that blog, and now Live Writer finally starts up properly.

The key I deleted was a subkey under this:

HKEY_CURRENT_USER\Software\Microsoft\Windows Live\Writer\Weblogs

I think Microsoft needs to fix this before shipping the final version.

Troubleshooting ClickOnce deployment issues

August 25, 2007 9:18 pm

Over the last few days I ran into several puzzling ClickOnce deployment problems. I want to document and share these so that I’ll remember them better, and so others might find help with similar issues.

The first issue:
I uploaded new versions of my files several times, but every time I attempted to download the refreshed versions, no matter which computer I tried it on, all I got were old files. Ctrl+F5 in IE didn’t make a difference. Clearing the Internet Explorer history, cookies, temporary files didn’t make a difference. I even contacted my web host to see if they have any caching issues on the server side. In the end I stumbled across my installation of Fiddler, the HTTP debugging proxy. I looked at the raw HTTP dumps, and then I saw the issue: I’m behind an active caching proxy on my home network. The proxy was giving me old files all the time.
First issue solution:
Clean out the cache files on my proxy server. It happens to be squid, so this did it:

service squid stop
echo “” > /var/spool/squid/swap.state
service squid start

The second issue:
During the troubleshooting of the first issue I had started suspecting the ClickOnce caching system to be at fault. So I used “mage -cc” and “rundll32 dfshim CleanOnlineAppCache” to clean out the cache. No change. Then I started manually deleting files from the cache location on the hard drive. Bad mistake. Now I got weird deployment errors, talking about COM objects not being available, and “interesting” HRESULT errors: The referenced assembly is not installed on your system. (Exception from HRESULT: 0×800736B3). I uninstalled the .NET Framework 2.0 and 3.0 and reinstalled them. No change. Luckily I found an article on the MSDN forums that pointed me to a registry location to check out: HKCU\ Software\ Classes\ Software\ Microsoft\ Windows\ CurrentVersion\ Deployment. I checked it out and found a bunch of registry keys that I remembered seeing when I cleaned out the cache files before. So what would happen if I deleted all those keys? Maybe it would “reset” ClickOnce completely? Luckily it did.
Second issue solution:
Clean out both the ClickOnce cache files [C:\Documents and Settings\(User)\Local Settings\Apps\2.0] by hand (completely), and also clean out the registry keys under Components, Marks, PackageMetadata, StateManager\ Applications, StateManager\ Families and Visibility underneath HKEY_CURRENT_USER\ Software\ Classes\ Software\ Microsoft\ Windows\ CurrentVersion\ Deployment\ SideBySide\ 2.0

Caution! Your Mileage May Vary. Deleting registry stuff is dangerous! Make a backup first.

Getting Vista UAC elevation to work for web deployed ClickOnce applications

12:06 am

Normally you can’t have ClickOnce applications that are deployed over the web run with Vista UAC elevation prompts. It’s not something Microsoft supports. Not sure why. I guess it’s once-bitten twice-shy, coming from the whole ActiveX mess. So I guess I do kind of understand why.

There is a workaround, if you really need UAC elevation, which you shouldn’t. But at a high level, it works like this. You create your ClickOnce app like you would normally. To go with it, you create a helper app that you equip with an embedded elevation manifest. You then add a test to your ClickOnce app to see if it’s running elevated. If it isn’t you make it call the helper app. It will cause a UAC elevation prompt and in turn launch the ClickOnce app anew. Since the helper got elevated, the ClickOnce app now runs elevated too. Of course, by doing this you might end up with users not accepting the elevation request. But from what I’ve seen real users do with those elevation prompts, it won’t matter much. Anyway.

The trick is getting the helper app included in the regular ClickOnce app. There may be better ways, but here’s one I’ve spent quite some time on to work out. Maybe it will help someone out there save time, like I’ve saved time by reading posts on elevation checks using managed code. So here are the steps I’ve followed to make this work:

  1. Modify your ClickOnce app’s entry point to include elevation checks as described at http://www.itwriting.com/blog/?p=198. If the app is not running elevated, make it run the helper application and exit. The launch looks something like this:

    ProcessStartInfo

    psi = new ProcessStartInfo(“Helper.exe”);
    psi.UseShellExecute = true;
    Process.Start(psi);

    The UseShellExecute flag makes sure the UAC prompt will happen.

  2. Create your helper application with an elevation manifest (the process for that is at Catherine Heller’s blog) and have it launch your app with something like this:

    string
    appExe = Environment.GetFolderPath(Environment.SpecialFolder.Programs) + @”\YourClickOnceApp\ClickOnceApp.appref-ms”;
    Process.Start(appExe);

    As you can see the whole scenario only works if you let the ClickOnce app create a Start Menu entry.

  3. Build and publish both applications, making sure they use the option to rename the published files to .deploy extensions. This helps tremendously with web deployment.

  4. Find the published helper .deploy files and copy them to the folder that contains the ClickOnce application’s .deploy files.

  5. Open the ClickOnce application’s .exe.manifest file using MageUI. Go to the Files section and click the Populate button to include the helper app and its manifest in the fileset for the ClickOnce app. Save and sign the manifest. I used a stored certificate for the signing.

  6. Open the ClickOnce application’s .application deployment manifest using MageUI. This is probably in the directory above the .deploy files. Open the Application Reference section. Click the Select Manifest… button and browse down to the manifest you modified in step 5. Save and sign the manifest. I used the stored certificate from step 5.

  7. Now you have all the needed files packaged for uploading to your web server.

This is what will happen when the user downloads the app for the first time: A verification window shows briefly, followed by a download warning, followed by a download progress window. Now the UAC prompt will come, and if accepted, another verification window. Then the app will show.

On subsequent launches of the app the user will see the verification window, followed by the UAC prompt, followed by another verification window. Then the app will show.

It’s not pretty, but at least it works.

If you try these steps out and they don’t work, I’d appreciate an opportunity to correct them.

————————————————-

P.S.: The manifest generation step looks like this for C# projects:

“$(DevEnvDir)..\..\VC\bin\mt.exe” -manifest “$(ProjectDir)$(TargetName).exe.manifest”  ?outputresource:”$(TargetDir)$(TargetFileName)”;#1

The .exe.manifest for the helper needs to look something like this (you can leave out the commented parts):

<?

xml version=1.0 encoding=utf-8 ?>

<assembly xmlns=urn:schemas-microsoft-com:asm.v1 manifestVersion=1.0>

<assemblyIdentity version=1.0.0.0 processorArchitecture=msil name=Helper type=win32 />

<description>Helper</description>

<trustInfo xmlns=urn:schemas-microsoft-com:asm.v3>

<security>

<requestedPrivileges>

<requestedExecutionLevel level=requireAdministrator />

<!–<requestedExecutionLevel level=”asInvoker” />–>

<!– <requestedExecutionLevel level=”highestAvailable” /> –>

</requestedPrivileges>

</security>

</trustInfo>

</assembly>

Close
E-mail It