Using the registry to resolve Visual Studio reference paths.

Posted by Justin on January 28th, 2010 filed in Just A Programmer
Comment now »

Note: To skip the long journey of what lead me to figuring this out, click here to go to the howto.

Recently I was asked to look at a fiddler plugin Stan, the founder of this blog, was developing. He gave me a SVN path and asked me to build it and test it.

So I checked out the source code and hit F5. I got a bunch of compiler errors relating to the fact that I didn’t have fiddler installed. I rectified that matter and still got errors. The problem was that the hintpath of fiddler.exe was wrong. On my machine, Fiddler is installed in ‘C:\Program Files\Fiddler2\’, while on Stan’s machine it is installed to ‘C:\Program Files (x86)\Fiddler2′. I consulted the mighty google, which led me to a stackoverflow question. The question pointed out that you can have multiple hintpaths to an assembly. However, I wanted a better solution. What if someone installed Fiddler to a custom location?

I got the idea of using the registry. Fiddler has an installer. Surely the installer records its install location to the registry. It does in ‘HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fiddler2′ (Apparently fiddler is written by a Microsoft Employee). So the question is how to get MSBuild, the tool that visual studio uses to parse project files, to read a value from the registry.

The answer was found in a post on the MSBuild team blog.

How To

Unfortunately, Visual Studio does not allow you to edit hintpaths to referenced assemblies. So you’re going to have to edit your vcproj or vbproj file in notepad or some other text editor.  Here are the steps:

  1. Open the project file in your text editor.
  2. Look for the <Reference/> element for fiddler.exe. It should look similar to this:

    <Reference Include=”Fiddler, Version=2.2.7.5, Culture=neutral, processorArchitecture=MSIL”>

    <SpecificVersion>False</SpecificVersion>

    <HintPath>C:\Program Files\Fiddler.exe</HintPath>

    <Private>False</Private>

    </Reference>

  3. Change the hintpath as follows:

    <Reference Include=”Fiddler, Version=2.2.7.5, Culture=neutral, processorArchitecture=MSIL”>
    <SpecificVersion>False</SpecificVersion>
    <HintPath>$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fiddler2@InstallPath)\Fiddler.exe</HintPath>
    <Private>False</Private>
    </Reference>

  4. Save the file
  5. Visual studio will detect the file change and ask you to reload the file. If you are using SharpDevelop as you’re IDE, you will have to close and reopen the solution.

Thats all there is to it. Happy coding!


What three things got me here.

Posted by Justin on January 21st, 2010 filed in Just A Programmer
Comment now »

Paul Randal wrote a What three events brought you here article on his blog and asked some others in the SQL server community to do the same. I of course was not on that list. However, no one ever invited me to blog about anything before so why should I be shy now.

I have decided to not tell this story in terms of professional accomplishments. For me, my hobbies have always led my career. Read the rest of this entry »


Trouble building PHP on Windows

Posted by Justin on January 17th, 2010 filed in Just A Programmer
3 Comments »

Update: It seems that the facts presented to me in the initial bug report are not correct. I will be revising this article after the facts are settled. For now read the comments.

It all started with a simple bug encountered while trying to get PHP and WCF to play nice. Before you know it I was attempting to compile PHP on windows myself. That’s when I realized how deep the rabbit hole really goes.

These days I program in PHP and .NET for a living. In a past life I was a unix admin for small ISP where most of the internal unix infrastructure was FreeBSD while the managed customers tended to run Redhat.  Due to the unique path of my IT career, I usually don’t have a problem compiling open source software primarily targeted for unix on windows. PHP has proven to be a bit of an exception. However, with a little struggle, I got it to compile.

In this case the crux of the struggle was not a lack of documentation, but documentation outdated to the point of being wrong. This is perhaps the one exception to the rule postulated by Dick Brandon, “Documentation is like sex . . . when it is good, it is very, very good; and when it is bad, it is better than nothing.” Thankfully, Pierre of libgd fame pointed me in the right direction on the mailing list. So being a good netizen, I submitted a bug report so that someone with commit access to the php source repo could straighten the mess out. This was the response I received:

We don’t understand the build requirements or system.

You have to ask the Microsoft guys to update that file.
http://no.php.net/manual/en/install.windows.building.php was one of our
best Windows know-how (not-microsoft-employee) guy shot at documenting
the process, but the feedback he got from Microsoft employees was “this
is crap. its all wrong”.

Sorry, we simply do not know how to do this.

That was a little disheartening. I asked them to mark the readme file as outdated, and I asked them how to contact Microsoft. This was the response I received:

Updated the file to say its outdated.

As for contacting the Microsoft guys, try surfing around on

http://windows.php.net

We have tried multiple times to get these docs updated, with no luck so
far, and like I said; our last attempt was shot down and they wanted
those docs to be reverted.

I’m sorry, you are simply on your own here.

So it seems my only resort is to blog about it and hope someone from Microsoft is in earshot. If you care about PHP on windows, spread the word. Spread this article with twitter, digg, reddit, or just plain old email. If you have the ear of anyone in Microsoft give it a bend. I’ve never attempted blogger activism like this, but I don’t know what else to do. I much prefer to fix problems myself than delegating or inspiring. However, this is one case where I need to “have a little help from my friends.” I don’t even know what Microsoft finds wrong with the proposed updates to the documentation, so submitting updated documentation seems pointless.


Yes your software needs an installer.

Posted by Justin on January 16th, 2010 filed in Uncategorized
2 Comments »

Some people have a love-hate releationship with certain pieces of software. Others, a love to hate relationship. My releationship with Eclipse is more of a respect-hate relationship.

Perhaps I make that categorization, because I cannot admit a more purer dichotomy of love-hate, I’ve often described eclipse as being put together by a hippie commune of developers. The features are all nice. However, the complete lack of central planning is very apparent. The fact that there are at least three “Find” dialogs in Eclipse PDT, the Eclipse distribution designed for PHP is testament to this. In the Edit menu their is a find dialog for the current document. In the Search menu there is one dialog for searching for PHP methods, fields, etc. There is also a second that has several tabs for searching for javascript, plain file search, and others.

This is all somewhat acceptable, as Eclipse not only an IDE, but a Framework for making IDEs. There are third party eclipse distributions for editing java, PHP and other languages in eclipse that are more polished. Perhaps its best that the “reference distributions” have the full hodgepodge of features, and third parties take the “less is more” approach.

However, one missing feature I cannot forgive is the lack of an installer. All mature software projects should have proper installers for their platform. For an Apple, this means a .dmg file with a .app bundle built in. For windows this means an MSI, exe, or an exe wrapped around an MSI. For linux this means an rpm and debian package.

That’s not to say I am against the concept of a binary zip or tarball. On the contrary, some people don’t like installers, and they should have the option of just unzipping. Freedom of choice is a good thing. However, I am saying that an installer is one of the necessary choices for all platforms.

As a final aside, I realize that a dmg with a .app bundle is not really an installer on par with an RPM, MSI, or EXE installer. I also realize there are real installers for MacOSX software that a minority of Mac Software uses.  So I acknowledge that Mac OSX is an exception to this rule.


Printf() for jquery.

Posted by Justin on January 16th, 2010 filed in Just A Programmer
Comment now »

I was preparing for my pre-session talk this past November at LISUG, when I determined that I needed a printf() function for jquery. To be more accurate, more accurately I needed an sprintf() implementation in javascript, and wanted to .

Google lead me to a jquery plugin that has not been updated since 2007. However, sometimes software gets to the point where it really doesn’t need to be maintained, and if it worked for me I was not going to dismiss it as abandoned software.

In the end it did require a small patch to handle %% (really print a percentage sign). Unfortunately, the maintainer has not acted on my patch. However, please apply it if you plan on using it.


Self appointed traditionalist bishop of the Church of XML

Posted by Justin on November 7th, 2009 filed in Just A Programmer
Comment now »

In a recent blog, ESR coined an interesting phrase, high-church XML. I have identified with this term, and all of its connotations. I have expanded upon the idea and declared myself a traditionalists bishop in the church of XML

ESR was trying to point out that regexes are appropriate for extracting information from html, because its tag soup, and DOM parsing doesn’t work well. I personally think some clever xPaths could be made to work, but I question the performance. I also think regexes are better when you are screen scraping because you can’t even guarantee the xml will be well formed.

He coined, the term to describe the other extreme, when you have a tightly defined schemas. Assumably the schemas are defined by xsd, but dtd and the exotic schema standards could do similar jobs.

To make a long story short, I spent a lot of time at the other extreme. I’ve used, extended, and authors several xsd schemas at a previous employer. I cannot discuss specifics, but can claim that thousands of documents go through their systems a day that must pass my strict schema, or the data gets sent back to its source like a citizen at the DMV that forgets to fill out part of a form.

I don’t claim superiority to ESR. He is not in a position to tell the forges “clean up your data.” My company was. He is not doing the forges a favor. I am just saying that I do appreciate the beauty of strictly defined xml documents.

Now, just some definitions related to his term an my self appointed title. High and low church refers to emphasis on ritual, incense, and “tradition.”  High church is mass in latin. Low church is Joel Osteen. A bishop is a clergyman tasked with authority over an area served by several churches. And traditionalists refers to Traditionalist Catholics, or a group of Catholics, some excommunicated, some not, that want the Catholic Church to return to its state before Vatican II where mass and the other church rituals were conducted in latin, meat was forbidden on all Fridays, and so on.

I’m a big fan of structure in my data so I’m all about my high church schema’s. I care about xml passionately, so I appoint myself a bishop. But where does the traditionalism come from? What innovations do I reject? The answer is html5. I don’t actually reject html5, I just reject it not being xml. I want a video tag in xhtml.


Github, because software kittens should be cloned, not adopted

Posted by Justin on November 4th, 2009 filed in Just A Programmer
1 Comment »

This is a tale of two open source software projects. However, unlike two certain European cities, there fates are not particularly intertwined, and there is little greatness about their history.

The projects are mqmanager, and console. Mqmanager is a tool for managing MSMQs written in .NET. Console is a multi-tabbed wrapper around cmd.exe.

Both projects are hosted on sourceforge. Neither project is terribly popular, although console is more so than mqmanager. The difference is in the SCM or source control management.

See mqmanager uses SVN, after a CVS migration, while Console uses git. More specifically Console hosts git on github.

“Whats so special about github?” you may ask. Well, mainly the forking presentment, or more specifically the one click forking. See, svn is centralized source control management, there is one repo that everyone reads from and writes to. In git, everyone has a full copy of the repo, and people can push and pull from each other based on network availability and security settings. More importantly, every open source git repo (they have a paid for option for closed source hosting) on github has a “fork button.” Want to fork project? Make an account, login, browse to the project, click the fork button. You have a full copy of the repo, along with the ability to add issue tracking, downloads, etc.

Now your asking, “Doesn’t this make forking too easy?” Well forking in and of itself isn’t that bad. Current trends in SCM policies for commercial companies as well as open source projects. And making it easier to fork doesn’t make it easier to make anyone care about anyone elses forks. If I forked emacs or firefox, few people would use my fork, regardless of how long it took me to setup SCM. My fork would do little to distract any resources besides my own.

I established forking does little harm, but whats the benifit? The benefit, at least the one I care about is for the less popular projects. Console is much more popular than mqmanager, but neither are hugely popular. Neither have funding or a development team of more than one person.

When I found mqmanager, it was abandoned like a stray kitten. I contacted the original developers, and was given control of the project. I improved it, used it, and forgot about it. Someday someone else might make changes to the code that they want to contribute back to the community. They will have to find me, I will have to give them access to the source forge project, and they will be stock caring for the project.

With console its a different model. The sourceforge page has  a sorce archive and a binary archive. I wanted an installer, and I was willing to write one myself. I made an account on github, forked the project (there is a fork button on each repo that will fork any project), made some changes, committed to my branch, and sent a pull request to the original author. Github makes it quite clear that I am a fork of bozho, and bozho can accept my changes at any time. A year from now someone can fork my version and send bozho and myself push requests.

The benefit of github is you don’t have to ask permission. Your cloning my kitten, not adopting him. Thats important for smaller niche open source projects. If I write a niche open source product, I probably won’t be using it regularly two years from now, but someone else might need it. The decentralized github model works better than the forge model for this.

I have adopted a few kittens over the years, and have a few kittens in need of adoption. I plan on migrating all my OSS project over to github. I will keep up the sourceforge pages, but  strip most of the sourceforge functionality to encourage use of the github pages. Perhaps people will fork these projects. Maybe at the time I will be to busy to evaluate their pull requests, but in the end my software . . . my craft . . . my art will live on and hopefully be mare more useful by others.


Stack Overflow, providing definitive answers that previously would have gone unanswered.

Posted by Justin on August 26th, 2009 filed in Just A Programmer
Comment now »

I am a stackoverflow, serverfault, superuser, and of course meta stackoverflow junkie. This probably comes as no surprise due to the three sites I recently launched.

There are many reasons I like these three sites. First of all, I am a big fan of on-line and real life programmer interaction. Secondly, I like the model Jeff Atwood and Joel Spolsky’s designed. Finally, the site just works and has a lot of users and content.

Today I was looking at some VB.NET code, and some string literals were being concatenated. These were long strings so it certainly made sense for them to be broken up along multiple lines. Normally I would assume the .NET compiler would optimize this to one string during the compile process, but I decided to search on stackoverflow. I found the following links:

I got my answers quickly, with references to the relevant specs, and IL code generated from sample source code. There are many duplicates on this topic, and I should take the time to notify the moderators to close them. However, today I produced better codeand was enlightened a little thanks  to stackoverflow.


Code Monkey Gets It “Java is to complicated”

Posted by Justin on August 11th, 2009 filed in Uncategorized
Comment now »

A clear article explaining why simpler is better with web service libraries.


It doesn’t bother me if half the world still runs XP

Posted by Justin on August 9th, 2009 filed in Uncategorized
Comment now »

I am an avid Reader of Jeff Atwood’s Coding Horror. I usually agree with him. However, I must disagree with his hatred of Window’s XP’s continuing popularity. I don’t care.

Disclaimer: I still run Windows XP at home and at work.

So now that I’ve stated my prejudice, I’ll talk about a similar situation that does bother me, people that use MacOS9, and why thats a completely different story.

Why do I hate the, now very small number of, MacOS9 zealots? Because of their fear of change. I try not to hate them for their lack of appreciation for a true multi user OS based on unix and the mach microkernel. Most of them just don’t care. I could never convince a client that ran a SECURITY guard company who was a retired NYPD Detective Sargeant of the neccessity of passwords to SECURE computers. Most people want to use their computer to accomplish a task. These are the same people that take their cars to their dealer for maintance, and don’t question their dealers reccomended service schedule. All that being said, these MacOS9 people, at least the ones using Quark and Photoshop, need to realize that the newer versions of these packages will improve their daily workflow.  Grouped masks and the like transformed how most people use photoshop. I’m sure in the past ten or so years quark has improved greatly.

Now this excert from a recent coding horror article seems to sum up Jeff’s position quite well.

Thus, I’ve been following the development of Windows 7 with cautious optimism. It’s important to me not because I am an operating system fanboy, but mostly because I want the world to get the hell off Windows XP. A world where people regularly use 9 year old operating systems is not a healthy computing ecosystem. Nobody is forcing anyone to use Windows, of course, but given the fundamental inertia in most people’s computing choices, the lack of a compelling Windows upgrade path is a dangerous thing.

The thing is I don’t have any problem with anyone using a 9 year old operating system. As long as they are updating the software running on top of it regularly. @Crazygeekchick, whom I follow on twitter, spent a good portion of saturday installing all the Microsoft Software she regularly uses on top of a fresh windows 7 install. People that Windows Vista or 7 and never run windows update, install a third party browser, or use a non microsoft program for any of their tasks bother me. My friend that ran windows 2000 until forced to do otherwise to use the latest version of DirectX does not.

Running XP in this day and age is a purposeful decision. Running Vista is the easy thing to do. If Vista is what you want, due to UAC or WAS, go for it. However, if you hate Vista, use XP, or Windows 7, or Linux, or even Plan 9 from Bell Labs.