Multi version of the an application
I have an existing application (C#/Win forms). I need to add functionality to the application such that is can launch another instance of its own and make some of the controls in the form disabled. It may be very easy t开发者_运维技巧o implement this using simple inheritance or may be some if else loop , but this application has to inform its dependent assemblies of the state. I am looking for the most elegant to do this. I am not keen on modifying the current files, just adding on to the existing functionality. Any suggestions will be of great help.
You can start another instance like this:
System.Diagnostics.Process.Start(
System.Reflection.Assembly.GetEntryAssembly().Location,
"disable");
You can test the command line argument with code like this in the form constructor:
public Form1() {
InitializeComponent();
if (Environment.CommandLine.ToLower() == "disble") {
button1.Enabled = false;
// etc..
}
}
To debug this, you must use Project + Properties, Debug tab, untick "Enable the Visual Studio hosting process".
精彩评论