简体   繁体   English

获取 Azure Servicebus 队列错误“参数 namespaceConnectionString 为空或空白。\\r\\n参数名称:namespaceConnectionString”

[英]Getting Azure Servicebus Queue Error "The argument namespaceConnectionString is null or white space. \r\nParameter name: namespaceConnectionString"

I am facing the issue.我正面临这个问题。 I have created the ServiceBus Queue on Azure portal.我在 Azure 门户上创建了 ServiceBus 队列。 Also I have written the .Net core application for send the data.我还编写了用于发送数据的 .Net 核心应用程序。 When I Send the data to queue from my application then I have got the below error message at the connection string when QueueClient initialize :当我将数据从我的应用程序发送到队列时,当 QueueClient 初始化时,我在连接字符串中收到以下错误消息:

"The argument namespaceConnectionString is null or white space.\\r\\nParameter name: namespaceConnectionString" "参数 namespaceConnectionString 为空或空白。\\r\\n参数名称:namespaceConnectionString"

I have google as well and tried all the options like remove the EntityPath from the connection string.我也有谷歌并尝试了所有选项,例如从连接字符串中删除 EntityPath。 Also tried the different Target Framework version (till 3.1) as well currently using .Net Core 2.2.还尝试了不同的 Target Framework 版本(直到 3.1)以及目前使用 .Net Core 2.2。

Please help me.请帮我。

using AzureTestProject.Interface;
using Microsoft.Azure.ServiceBus;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AzureQueueService
{
    public class ServiceBusQueue  
    {
        private  QueueClient _queueClient;
        private readonly IConfiguration _configuration;
        private const string QUEUE_NAME = "devicetestqueue";
        private string _connectionString;

        // Payload =  {"Id":"1","Type":"Device1","SerialNumber":"10001"}
        public async Task SendMessage(object payload)
        {
            try
            {
                _queueClient = new QueueClient(
                _configuration.GetConnectionString("Endpoint=sb://Subscription.servicebus.windows.net/;SharedAccessKeyName=DeviceTestQueueListenAccessKey;SharedAccessKey=hjklgtfapinznyx2gSnPqngQgIa9p7AxeihLoBz8+Sc=;EntityPath=devicetestqueue"),
                QUEUE_NAME);

                string data = JsonConvert.SerializeObject(payload);
                Message message = new Message(Encoding.UTF8.GetBytes(data));

                await _queueClient.SendAsync(message);
            }
            catch (Exception ex)
            {
                throw;
            }            
        }
    }
}

I have got the solution as below :我得到了如下解决方案:

 public async Task SendMessage(object payload)
        {
            try
            {                
                _queueClient = new QueueClient("Endpoint=sb://Subscription.servicebus.windows.net/;SharedAccessKeyName=DeviceTestQueueListenAccessKey;SharedAccessKey=hjklgtfapinznyx2gSnPqngQgIa9p7AxeihLoBz8+Sc=;EntityPath=devicetestqueue", QUEUE_NAME);
                string data = JsonConvert.SerializeObject(payload);
                Message message = new Message(Encoding.UTF8.GetBytes(data));

                await _queueClient.SendAsync(message);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure:{“目录路径的语法无效” \\ r \\ n参数名称:initialConfiguration”}错误 - Azure: {“Invalid syntax for directory path ''\r\nParameter name: initialConfiguration”} Error 参数“ sql”不能为null,为空或仅包含空格。 首次创建数据库时 - The argument 'sql' cannot be null, empty or contain only white space. When first create the database 值不能为空,参数名称来源 - Value cannot be null, r nparameter name source 值不能为null或为空。\ r \ nParameter name:name - Value cannot be null or empty.\r\nParameter name: name ResourceDictionary中的运行时错误:{“Key不能为null。\\ r \\ nParameter name:key”} - Runtime Error in ResourceDictionary: {“Key cannot be null.\r\nParameter name: key”} 根据xml错误{“值不能为空。\\ r \\ n参数名称:元素”}创建对象 - Creating objects from xml error {“Value cannot be null.\r\nParameter name: element”} 值不能为空。\\ r \\ n参数名称:输入 - Value cannot be null.\r\nParameter name: input “值不能为空。\\r\\n参数名称:文本” - “Value cannot be null.\r\nParameter name: text” {“值不能为空。\\ r \\ nParameter name:s”} - {“Value cannot be null.\r\nParameter name: s”} 参数“名称”不能为 null、为空或仅包含空格 - The argument 'name' cannot be null, empty or contain only white space
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM