Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 服务总线令牌具有无效的签名_C#_Azure_Servicebus - Fatal编程技术网

C# 服务总线令牌具有无效的签名

C# 服务总线令牌具有无效的签名,c#,azure,servicebus,C#,Azure,Servicebus,我正在尝试创建一个基于 我收到一条错误消息Generic:InvalidSignature:令牌具有无效签名 static void Main(string[] args) { ServiceHost sh = new ServiceHost(typeof(ProblemSolver)); sh.AddServiceEndpoint( typeof(IProblemSolver), new NetTcpBinding(),

我正在尝试创建一个基于

我收到一条错误消息Generic:InvalidSignature:令牌具有无效签名

static void Main(string[] args)
{
        ServiceHost sh = new ServiceHost(typeof(ProblemSolver));

        sh.AddServiceEndpoint(
           typeof(IProblemSolver), new NetTcpBinding(),
           "net.tcp://tjservicebus.servicebus.windows.net/solver");

        Console.WriteLine("Add Binding End Point");

        var key = "MYKEY";

        sh.AddServiceEndpoint(
           typeof(IProblemSolver), new NetTcpRelayBinding(),
           ServiceBusEnvironment.CreateServiceUri("sb", "tjservicebus", "solver"))
            .Behaviors.Add(new TransportClientEndpointBehavior
            {
                TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider("RootManageSharedAccessKey", key)
            });

        sh.Open();

        Console.WriteLine("Press ENTER to close");
        Console.ReadLine();

        sh.Close();
    }
错误消息出现在sh.Open()点


有人能帮忙吗?

看起来我已经解决了这个问题,键中的正斜杠没有被转义

下一个问题是我现在得到以下,但想排除我们的防火墙第一

<Error>
  <Code>400</Code>
    <Detail>
      Cannot send message because the service endpoint hosted at the specified address uses a binding that cannot be accessed over HTTP. TrackingId:7e6402e1-a250-482b-967e-a4d1860bca54_G37,TimeStamp:11/12/2015 9:09:15 AM
    </Detail>
</Error>

我遇到了与第一次相同的错误


但我的问题是我使用了连接字符串作为键。然后我更改了密钥的最后一个参数
SharedAccessKey
,错误已被解决。

我也收到了此错误消息,结果与Andy Zhang的问题相同

我删除了服务总线以测试自动部署,并且仍然在连接字符串中引用旧的SharedAccessKey进行连接,但在重新部署后,这一点发生了变化

我们将连接字符串存储在Key Vault中,因此我必须更改其中的连接字符串以解决问题。

特别是在本地环境中,我在Visual Studio打开时更改了环境变量,其中一个是服务总线连接字符串

Visual Studio将在启动时缓存环境变量


关闭Visual Studio,重新打开并再次运行解决了我的问题。

您能解释一下您所做的更改吗?