I'm not sure what you are trying to accomplish with your app.config file. An app.config that provides the value you want need only contain
="1.0"="utf-8"
<configuration>
<appSettings>
<add key="DefaultTimer" value="90" />
</appSettings>
</configuration>
You must include System.Configuration in the usings at the top of the program and and in the References.
The following is a rewrite of your program.
using System;
using System.Configuration;
using System.Reflection;
using System.Text;
namespace Timer
{
static class Program
{
[STAThread]
static void Main ( )
{
if ( Environment.CommandLine.Contains ( "?" ) )
{
StringBuilder sb = new StringBuilder ( );
sb.AppendFormat (
"Timer v {0} " +
"Command Line Options: /Timer:<timeinminutes> " +
"Current value is: {1}",
Assembly.GetEntryAssembly ( ).
GetName ( ).Version.ToString ( ),
ConfigurationManager.AppSettings [
"DefaultTimer" ] );
}
}
}
}
Some thoughts:
- Do not declare auxiliary variables (e.g., assm, assmName, ver, etc.) unless you will use them later in the application.
- Use the StringBuilder AppendFormat method rather than invoking the StringBuilder Append method multiple times.
- I do not recognize .Properties in your code.
Hope that helps.