harriyott.com

Tuesday, November 21, 2006

FileNotFoundException with CustomActions in Windows Installer

I'm building an installer with .NET 2.0 at the moment. I've been adding CustomActionData to the CustomAction dll, which includes a path. After adding a couple of new parameters, I started getting this message:
Exception occurred while initializing the installation:
System.IO.FileNotFoundException: Could not load file or assembly
'file:///C:\Windows\system32\Files\Company\Product\CustomActions.dll' or one of its dependencies. The system cannot find the file specified..

Now, I'm not actually trying to put the custom action in system32, it should be going under Program Files. The problem turned out to be a CustomActionData parameter. Here are the two values I tried - the first works and the second fails:

/installpath="[ProgramFilesFolder][Manufacturer]\[ProductName]"
/installpath="[ProgramFilesFolder][Manufacturer]\[ProductName]\"

What seems to be happening is that the \" is escaping the quote. The installer must be putting extra parameters after the supplied string, which are used to locate the CustomActions dll. Because the last quote is escaped, the value of the hidden parameters is appended to my installpath parameter, and the installer "loses" the CustomActions dll. I think that this probably counts as a bug in the installer.

This one has been bugging me all afternoon, and I didn't have much luck with Google. I've laden this post with keywords, so hopefully someone else will benefit from my hideous afternoon. [n.b. we have no internal mechanism for recording findings like this, so I use this blog as a personal store for non-IPR work stuff].

Update: I needed too use [SourceDir] to, but this didn't work, unless there trailing slash was present!. This is the opposite of the previous behaviour, so the second one of these works and the first one fails. Weird.

/installedfrom="[SourceDir]"
/installedfrom="[SourceDir]\"

Monday, November 20, 2006

Microsoft .WET event

Nice to see Microsoft hosting an event in their swimming pool.

Saturday, November 18, 2006

Guess who I saw

My new project with a random guy I met on the internet a couple of weeks ago will be called Guess who I saw. Not saying what it is yet, this post is just to get Google's robot spider working on it. Oh, I've just got it. It's called a spider because it lives on a web!



[Tags: ]

Friday, November 17, 2006

Sussex Geek Dinner: 21st November in Brighton

The next Sussex geek dinner is on Tuesday at 8pm, at the Black Horse in Church Street, Brighton. It's free entry, and Jay Gooby from Snipperoo will be speaking on JQuery. Please sign up on the geek dinner site.

[Tags: ]

I'm not working on a project, I'm working on an experiment

Two excellent posts by Jeff Atwood on why the deadline may not be hit.

[Tags: ]

Tuesday, November 14, 2006

CSS for painting

I've got a great new idea for an invention, that I just thought of whilst painting the walls of my daughter's bedroom, which is going to take 3 coats, and I'm not totally sure that the colour is exactly what I want, and I can't tweak it a little once I've finished.

A CSS file makes it really easy to change the colours of an entire website all in one go, and saves loads of time. My idea is to have a CSS file for a house. In that way I can try out a colour, and change it if I don't like it. e.g. I can start with this:


.house .bedroom .emma
{
   background-color: FloralWhite;
}


and if I don't like it, I can change it to


.house .bedroom .emma
{
   background-color: PapayaWhip;
}


Haven't quite figured out how to code it up yet though...

Saturday, November 11, 2006

Ruby on Rails for .NET developers

As a .NET developer, when it comes to development, I sometimes feel a little bit like the PC in the Apple adverts. I see trendy web 2.0 apps written in Ruby on Rails and feel just like I did when I was at school - one of the square kids. But hey, you can write webparts for SharePoint in .NET. Quite.

So, given that the cool kids in my school were thick as milkshakes, I thought I'd look into it. Here are my observations after about two or three hours of trying to hang out near the cool kids hoping I look like I belong.

My first misconception was that I would have to spend ages setting up a different OS like Linux, or buying a mac (which I still would like to do one day, if I'm ever cool enough). Not so, there's a Windows package called InstantRails that just does it. Download the ~ 60Mb zip file, unzip it, and you're ready to go (just like a Mac). This gives you Ruby, Apache, MySQL and PHP. Start it up by launching InstantRails.exe.

There's an initial dialog box that needs slapping out of the way, and then I had to change the port Apache uses, because IIS already uses port 80. I randomly picked 100, and it seemed to work. One can change this in the config file that is accessable from the Instant Rails menu.

One of the things that makes Rails so quick is using conventions for naming, rather than using configuration files. What that means in practise is that your MySQL table names (your MySQL? YourSQL maybe?) have to be plurals, e.g. rabbits. Rails can then sort you out a nice Rabbit class without any bother. Also, the ID column must be called id, so Rails knows it's the ID column. Foreign keys take the format "tablename_id", so the rabbit table might have a foreign key to the hat table hat_id. Simple really. If you've been lumbered with a honking great legacy database, you can still configure it up to use it, but that kind of defeats the object. You might as well go back to C# for that, at least you know how to do that.

Another good thing about Rails is that it enforces the model-view-controller pattern right away. When you create an application, "models", "views" and "controllers" tables are created automatically.

An application is created using a single statement on the command prompt. You should then add your (plural) tables to MySQL. You'll need an Enterprise Manager equivalent for that. I found HeidiSQL to be both suitable and fashionable-sounding.

The next thing to do is to generate some classes. One can "scaffold" these, which seems to mean that it will create default pages for one's CRUD operations. And a listing page. There are two ways of doing this: the first way is to generate the classes "normally", and put a scaffold statement in the controller, and the second is to generate the scaffolding, which puts a load of code in your MVC folders. This is quite useful, as you can see what Ruby actually looks like, and play around with it a bit. To generate the scaffolding from the command prompt, type

ruby script\generate scaffold rabbit

[where rabbit is the singular of your table name]

You should then be able to go to localhost:100/rabbit and see a list of all the rabbits in your table, and links to add, edit, modify and delete rabbits. Now that's magic.

Now you've done that, you can have a bit of a poke about in the code, and change stuff. To change what the page looks like, go to the view. It's a little like "classic" ASP, in that there's code and HTML jumbled up together, but the difference is that the code should only be accessing data from the model, and not doing anything beyond formatting it.

So, there we go. I've created a cool rails app in next to no time. You don't have to be particularly cool to do it, as I've just proved.

Books:





Links:

Ruby on Rails Home
Instant Rails
A proper tutorial
Ruby Language Reference

And here's a demo video:



[Tags: ]

Wednesday, November 08, 2006

I can't believe it!

I've just been to see Borat's movie film, and on the way back I heard on the radio that he's been given a life sentence for terrorism. I didn't think he seemed bright enough to be a terrorist.

[Tags: ]

Tuesday, November 07, 2006

Map of EurotaxGlass's, Crowborough

A couple of people recently have had trouble finding our Crowborough office, as there is no map online. Here's a link to a Google map of EurotaxGlass's in Crowborough.

Thursday, November 02, 2006

Peer-to-peer dynamic AJAX

Video with the most TLAs per minute:



I know what he means about ColdFusion though...

Wednesday, November 01, 2006

Starting the Distributed Transaction Coordinator from C#

The DTC is needed when a Winforms app is calling more than one stored procedure as part of a transaction. As the DTC is just a service, the standard ServiceController class can be used. A reference to System.ServiceProcess must be added first, and the code is as follows:

// Find the Distributed Transaction Controller service

ServiceController service = new ServiceController("MSDTC");

if (service.Status != ServiceControllerStatus.Running)

{

    try

    {

        service.Start();

        // Wait for up to 10 seconds for the service to start

        TimeSpan timeSpan = TimeSpan.FromSeconds(10);

        service.WaitForStatus(ServiceControllerStatus.Running, timeSpan);

    }

    catch (TimeoutException exc)

    {

        MessageBox.Show(exc.Message);

    }

}



[Tags: ]