tags:

views:

90

answers:

3

I've made an simple installation class:

[RunInstaller(true)]
public class MyCustumAction : Installer
{
    public override void Install(System.Collections.IDictionary stateSaver)
    {
        base.Install(stateSaver);
        string value = Context.Parameters["targetdir"];

        throw new Exception("Contact?? " + value);

        WriteLog(value);
    }

    private void WriteLog(string message)
    {
        using(FileStream f = File.Create(@"C:\ik ben nieuw.txt"))
        {
            using (StreamWriter w = new StreamWriter(f))
            {
                w.WriteLine("Dag van installatie: " + DateTime.Now.ToString());
                w.WriteLine(message);

            }
        }
    }
}

In my Setup project I've done the following:

  • Add project output - primary output of my assembly
  • Add a Custom Action on the Install directory (Custom Actions view)
  • Set CustumActionData to '/targetdir="[TARGETDIR]\"'
  • Build my assembly and build the setup project

During the installation, the Exception is not thrown. Why not? It seems that my class isn't invoked. What am I doing wrong here?

UPDATE

When I create a seperate project with only the installer class in it and add this ont to my project ouput and set the custum action properly, I do get the exception!

Now I am wondering why this same file doesn't get invoked in my own (winforms) assembly..

A: 

You need to decorate your class with the RunInstaller attribute. This provides more detail.

http://msdn.microsoft.com/en-us/library/system.componentmodel.runinstallerattribute.aspx

Steve Danner
I have the attribute, but I still don't get an exception.
Martijn
See my startpost.
Martijn
A: 

Have you decorated your class with

[RunInstaller(true)]

?

Dmitry Ornatsky
Yes I have and still I don't get the exception
Martijn
See my startpost.
Martijn
A: 

I have some notes from when I was trying to solve this same problem:

to install on Vista ensure you initiate from the Setup.exe, not from the Msi

Even if you are on XP perhaps you should try running from the setup.exe

hawbsl