vb.net錯(cuò)誤日志文檔,vb往日志文件中寫日志

VB.NET做的程序在其它機(jī)器上運(yùn)行時(shí)出現(xiàn)問題,求助!

缺少運(yùn)行庫

網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)公司!專注于網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、微信平臺(tái)小程序開發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了商河免費(fèi)建站歡迎大家使用!

裝上.NETframework

和帶上引用的插件(工程屬性那有個(gè)引用頁)

.

VB.NET里這個(gè)錯(cuò)誤怎么處理?“frmEditor”是“WindowsApplication1”中的類型,不能用作表達(dá)式。

最好換一個(gè)窗體名稱(NAME),因?yàn)檫@可能是由于FRMEDITOR已經(jīng)是VB。NET的一個(gè)已定義的類型,可能是自己不小心新建了一個(gè)窗體,也有可能是因?yàn)橄到y(tǒng)定義了一個(gè)FRMEDITOR類型。

好像換了窗體名稱不會(huì)有什么大問題的。

vb.net 中如何進(jìn)行文件的讀寫

一般來講asp.net的服務(wù)器運(yùn)行應(yīng)用所用的賬號(hào)只有對(duì)應(yīng)用所在目錄(放網(wǎng)頁的目錄)的訪問權(quán)限,你可以把文件存儲(chǔ)在應(yīng)用所在目錄或者子目錄試試。

My.Computer.FileSystem.WriteAllText(Server.MapPath("") “\" Now.toString("yyyyMMdd") ".txt", "URL:XXXXXX查詢完成,匹配成功!" vbCrLf, true, System.Text.Encoding.Default)

在vb.net 中,記錄系統(tǒng)錯(cuò)誤日志這個(gè)功能怎么實(shí)現(xiàn)

Public Sub ShowError(strModule As String, strProcedure As String, lngErrorNumber As Long, strErrorDescription As String, showMsg As String)

'

'錯(cuò)誤處理中心過程,寫數(shù)據(jù)庫日志表或?qū)懭罩疚募?/p>

'

'strModule '模塊名稱

'strProcedure '過程名稱

'lngErrorNumber '錯(cuò)誤ID號(hào)

'strErrorDescription '錯(cuò)誤描述

'showMsg '是否顯示本過程內(nèi)錯(cuò)誤顯示信息(值:"Y" or "N")

'Error表結(jié)構(gòu)(f001 (Date)發(fā)生時(shí)間, f002 (nvarchar50)模塊名稱, f003 (nvarchar50)過程名稱, f004 (nvarchar50)錯(cuò)誤ID號(hào), _

f005 (nvarchar300)錯(cuò)誤描述,f006 (nvarchar50)版 本 號(hào), f007 (nvarchar50)用戶名稱, f008 (nvarchar50)網(wǎng)卡地址

'ErrorCode表結(jié)構(gòu) f001 (nvarchar20)錯(cuò)誤代碼, f002 (nvarchar255)錯(cuò)誤信息, f003 (numeric9)錯(cuò)誤級(jí)別

' 級(jí)別說明: '10'以下,一般錯(cuò)誤,不影響操作

' '11-20',嚴(yán)重錯(cuò)誤,不能操作,程序執(zhí)行退出

On Error GoTo ErrorHandle

Dim strMessage As String

Dim strCaption As String

Dim sVer As String

Dim intLogFile As Integer

Dim Res As New ADODB.Recordset

Dim ResErrorCode As New ADODB.Recordset

Dim strSQL As String

'對(duì)應(yīng)錯(cuò)誤號(hào),從ErrorCode表中找到對(duì)應(yīng)的錯(cuò)誤信息,0-1000 錯(cuò)誤號(hào)保留給VB

DBOpen ResErrorCode, "select * from errorcode where f001='" lngErrorNumber "'"

If Not (ResErrorCode.EOF Or ResErrorCode.BOF) Then

strMessage = ResErrorCode.Fields("f002")

If ResErrorCode.Fields("f003") 10 Then

MsgBox "產(chǎn)生一個(gè)嚴(yán)重錯(cuò)誤,可能影響到系統(tǒng)的可操作性,請(qǐng)立即聯(lián)系本系統(tǒng)開發(fā)人員!", vbCritical, "嚴(yán)重錯(cuò)誤"

End If

End If

'寫錯(cuò)誤入文件----------------------------

intLogFile = FreeFile

Open App.Path "\" strIni.LogFile For Append As #intLogFile

Print #intLogFile, "***錯(cuò)誤"; VBA.Now "*** " "Version:" _

str$(App.Major) "." str$(App.Minor) "." Format(App.Revision, "0000")

Print #intLogFile, "Error: " lngErrorNumber

Print #intLogFile, "Description: " strErrorDescription

Print #intLogFile, "Module: " strModule

Print #intLogFile, "Procedure: " strProcedure

Print #intLogFile, ""

Close #intLogFile

If Len(strMessage) 2 Then strErrorDescription = strMessage

strMessage = "錯(cuò)誤: " "(" lngErrorNumber ")" strErrorDescription vbCrLf vbCrLf _

"模塊:" strModule "; 過程:" strProcedure

sVer = Trim(str$(App.Major) "." str$(App.Minor) "." _

Format(App.Revision, "0000"))

strCaption = "錯(cuò)誤 Version: " sVer

'寫錯(cuò)誤入數(shù)據(jù)庫表--------------------------

strSQL = "insert into error(f001,f002,f003,f004,f005,f006,f007,f008) values(" _

DateFmtB VBA.Now DateFmtE "," _

IIf(Len(Trim(strModule)) = 0, "null", "'" strModule "'") "," _

IIf(Len(Trim(strProcedure)) = 0, "null", "'" strProcedure "'") "," _

IIf(Len(Trim(lngErrorNumber)) = 0, "null", "'" lngErrorNumber "'") "," _

IIf(Len(Trim(strErrorDescription)) = 0, "null", "'" Replace(strErrorDescription, "'", "") "'") "," _

IIf(Len(Trim(sVer)) = 0, "null", "'" sVer "'") "," _

IIf(Len(Trim(sUserName)) = 0, "null", "'" sUserName "'") "," _

IIf(Len(Trim(sVer)) = 0, "null", "'" EthernetNO "'") ")"

Cn.Execute strSQL

'是否顯示未知錯(cuò)誤信息

If Trim(UCase(showMsg)) = "Y" Then MsgBox strMessage, vbCritical, strCaption

PROC_EXIT:

Set Res = Nothing

Set ResErrorCode = Nothing

Exit Sub

ErrorHandle:

Resume Next

本文名稱:vb.net錯(cuò)誤日志文檔,vb往日志文件中寫日志
網(wǎng)站鏈接:http://muchs.cn/article10/phijgo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站設(shè)計(jì)網(wǎng)站內(nèi)鏈、全網(wǎng)營銷推廣ChatGPT、微信公眾號(hào)、搜索引擎優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)