I have the following situation. There is some very common class in my application that contains a static readonly field called “BinDirectory” that holds the path to the bin directory. Other fields in this class, which are static readonly too, use this value to as a base to their value. On the current version BinDirectory is initialized to hold the directory where the code is running (i.e. Assembly.GetExecutingAssembly().CodeBase). I want to extend this class to initialize BinDirectory to hold the “TargetDir” from the installer context when it is run from my application installer. I can change BinDirectory to be simply static but I don’t want to, since it will make me do lots of changes to a class that is common in my app. Can somebody suggest an elegant solution to this problem?
I have the following situation. There is some very common class in my application
Share
This is what AppConfigs are for. In your AppSettings section, add a new key called
BinDirectory. You can re-write your class as:Finally, as one of the last steps in your installation process, you can change the BinDirectory to point to any directory you want. So now this value is determined entirely by the installer context.