你可能會想刪除我的一些多餘的廢話...但是這應該做的伎倆:
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());
}
}
這對您的問題有幫助嗎? – Derek