Reputation: 27384
I have an installer class for my program (that resides within the application project). I also have a class that dictates where my data save locations are which uses Application.ProductName
obviously whilst in the installer this does not come back as my product name but it comes back as something like Windows Installer - Unicode
which is expected.
How do I then, in the installer class, retrieve the actual product name? Would I have to hardcode it or can I tweak my installer class?
Upvotes: 0
Views: 1984
Reputation: 716
Assembly.GetExecutingAssembly().GetName().Name
You can get the application name inside the installer class using Assembly.GetExecutingAssembly().GetName().Name
, If you also want to get the user-selected directory for installation. You can do that with Assembly.GetExecutingAssembly().Location
.
Upvotes: 0
Reputation: 49165
You can pass data to your custom action (i.e. installer class) in setup project using CustomActionData property. Now installer class can access them via Context.Parameters. For your requirement, you can pass product name as some parameter - for example, CustomActionData value could be /prodName="[ProductName]"
and then access it via Context.Parameters["prodName"]
. The special syntax [property name]
is used to pass various installer properties (to custom action) - see this for various pre-define properties available. This will help in understanding how to pass custom data.
Upvotes: 6