1.首先,啓用查詢字符串參數傳遞給應用程序。
2.訪問查詢字符串這樣
private NameValueCollection GetQueryString()
{
if (ApplicationDeployment.IsNetworkDeployed)
{
try
{
string rawQueryString = String.Empty;
rawQueryString = ApplicationDeployment.CurrentDeployment.ActivationUri.Query;
NameValueCollection queryString;
try
{
queryString = HttpUtility.ParseQueryString(ApplicationDeployment.CurrentDeployment.ActivationUri.Query);
}
catch (Exception ex)
{
throw new Exception("Unauthorized access!");
}
return queryString;
}
catch (Exception ex)
{
if (ApplicationDeployment.CurrentDeployment == null)
{
throw new Exception("Deployment error");
}
else if (ApplicationDeployment.CurrentDeployment.ActivationUri == null)
{
throw new Exception("Unable to read data");
}
else
{
throw new Exception("Error with deployment: " + ex.Message);
}
}
}
else
{
throw new Exception("This application may not be accessed directly");
}
}
3.更新的app.config
App.Config change value
哪一步失敗?你在應用程序中成功接收到查詢字符串了嗎? – Zesty
讓我知道它是否適合你。 – Zesty
感謝@Zesty的快速回復。我擔心的是,如果我更改配置文件,它將導致更改散列文件,因此我們可能無法使用clickonce更新它。我會檢查你的答案,並讓你知道結果。再次感謝。 – LittleOne