C# Clickonce:applicationUri为null,允许传递URL参数设置为true

C# Clickonce:applicationUri为null,允许传递URL参数设置为true,c#,.net,clickonce,C#,.net,Clickonce,我有一个通过clickonce部署的winforms应用程序,希望获取querystring参数,以便发送带有参数的可单击链接。我已尝试使用ApplicationDeployment.CurrentDeployment.ActivationUri和AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData,但这两个都不返回查询字符串。在VisualStudio中(或通过MageUI设置),“允许将URL参

我有一个通过clickonce部署的winforms应用程序,希望获取querystring参数,以便发送带有参数的可单击链接。我已尝试使用ApplicationDeployment.CurrentDeployment.ActivationUri和AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData,但这两个都不返回查询字符串。在VisualStudio中(或通过MageUI设置),“允许将URL参数传递给应用程序”设置为true,并且此设置包含在部署清单中

我是否缺少允许将querystring参数传递给应用程序的附加设置

注意:我通过windows资源管理器或IE调用已部署的应用程序,URI为:文件:C:\Users\\Deploy\TestApp.application?testarg123。这会引起问题吗

谢谢

static void Main(){
...
Uri activationData = ApplicationDeployment.CurrentDeployment.ActivationUri;
                    MessageBox.Show(activationData.ToString());
...
}
根据,设置
TrustUrlParameters=true
并使用完整URL(而不是UNC路径)启动程序应允许访问查询字符串参数

尝试将文件路径设置为URL,为查询参数设置一个值,然后使用
HttpUtility.ParseQueryString
访问该值。示例:

用于启动应用程序的URL

file:///C:\Users\\Deploy\TestApp.application?testarg=123
方法检索查询字符串参数

private NameValueCollection GetQueryStringParameters()
{
    NameValueCollection nameValueTable = new NameValueCollection();

    if (ApplicationDeployment.IsNetworkDeployed)
    {
        string queryString = ApplicationDeployment.CurrentDeployment.ActivationUri.Query;
        nameValueTable = HttpUtility.ParseQueryString(queryString);
    }

    return (nameValueTable);
}
根据,设置
TrustUrlParameters=true
并使用完整URL(而不是UNC路径)启动程序应允许访问查询字符串参数

尝试将文件路径设置为URL,为查询参数设置一个值,然后使用
HttpUtility.ParseQueryString
访问该值。示例:

用于启动应用程序的URL

file:///C:\Users\\Deploy\TestApp.application?testarg=123
方法检索查询字符串参数

private NameValueCollection GetQueryStringParameters()
{
    NameValueCollection nameValueTable = new NameValueCollection();

    if (ApplicationDeployment.IsNetworkDeployed)
    {
        string queryString = ApplicationDeployment.CurrentDeployment.ActivationUri.Query;
        nameValueTable = HttpUtility.ParseQueryString(queryString);
    }

    return (nameValueTable);
}

它仅通过http等网络部署可用,您可以检查属性ApplicationDeployment.IsNetworkDeployed(如果是真的)。它仅通过http等网络部署可用。如果是真的,您可以检查属性ApplicationDeployment.IsNetworkDeployed(如果是真的)。感谢您的响应。。我已经更新了代码以使用此方法检索querystring,但仍然没有数据。。。如果我使用`activationData=String.Join(“,”,GetQueryStringParameters().AllKeys);MessageBox.Show(激活数据);`要检索信息,返回的数据为空。用于打开程序的URL是什么?您是否也设置了
TrustUrlParameters=true
?我正在使用file:///C:\用户\..\Deploy\Test.application?testarg=123启动。至于TrustUrlParameters,我在VisualStudio中选中了相应的框(属性>发布>选项>允许将URL参数传递给应用程序)。部署的.应用程序清单也有一行“`”。还有其他地方需要设置吗?谢谢您的回复。。我已经更新了代码以使用此方法检索querystring,但仍然没有数据。。。如果我使用`activationData=String.Join(“,”,GetQueryStringParameters().AllKeys);MessageBox.Show(激活数据);`要检索信息,返回的数据为空。用于打开程序的URL是什么?您是否也设置了
TrustUrlParameters=true
?我正在使用file:///C:\用户\..\Deploy\Test.application?testarg=123启动。至于TrustUrlParameters,我在VisualStudio中选中了相应的框(属性>发布>选项>允许将URL参数传递给应用程序)。部署的.应用程序清单也有一行“`”。还有其他地方需要设置吗?