CentOS obs直播RTMP協議推流到Nginx流媒體伺服器到VUE使用HLS直播

来源:https://www.cnblogs.com/ingstyle/archive/2022/09/26/16731420.html
-Advertisement-
Play Games

1. 發佈打包前端管理平臺(ant-design-vue) 2. 發佈打包後端(.NET6-WebApi) .NET6 webAPI orm: free sql 資料庫:mysql5.7 3. 發佈打包H5端(uni) 播放器使用: import Player from 'xgplayer'; // ...


1. 發佈打包前端管理平臺(ant-design-vue)

2. 發佈打包後端(.NET6-WebApi)

.NET6 webAPI

orm: free sql

資料庫:mysql5.7

3. 發佈打包H5端(uni)

播放器使用:

import Player from 'xgplayer'; // npm install xgplayer
import HlsJsPlayer from "xgplayer-hls.js"; // 直播流m3u8(hls) npm install xgplayer-hls.js

4. 伺服器安裝.NET6環境:https://learn.microsoft.com/zh-cn/dotnet/core/install/linux-centos

安裝 .NET 之前,請運行以下命令,將 Microsoft 包簽名密鑰添加到受信任密鑰列表,並添加 Microsoft 包存儲庫。 打開終端並運行以下命令:
sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
安裝 SDK .NET SDK 使你可以通過 .NET 開發應用。 如果安裝 .NET SDK,則無需安裝相應的運行時。 若要安裝 .NET SDK,請運行以下命令:
sudo yum install dotnet-sdk-6.0
安裝運行時 通過 ASP.NET Core 運行時,可以運行使用 .NET 開發且未提供運行時的應用。 以下命令將安裝 ASP.NET Core 運行時,這是與 .NET 最相容的運行時。 在終端中,運行以下命令:  
sudo yum install aspnetcore-runtime-6.0

 

5. 伺服器安裝寶塔:https://www.bt.cn/new/download.html

yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh ed8484bec

6. 伺服器安裝supervisor進程守護

supervisord是服務相關的命令
supervisorctl是客戶端相關的命令

安裝命令:

yum install -y supervisor

查看狀態:

supervisord -v 

卸載:

yum -y remove supervisor

在/etc創建文件目錄supervisor

在/etc/supervisor下創建文件目錄supervisord.d

在/etc/supervisor下上傳文件supervisord.conf,內容如下:

; Sample supervisor config file.

[unix_http_server]
file=/run/supervisor/supervisor.sock   ; (the path to the socket file)
;chmod=0700                 ; sockef file mode (default 0700)
;chown=nobody:nogroup       ; socket file uid:gid owner
;username=user              ; (default is no username (open server))
;password=123               ; (default is no password (open server))

[inet_http_server]         ; inet (TCP) server disabled by default
port=*:9001        ; (ip_address:port specifier, *:port for all iface)
;username=user              ; (default is no username (open server))
;password=123               ; (default is no password (open server))

[supervisord]
logfile=/www/log/supervisor/supervisord.log  ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB       ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10          ; (num of main logfile rotation backups;default 10)
loglevel=info               ; (log level;default info; others: debug,warn,trace)
pidfile=/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false              ; (start in foreground if true;default false)
minfds=1024                 ; (min. avail startup file descriptors;default 1024)
minprocs=200                ; (min. avail process descriptors;default 200)
;umask=022                  ; (process file creation umask;default 022)
;user=chrism                 ; (default is current user, required if root)
;identifier=supervisor       ; (supervisord identifier, default is 'supervisor')
;directory=/tmp              ; (default is not to cd during start)
;nocleanup=true              ; (don't clean up tempfiles at start;default false)
;childlogdir=/tmp            ; ('AUTO' child log dir, default $TEMP)
;environment=KEY=value       ; (key value pairs to add to environment)
;strip_ansi=false            ; (strip ansi escape codes in logs; def. false)

; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///run/supervisor/supervisor.sock ; use a unix:// URL  for a unix socket
serverurl=http://*:9001 ; use an http:// url to specify an inet socket
;username=chris              ; should be same as http_username if set
;password=123                ; should be same as http_password if set
;prompt=mysupervisor         ; cmd line prompt (default "supervisor")
;history_file=~/.sc_history  ; use readline history if available

; The below sample program section shows all possible program subsection values,
; create one or more 'real' program: sections to be able to control them under
; supervisor.

;[program:theprogramname]
;command=/bin/cat              ; the program (relative uses PATH, can take args)
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
;numprocs=1                    ; number of processes copies to start (def 1)
;directory=/tmp                ; directory to cwd to before exec (def no cwd)
;umask=022                     ; umask for process (default None)
;priority=999                  ; the relative start priority (default 999)
;autostart=true                ; start at supervisord start (default: true)
;autorestart=true              ; retstart at unexpected quit (default: true)
;startsecs=10                  ; number of secs prog must stay running (def. 1)
;startretries=3                ; max # of serial start failures (default 3)
;exitcodes=0,2                 ; 'expected' exit codes for process (default 0,2)
;stopsignal=QUIT               ; signal used to kill process (default TERM)
;stopwaitsecs=10               ; max num secs to wait b4 SIGKILL (default 10)
;user=chrism                   ; setuid to this UNIX account to run the program
;redirect_stderr=true          ; redirect proc stderr to stdout (default false)
;stdout_logfile=/a/path        ; stdout log path, NONE for none; default AUTO
;stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stdout_logfile_backups=10     ; # of stdout logfile backups (default 10)
;stdout_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
;stdout_events_enabled=false   ; emit events on stdout writes (default false)
;stderr_logfile=/a/path        ; stderr log path, NONE for none; default AUTO
;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups=10     ; # of stderr logfile backups (default 10)
;stderr_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
;stderr_events_enabled=false   ; emit events on stderr writes (default false)
;environment=A=1,B=2           ; process environment additions (def no adds)
;serverurl=AUTO                ; override serverurl computation (childutils)

; The below sample eventlistener section shows all possible
; eventlistener subsection values, create one or more 'real'
; eventlistener: sections to be able to handle event notifications
; sent by supervisor.

;[eventlistener:theeventlistenername]
;command=/bin/eventlistener    ; the program (relative uses PATH, can take args)
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
;numprocs=1                    ; number of processes copies to start (def 1)
;events=EVENT                  ; event notif. types to subscribe to (req'd)
;buffer_size=10                ; event buffer queue size (default 10)
;directory=/tmp                ; directory to cwd to before exec (def no cwd)
;umask=022                     ; umask for process (default None)
;priority=-1                   ; the relative start priority (default -1)
;autostart=true                ; start at supervisord start (default: true)
;autorestart=unexpected        ; restart at unexpected quit (default: unexpected)
;startsecs=10                  ; number of secs prog must stay running (def. 1)
;startretries=3                ; max # of serial start failures (default 3)
;exitcodes=0,2                 ; 'expected' exit codes for process (default 0,2)
;stopsignal=QUIT               ; signal used to kill process (default TERM)
;stopwaitsecs=10               ; max num secs to wait b4 SIGKILL (default 10)
;user=chrism                   ; setuid to this UNIX account to run the program
;redirect_stderr=true          ; redirect proc stderr to stdout (default false)
;stdout_logfile=/a/path        ; stdout log path, NONE for none; default AUTO
;stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stdout_logfile_backups=10     ; # of stdout logfile backups (default 10)
;stdout_events_enabled=false   ; emit events on stdout writes (default false)
;stderr_logfile=/a/path        ; stderr log path, NONE for none; default AUTO
;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups        ; # of stderr logfile backups (default 10)
;stderr_events_enabled=false   ; emit events on stderr writes (default false)
;environment=A=1,B=2           ; process environment additions
;serverurl=AUTO                ; override serverurl computation (childutils)

; The below sample group section shows all possible group values,
; create one or more 'real' group: sections to create "heterogeneous"
; process groups.

;[group:thegroupname]
;programs=progname1,progname2  ; each refers to 'x' in [program:x] definitions
;priority=999                  ; the relative start priority (default 999)

; The [include] section can just contain the "files" setting.  This
; setting can list multiple files (separated by whitespace or
; newlines).  It can also contain wildcards.  The filenames are
; interpreted as relative to this file.  Included files *cannot*
; include files themselves.

[include]
files = supervisord.d/*.conf ;這行預設是載入/etc/supervisord.d/目錄內所有conf尾碼的配置,喜歡用ini的可以改成ini
supervisord.conf

在/etc/supervisor/supervisord.d下上傳文件xx.conf,內容如下:

[program:appname]
command=dotnet appname.dll --urls=http://*:5000   ;要執行的命令
directory=/www/api ;命令執行的目錄
environment=ASPNETCORE__ENVIRONMENT=Production ;環境變數
user=root  ;進程執行的用戶身份
stopsignal=INT
autostart=true ;是否自動啟動
autorestart=true ;是否自動重啟
startsecs=3 ;自動重啟間隔
stderr_logfile=/www/log/appname.err.log ;標準錯誤日誌
stdout_logfile=/www/log/appname.out.log ;標準輸出日誌
[supervisord]
[supervisorctl]

執行啟動命令:

supervisord -c /etc/supervisor/supervisord.conf

啟動成功後:執行下麵命令查看,會出現一個

ps aux|grep supervisord
root     11589  0.0  0.0 112828   988 pts/0    S+   16:57   0:00 grep --color=auto supervisord
root     30510  0.0  0.4 245472 17220 ?        Ss   16:12   0:00 /usr/bin/python /usr/bin/supervisord -c /etc/supervisor/supervisord.conf

啟動程式:

supervisorctl start  appname
supervisorctl stop  appname

查看狀態:

supervisorctl status
appname    RUNNING   pid 20538, uptime 0:24:24

查看狀態:瀏覽器輸入:http://*:9001/

 

 查看埠以及appanme運行進程

lsof -i:5000
ps -f |grep appname
 配置Supervisor開機啟動
systemctl enable supervisord.service
 檢查是否開機啟動
systemctl is-enabled supervisord

如果啟動錯誤,查看日誌

supervisorctl tail dcapi stdout

 

 log日誌地址:/www/log/supervisor/supervisord.log

遇到錯誤:Unlinking stale socket /run/supervisor/supervisor.sock

解決辦法:

執行命令:

nlink /run/supervisor/supervisor.sock

 

7. 寶塔安裝Mysql5.7

 

8. 伺服器安裝Nginx(基於RTMP模式的)

沒有git請輸入以下命令

yum -y install git

開始下載nginx-rtmp,記住cd到一個盤符進行下載,建議cd ~,也可以直接從git下載瞭然後複製上去/www/server/nginx/nginx-rtmp-module

git clone https://github.com/arut/nginx-rtmp-module.git

修改配置文件:添加內容:--add-module=/root/nginx-rtmp-module

vim /www/server/panel/install/nginx.sh

可以下載到本地修改,然後上傳到伺服器路徑下:/www/server/panel/install/nginx.sh

修改位置:./configure --add-module=/root/nginx-rtmp-module --user=www ........................

 

 

使用sh命令安裝

sh /www/server/panel/install/nginx.sh install1.22

9. Nginx配置 ,修改寶塔》軟體管理》Nginx1.22管理》配置修改如下:

user  www www;
worker_processes auto;
error_log  /www/wwwlogs/nginx_error.log  crit;
pid        /www/server/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;

stream {
    log_format tcp_format '$time_local|$remote_addr|$protocol|$status|$bytes_sent|$bytes_received|$session_time|$upstream_addr|$upstream_bytes_sent|$upstream_bytes_received|$upstream_connect_time';
  
    access_log /www/wwwlogs/tcp-access.log tcp_format;
    error_log /www/wwwlogs/tcp-error.log;
    include /www/server/panel/vhost/nginx/tcp/*.conf;
}

events
    {
        use epoll;
        worker_connections 51200;
        multi_accept on;
    }
#RTMP服務,新增部分:
rtmp_auto_push on;
rtmp{
    server{
        listen 1935;        #服務埠
        chunk_size 4096;    #數據傳輸塊的大小
        
        application vod{
            play ./vod;   #視頻文件存放位置
        }
        application live{
            live on;                     #開啟直播
            hls on;              
            hls_path /www/m3u8File;          
            hls_fragment 5s;             #每個視頻切片的時長
            hls_playlist_length 16s;
            recorder myRecord {
                    record_path /rec;
            record all manual;
                    record_suffix -%Y-%m-%d-%H_%M_%S.flv;
            }
            hls_continuous on;          #連續模式
            hls_cleanup on;             #對多餘的切片進行刪除
            hls_nested on;              #嵌套模式
        }
    }
}
#RTMP服務,新增完畢


http
    {
        include       mime.types;
        #include luawaf.conf;

        include proxy.conf;

        default_type  application/octet-stream;

        server_names_hash_bucket_size 512;
        client_header_buffer_size 32k;
        large_client_header_buffers 4 32k;
        client_max_body_size 50m;

        sendfile   on;
        tcp_nopush on;

        keepalive_timeout 60;

        tcp_nodelay on;

        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
        fastcgi_buffer_size 64k;
        fastcgi_buffers 4 64k;
        fastcgi_busy_buffers_size 128k;
        fastcgi_temp_file_write_size 256k;
        fastcgi_intercept_errors on;

        gzip on;
        gzip_min_length  1k;
        gzip_buffers     4 16k;
        gzip_http_version 1.1;
        gzip_comp_level 2;
        gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
        gzip_vary on;
        gzip_proxied   expired no-cache no-store private auth;
        gzip_disable   "MSIE [1-6]\.";

        limit_conn_zone $binary_remote_addr zone=perip:10m;
        limit_conn_zone $server_name zone=perserver:10m;

        server_tokens off;
        access_log off;

server
    {
        listen 888;
        server_name phpmyadmin;
        index index.html index.htm index.php;
        root  /www/server/phpmyadmin;

        #error_page   404   /404.html;
        include enable-php.conf;

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /\.
        {
            deny all;
        } 
        access_log  /www/wwwlogs/access.log;
    }
include /www/server/panel/vhost/nginx/*.conf;
}
RTMP-Nginx配置

找到某個80埠的Nginx配置,修改:

server
{
    listen 80;
    server_name xxxxxxx;
    index index.php index.html index.htm default.php default.htm default.html;
    root /www/wwwroot/live;

    #SSL-START SSL相關配置,請勿刪除或修改下一行帶註釋的404規則
    #error_page 404/404.html;
    #SSL-END

    #ERROR-PAGE-START  錯誤頁配置,可以註釋、刪除或修改
    #error_page 404 /404.html;
    #error_page 502 /502.html;
    #ERROR-PAGE-END

    #PHP-INFO-START  PHP引用配置,可以註釋或修改
    include enable-php-00.conf;
    #PHP-INFO-END
    try_files $uri $uri/ /index.html;
    #REWRITE-START URL重寫規則引用,修改後將導致面板設置的偽靜態規則失效
    include /www/server/panel/vhost/rewrite/www.live.com.conf;
    #REWRITE-END

    #禁止訪問的文件或目錄
    location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
    {
        return 404;
    }

    #一鍵申請SSL證書驗證目錄相關設置
    location ~ \.well-known{
        allow all;
    }

    #禁止在證書驗證目錄放入敏感文件
    if ( $uri ~ "^/\.well-known/.*\.(php|jsp|py|js|css|lua|ts|go|zip|tar\.gz|rar|7z|sql|bak)$" ) {
        return 403;
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
        expires      30d;
        error_log /dev/null;
        access_log /dev/null;
    }

    location ~ .*\.(js|css)?$
    {
        expires      12h;
        error_log /dev/null;
        access_log /dev/null;
    }

#新增部分
    location /live{
            types{
                #m3u8 type設置
                application/vnd.apple.mpegurl m3u8;
                #ts分片文件設置
                video/mp2t ts;
            }
              #訪問許可權開啟,否則訪問這個地址會報403
                        autoindex on;
                        
            #指向訪問m3u8文件目錄
            alias /www/m3u8File;
            expires -1;
            add_header Cache-Control no-cache;
            #防止跨域問題
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';  
        }
         location /control{
            rtmp_control all;
        }
        
        location /stat{
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }
        location /stat.xsl{
            root ./nginx-rtmp-module;
        }
#新增完畢
    access_log  /www/wwwlogs/www.live.com.log;
    error_log  /www/wwwlogs/www.live.com.error.log;
}
拉流配置

在Nginx伺服器位置創建一個目錄:/www/server/panel/m3u8File

10. 開始直播及推流

OBS推流配置服務地址:rtmp://127.0.0.1:1935/live

串流密鑰:001

然後開始推流,在伺服器地址/www/server/panel/m3u8File下麵會生成001的文件目錄,然後001文件目錄裡面會出現很多*.ts文件,以及一個index.mu38文件

拉流地址: http://127.0.0.1/live/001/index.m3u8

拉流地址:rtmp://127.0.0.1:1935/live/001

拉流地址註意埠

本地測試可以使用VLC media player軟體

 

彪悍的人生不需要解釋,彪悍的代碼不需要註釋。
您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 前言 大家早好、午好、晚好吖~ 知識點: 爬蟲基本流程 保存海量漫畫數據 requests的使用 base64解碼 開發環境: 版 本:python 3.8 編輯器:pycharm requests: pip install requests parsel: pip install parsel 如 ...
  • 上一篇文章我們學習了使用註解開發,但還沒有完全脫離xml的配置,現在我們來學習JavaConfig配置來代替xml的配置,實現完全註解開發。 下麵我們用一個簡單的例子來進行學習。 一、首先建立兩個實體類 User: package com.jms.pojo; import org.springfra ...
  • 服務註冊中心 Nacos 官網:home (nacos.io) nacos-server下載地址:Releases · alibaba/nacos (github.com) 第一步:運行nacos-server nacos-server-2.1.1\nacos\bin 目錄下打開命令行視窗,輸入st ...
  • 順序存儲二叉樹的概念 從數據存儲來看,數組存儲方式和樹的存儲方式可以相互轉換,即數組可以轉換成樹,樹也可以轉換成數組, 看下麵的示意圖。 要求: 右圖的二叉樹的結點,要求以數組的方式來存放 arr : [1, 2, 3, 4, 5, 6, 6] 要求在遍曆數組 arr 時,仍然可以以前序遍歷,中序遍 ...
  • 函數 1.字元串函數 #(1)add() 對兩個數組的元素進行字元串連接 import numpy as np print(np.char.add(["xiaodu"],["good"])) print(np.char.add(["xiaodu","dudu"],["good","nice"])) ...
  • 事情是這樣的:今天晚上,女朋友讓我十二點催她睡覺。 不過,可是我實在太困了,熬不下去…… 是吧?女朋友哪有睡覺重要? 但,女朋友的命令,我是不敢違抗的…… 但是睡覺也不能缺! 這時候我們該怎麼辦呢?是時候讓Python登場了! Python登場這次我們來做一個自動發送微信的程式,在深夜十二點的時候給 ...
  • 1、初衷 開發中經常需要做一些介面的簽名生成和校驗工作,最開始的時候都是每個介面去按照約定單獨實現,久而久之就變的非常難維護,因此就琢磨怎麼能夠寫了一個比較通用的簽名生成工具。 2、思路 採用鏈式調用的方式,使得簽名的步驟可以動態拼湊組合。 3、直接看效果 //設置數據源 var signSourc ...
  • .Net7 的到來的同時,也帶來了 C# 11,而令我最期待的就是 C# 11 的 原始字元串了,當我知道這個的時候,簡直比過年還要開心。 非原始字元串 首先我們看看現在寫字元串的方式 var str = @" 雪莉:""有人在嗎?"" 神樂:""他們有事出去了,你有什麼困擾呢? 萬事屋神樂為您服務 ...
一周排行
    -Advertisement-
    Play Games
  • 概述:在C#中,++i和i++都是自增運算符,其中++i先增加值再返回,而i++先返回值再增加。應用場景根據需求選擇,首碼適合先增後用,尾碼適合先用後增。詳細示例提供清晰的代碼演示這兩者的操作時機和實際應用。 在C#中,++i 和 i++ 都是自增運算符,但它們在操作上有細微的差異,主要體現在操作的 ...
  • 上次發佈了:Taurus.MVC 性能壓力測試(ap 壓測 和 linux 下wrk 壓測):.NET Core 版本,今天計劃準備壓測一下 .NET 版本,來測試並記錄一下 Taurus.MVC 框架在 .NET 版本的性能,以便後續持續優化改進。 為了方便對比,本文章的電腦環境和測試思路,儘量和... ...
  • .NET WebAPI作為一種構建RESTful服務的強大工具,為開發者提供了便捷的方式來定義、處理HTTP請求並返迴響應。在設計API介面時,正確地接收和解析客戶端發送的數據至關重要。.NET WebAPI提供了一系列特性,如[FromRoute]、[FromQuery]和[FromBody],用 ...
  • 原因:我之所以想做這個項目,是因為在之前查找關於C#/WPF相關資料時,我發現講解圖像濾鏡的資源非常稀缺。此外,我註意到許多現有的開源庫主要基於CPU進行圖像渲染。這種方式在處理大量圖像時,會導致CPU的渲染負擔過重。因此,我將在下文中介紹如何通過GPU渲染來有效實現圖像的各種濾鏡效果。 生成的效果 ...
  • 引言 上一章我們介紹了在xUnit單元測試中用xUnit.DependencyInject來使用依賴註入,上一章我們的Sample.Repository倉儲層有一個批量註入的介面沒有做單元測試,今天用這個示例來演示一下如何用Bogus創建模擬數據 ,和 EFCore 的種子數據生成 Bogus 的優 ...
  • 一、前言 在自己的項目中,涉及到實時心率曲線的繪製,項目上的曲線繪製,一般很難找到能直接用的第三方庫,而且有些還是定製化的功能,所以還是自己繪製比較方便。很多人一聽到自己畫就害怕,感覺很難,今天就分享一個完整的實時心率數據繪製心率曲線圖的例子;之前的博客也分享給DrawingVisual繪製曲線的方 ...
  • 如果你在自定義的 Main 方法中直接使用 App 類並啟動應用程式,但發現 App.xaml 中定義的資源沒有被正確載入,那麼問題可能在於如何正確配置 App.xaml 與你的 App 類的交互。 確保 App.xaml 文件中的 x:Class 屬性正確指向你的 App 類。這樣,當你創建 Ap ...
  • 一:背景 1. 講故事 上個月有個朋友在微信上找到我,說他們的軟體在客戶那邊隔幾天就要崩潰一次,一直都沒有找到原因,讓我幫忙看下怎麼回事,確實工控類的軟體環境複雜難搞,朋友手上有一個崩潰的dump,剛好丟給我來分析一下。 二:WinDbg分析 1. 程式為什麼會崩潰 windbg 有一個厲害之處在於 ...
  • 前言 .NET生態中有許多依賴註入容器。在大多數情況下,微軟提供的內置容器在易用性和性能方面都非常優秀。外加ASP.NET Core預設使用內置容器,使用很方便。 但是筆者在使用中一直有一個頭疼的問題:服務工廠無法提供請求的服務類型相關的信息。這在一般情況下並沒有影響,但是內置容器支持註冊開放泛型服 ...
  • 一、前言 在項目開發過程中,DataGrid是經常使用到的一個數據展示控制項,而通常表格的最後一列是作為操作列存在,比如會有編輯、刪除等功能按鈕。但WPF的原始DataGrid中,預設只支持固定左側列,這跟大家習慣性操作列放最後不符,今天就來介紹一種簡單的方式實現固定右側列。(這裡的實現方式參考的大佬 ...