vs项目发布时提示类似Default-Web.config Connection String”参数不能为 Null 或空的报错问题

参考地址:

http://stackoverflow.com/questions/28996604/the-defaultconnection-web-config-connection-string-argument-cannot-be-null-or


Create a Parameters.xml file in the Project root with the following content:

<?xml version="1.0" encoding="utf-8" ?>
<parameters>
  <parameter name="DefaultConnection-Web.config Connection String"
      description="DefaultConnection"
      defaultValue="Server=tcp:x.database.windows.net,1433;Database=x_db;User ID=x@y;Password=z;Trusted_Connection=False;etc." tags="" />
</parameters>

意思就是在项目的要目录下,创建一个 Parameters.xml 名称的文件,内容就是上面的xml。

改成自己的名称:



然后发布就不会报错了,我也不知道这是怎么回事,应该是用来更新服务器上的连接串的,也可以选择不更新。


以下是一个简单的 ESP32-C3 ESP-IDF 4.3.5 示例程序,它将作为 TCP 客户端连接到指定的 IP 地址,并循环收发数据。如果连接断开,它将尝试重新连接。 ```c #include <stdio.h> #include <string.h> #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_wifi.h" #include "esp_system.h" #include "esp_event.h" #include "esp_log.h" #include "esp_netif.h" #include "esp_tls.h" #include "lwip/sockets.h" #include "lwip/dns.h" #include "lwip/netdb.h" #define WIFI_SSID "your_wifi_ssid" #define WIFI_PASSWORD "your_wifi_password" #define HOST_IP_ADDR "10.0.0.2" #define HOST_PORT 1234 #define TAG "TCP_CLIENT" static int s_retry_num = 0; static void wifi_event_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data) { switch (event_id) { case WIFI_EVENT_STA_START: esp_wifi_connect(); break; case WIFI_EVENT_STA_DISCONNECTED: if (s_retry_num < 3) { esp_wifi_connect(); s_retry_num++; ESP_LOGI(TAG, "retry to connect to the AP"); } break; default: break; } } static void tcp_client_task(void* arg) { char rx_buffer[128]; char tx_buffer[128]; int sock = -1; struct sockaddr_in server_addr; while (1) { // Wait for Wi-Fi connection xEventGroupWaitBits(wifi_event_group, WIFI_CONNECTED_BIT, false, true, portMAX_DELAY); // Create socket sock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); if (sock < 0) { ESP_LOGE(TAG, "Failed to create socket"); break; } // Set server address memset(&server_addr, 0, sizeof(server_addr)); server_addr.sin_family = AF_INET; server_addr.sin_addr.s_addr = inet_addr(HOST_IP_ADDR); server_addr.sin_port = htons(HOST_PORT); // Connect to server if (connect(sock, (struct sockaddr*)&server_addr, sizeof(server_addr)) != 0) { ESP_LOGE(TAG, "Failed to connect to server"); close(sock); continue; } ESP_LOGI(TAG, "Connected to server"); while (1) { // Receive data from server int rx_len = recv(sock, rx_buffer, sizeof(rx_buffer) - 1, 0); if (rx_len < 0) { ESP_LOGE(TAG, "Failed to receive data"); break; } else if (rx_len == 0) { ESP_LOGI(TAG, "Server disconnected"); break; } rx_buffer[rx_len] = '\0'; ESP_LOGI(TAG, "Received: %s", rx_buffer); // Send data to server sprintf(tx_buffer, "Hello, server!"); int tx_len = send(sock, tx_buffer, strlen(tx_buffer), 0); if (tx_len < 0) { ESP_LOGE(TAG, "Failed to send data"); break; } } close(sock); } vTaskDelete(NULL); } void app_main(void) { // Initialize Wi-Fi tcpip_adapter_init(); wifi_event_group = xEventGroupCreate(); esp_event_loop_create_default(); wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); esp_wifi_init(&cfg); esp_wifi_set_mode(WIFI_MODE_STA); esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config); esp_wifi_start(); // Register Wi-Fi event handler esp_event_handler_instance_t instance_any_id; esp_event_handler_instance_t instance_got_ip; esp_event_handler_instance_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL, &instance_any_id); esp_event_handler_instance_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &wifi_event_handler, NULL, &instance_got_ip); // Wait for Wi-Fi connection xEventGroupWaitBits(wifi_event_group, WIFI_CONNECTED_BIT, false, true, portMAX_DELAY); // Start TCP client task xTaskCreate(tcp_client_task, "tcp_client_task", 4096, NULL, 5, NULL); } ``` 请注意,此示例程序假定您已经将 Wi-Fi 配置为连接到指定的 SSID,并已经设置了 Wi-Fi 密码。如果您还没有这样做,请将 `WIFI_SSID` 和 `WIFI_PASSWORD` 宏定义替换为您自己的 SSID 和密码。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值