你可能想要删除我的一些额外的废话......但这应该可以解决问题:
public string GetCommandLineArguments( Project p )
{
string returnValue = null;
try
{
if ( ( Instance != null ) )
{
Properties props = p.ConfigurationManager.ActiveConfiguration.Properties;
try
{
returnValue = props.Item( "StartArguments" ).Value.ToString();
}
catch
{
returnValue = props.Item( "CommandArguments" ).Value.ToString();
// for c++
}
}
}
catch ( Exception ex )
{
Logger.Info( ex.ToString() );
}
return returnValue;
}
这些也可能会有所帮助:(因此您可以查看项目具有哪些属性及其值)
public void ShowProjectProperties( Project p )
{
try
{
if ( ( Instance != null ) )
{
string msg = Path.GetFileNameWithoutExtension( p.FullName ) + " has the following properties:" + Environment.NewLine + Environment.NewLine;
Properties props = p.ConfigurationManager.ActiveConfiguration.Properties;
List< string > values = props.Cast< Property >().Select( prop => SafeGetPropertyValue( prop) ).ToList();
msg += string.Join( Environment.NewLine, values );
MessageDialog.ShowMessage( msg );
}
}
catch ( Exception ex )
{
Logger.Info( ex.ToString() );
}
}
public string SafeGetPropertyValue( Property prop )
{
try
{
return string.Format( "{0} = {1}", prop.Name, prop.Value );
}
catch ( Exception ex )
{
return string.Format( "{0} = {1}", prop.Name, ex.GetType() );
}
}