472,807 Members | 4,448 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,807 software developers and data experts.

Attempted to read or write protected memory

Dear Experts,

I have created a script to extract the Event Logs from the system into an
excel sheet. The logs are separated into 2 worksheets (Application Log and
System Log). After this excel file being created, it will be sent out via
email to the list of recipients.

I run the script on my notebook (also developed on th same machine) it works
fine. However, when I copy all the programs into the server which running on
Windows 2000 sp4 with NET Framework 2.0 installed. The error message that I
received was as follow:

-2147467261
Attempted to read or write protected memory. This is often an indication
that other memory is corrupt.

My program code is as follow:

Imports System.Net.Mail
Imports System.Reflection
Imports System.Runtime.InteropServices
Imports System.IO
Imports System.Diagnostics
Imports Excel

Module Module1
Public strXLFile, strXLNewFile, strOldXLFile, strLogFile As String
Sub Main()
Dim oXL As New Excel.Application
Dim objExcel As Object
Dim objWorkbook As Object

'Dim oNewWBKs As Excel.Workbooks
Dim oNewWBK As Excel.Workbook
Dim oNewAppLogWS As New Excel.Worksheet
Dim oNewSysLogWS As New Excel.Worksheet

Dim iRow As Integer
Dim strComputerName As String

Dim strLogFile As String
Dim objOutputLog As Object

Try
Dim objFSO = CreateObject("Scripting.FileSystemObject")

'Set output log file
strLogFile = objFSO.getSpecialFolder(2).path & "\" &
"EventLogFile.txt"
objOutputLog = New StreamWriter(strLogFile, True)
objOutputLog.WriteLine(vbCrLf & Now() & " : Started")

strComputerName = GetComputerName()
strXLNewFile = objFSO.getSpecialFolder(2).path & "\" &
strComputerName & "-" & Today.ToString("ddMMMyyyy") & "-" &
Now().ToString("HHmm") & ".xls"
'strXLNewFile = "C:\Data\EventLog\" & strComputerName & "-" &
Today.ToString("ddMMMyyyy") & "-" & Now().ToString("HHmm") & ".xls"
objExcel = CreateObject("Excel.Application")
objWorkbook = objExcel.Workbooks.Add
objWorkbook.SaveAs(strXLNewFile)
objExcel.workbooks.close()
objWorkbook = Nothing
objExcel.quit()
objExcel = Nothing

'Create Header for Application Log
oNewWBK = oXL.Workbooks.Open(strXLNewFile)
oNewAppLogWS = oXL.Worksheets("Sheet1")
oNewAppLogWS.Name = "Application Log"
oNewAppLogWS.Range("A1").Value = "Type"
oNewAppLogWS.Range("B1").Value = "Date & Time"
oNewAppLogWS.Range("C1").Value = "Source"
oNewAppLogWS.Range("D1").Value = "Category (Code)"
oNewAppLogWS.Range("E1").Value = "Event ID"
oNewAppLogWS.Range("F1").Value = "User"
oNewAppLogWS.Range("G1").Value = "Computer"
'oNewAppLogWS.Range("H1:O1").Merge()
oNewAppLogWS.Range("H1").Value = "Description"
iRow = 2

'Declare an EventLog and EventLogEntry object
Dim elAppEvent As New System.Diagnostics.EventLog("Application")
Dim elAppEventEntry As System.Diagnostics.EventLogEntry

' Iterate through a collection
For Each elAppEventEntry In elAppEvent.Entries
If Not UCase(elAppEventEntry.EntryType.ToString) =
"INFORMATION" Then
oNewAppLogWS.Cells(iRow, "A") =
elAppEventEntry.EntryType.ToString
oNewAppLogWS.Cells(iRow, "B") =
elAppEventEntry.TimeGenerated.ToString
oNewAppLogWS.Cells(iRow, "C") =
elAppEventEntry.Source.ToString
oNewAppLogWS.Cells(iRow, "D") =
elAppEventEntry.Category.ToString & "(" &
elAppEventEntry.CategoryNumber.ToString & ")"
oNewAppLogWS.Cells(iRow, "E") =
elAppEventEntry.InstanceId.ToString

If elAppEventEntry.UserName Is Nothing Then
oNewAppLogWS.Cells(iRow, "F") = "N/A"
Else
oNewAppLogWS.Cells(iRow, "F") =
elAppEventEntry.UserName.ToString
End If
oNewAppLogWS.Cells(iRow, "G") =
elAppEventEntry.MachineName.ToString
'oNewAppLogWS.Range("H" & iRow & ":O" & iRow).Merge()
oNewAppLogWS.Cells(iRow, "H") =
elAppEventEntry.Message.ToString
iRow = iRow + 1
End If
Next

'Create Header for System Log
oNewSysLogWS = oXL.Worksheets("Sheet2")
oNewSysLogWS.Name = "System Log"
oNewSysLogWS.Range("A1").Value = "Type"
oNewSysLogWS.Range("B1").Value = "Date & Time"
oNewSysLogWS.Range("C1").Value = "Source"
oNewSysLogWS.Range("D1").Value = "Category (Code)"
oNewSysLogWS.Range("E1").Value = "Event ID"
oNewSysLogWS.Range("F1").Value = "User"
oNewSysLogWS.Range("G1").Value = "Computer"
'oNewSysLogWS.Range("H1:O1").Merge()
oNewSysLogWS.Range("H1").Value = "Description"
iRow = 2
'Declare an EventLog and EventLogEntry object
Dim elSysEvent As New System.Diagnostics.EventLog("System")
Dim elSysEventEntry As System.Diagnostics.EventLogEntry
For Each elSysEventEntry In elSysEvent.Entries
If Not UCase(elSysEventEntry.EntryType.ToString) =
"INFORMATION" Then
oNewSysLogWS.Cells(iRow, "A") =
elSysEventEntry.EntryType.ToString
oNewSysLogWS.Cells(iRow, "B") =
elSysEventEntry.TimeGenerated.ToString
oNewSysLogWS.Cells(iRow, "C") =
elSysEventEntry.Source.ToString
oNewSysLogWS.Cells(iRow, "D") =
elSysEventEntry.Category.ToString & "(" &
elSysEventEntry.CategoryNumber.ToString & ")"
oNewSysLogWS.Cells(iRow, "E") =
elSysEventEntry.InstanceId.ToString
If elSysEventEntry.UserName Is Nothing Then
oNewSysLogWS.Cells(iRow, "F") = "N/A"
Else
oNewSysLogWS.Cells(iRow, "F") =
elSysEventEntry.UserName.ToString
End If
oNewSysLogWS.Cells(iRow, "G") =
elSysEventEntry.MachineName.ToString
'oNewSysLogWS.Range("H" & iRow & ":O" & iRow).Merge()
oNewSysLogWS.Cells(iRow, "H") =
elSysEventEntry.Message.ToString
iRow = iRow + 1
End If
Next

oNewWBK.Save()
oNewWBK.Close()

SendMail(strXLNewFile)

Catch ex As Exception
objOutputLog.WriteLine(Err.Number & vbCrLf & ex.Message)

Finally
objOutputLog.writeline(Now() & " Completed")
objOutputLog.Close()

End Try

End Sub

Private Function GetComputerName() As String
Dim objWMI As New clsWMI()
Dim strComputerName As String
With objWMI
strComputerName = .ComputerName
End With
GetComputerName = strComputerName
End Function

Public Sub SendMail(ByVal strXLNewFile As String)
Dim MailClient As New SmtpClient
Dim msg As New Net.Mail.MailMessage
Dim FileAttachment As Attachment
'Dim msgRequestNotification As New Net.Mail.MailMessage
Dim strRecipientEmail As String = "Em******@domain.com"
Dim strSenderEmail As String = "Em******@domain.com"

MailClient.Host = "###.###.###.###"

msg.From = New MailAddress(strSenderEmail)
msg.To.Add(New MailAddress(strRecipientEmail))
msg.Priority = MailPriority.High
msg.Subject = " Event Logs for " & GetComputerName() & " on " & Today
msg.Body = ""

FileAttachment = New Attachment(strXLNewFile)
msg.Attachments.Add(FileAttachment)

MailClient.Send(msg)

End Sub

End Module
Please advise.

Many thanks in advance.

Regards,
SB
May 3 '06 #1
4 7197
Put msvcr71.dll in the system32 directory. It should work.

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"Seok Bee" <se*****@yahoo.com> wrote in message
news:9B**********************************@microsof t.com...
Dear Experts,

I have created a script to extract the Event Logs from the system into an
excel sheet. The logs are separated into 2 worksheets (Application Log and
System Log). After this excel file being created, it will be sent out via
email to the list of recipients.

I run the script on my notebook (also developed on th same machine) it
works
fine. However, when I copy all the programs into the server which running
on
Windows 2000 sp4 with NET Framework 2.0 installed. The error message that
I
received was as follow:

-2147467261
Attempted to read or write protected memory. This is often an indication
that other memory is corrupt.

My program code is as follow:

Imports System.Net.Mail
Imports System.Reflection
Imports System.Runtime.InteropServices
Imports System.IO
Imports System.Diagnostics
Imports Excel

Module Module1
Public strXLFile, strXLNewFile, strOldXLFile, strLogFile As String
Sub Main()
Dim oXL As New Excel.Application
Dim objExcel As Object
Dim objWorkbook As Object

'Dim oNewWBKs As Excel.Workbooks
Dim oNewWBK As Excel.Workbook
Dim oNewAppLogWS As New Excel.Worksheet
Dim oNewSysLogWS As New Excel.Worksheet

Dim iRow As Integer
Dim strComputerName As String

Dim strLogFile As String
Dim objOutputLog As Object

Try
Dim objFSO = CreateObject("Scripting.FileSystemObject")

'Set output log file
strLogFile = objFSO.getSpecialFolder(2).path & "\" &
"EventLogFile.txt"
objOutputLog = New StreamWriter(strLogFile, True)
objOutputLog.WriteLine(vbCrLf & Now() & " : Started")

strComputerName = GetComputerName()
strXLNewFile = objFSO.getSpecialFolder(2).path & "\" &
strComputerName & "-" & Today.ToString("ddMMMyyyy") & "-" &
Now().ToString("HHmm") & ".xls"
'strXLNewFile = "C:\Data\EventLog\" & strComputerName & "-" &
Today.ToString("ddMMMyyyy") & "-" & Now().ToString("HHmm") & ".xls"
objExcel = CreateObject("Excel.Application")
objWorkbook = objExcel.Workbooks.Add
objWorkbook.SaveAs(strXLNewFile)
objExcel.workbooks.close()
objWorkbook = Nothing
objExcel.quit()
objExcel = Nothing

'Create Header for Application Log
oNewWBK = oXL.Workbooks.Open(strXLNewFile)
oNewAppLogWS = oXL.Worksheets("Sheet1")
oNewAppLogWS.Name = "Application Log"
oNewAppLogWS.Range("A1").Value = "Type"
oNewAppLogWS.Range("B1").Value = "Date & Time"
oNewAppLogWS.Range("C1").Value = "Source"
oNewAppLogWS.Range("D1").Value = "Category (Code)"
oNewAppLogWS.Range("E1").Value = "Event ID"
oNewAppLogWS.Range("F1").Value = "User"
oNewAppLogWS.Range("G1").Value = "Computer"
'oNewAppLogWS.Range("H1:O1").Merge()
oNewAppLogWS.Range("H1").Value = "Description"
iRow = 2

'Declare an EventLog and EventLogEntry object
Dim elAppEvent As New
System.Diagnostics.EventLog("Application")
Dim elAppEventEntry As System.Diagnostics.EventLogEntry

' Iterate through a collection
For Each elAppEventEntry In elAppEvent.Entries
If Not UCase(elAppEventEntry.EntryType.ToString) =
"INFORMATION" Then
oNewAppLogWS.Cells(iRow, "A") =
elAppEventEntry.EntryType.ToString
oNewAppLogWS.Cells(iRow, "B") =
elAppEventEntry.TimeGenerated.ToString
oNewAppLogWS.Cells(iRow, "C") =
elAppEventEntry.Source.ToString
oNewAppLogWS.Cells(iRow, "D") =
elAppEventEntry.Category.ToString & "(" &
elAppEventEntry.CategoryNumber.ToString & ")"
oNewAppLogWS.Cells(iRow, "E") =
elAppEventEntry.InstanceId.ToString

If elAppEventEntry.UserName Is Nothing Then
oNewAppLogWS.Cells(iRow, "F") = "N/A"
Else
oNewAppLogWS.Cells(iRow, "F") =
elAppEventEntry.UserName.ToString
End If
oNewAppLogWS.Cells(iRow, "G") =
elAppEventEntry.MachineName.ToString
'oNewAppLogWS.Range("H" & iRow & ":O" & iRow).Merge()
oNewAppLogWS.Cells(iRow, "H") =
elAppEventEntry.Message.ToString
iRow = iRow + 1
End If
Next

'Create Header for System Log
oNewSysLogWS = oXL.Worksheets("Sheet2")
oNewSysLogWS.Name = "System Log"
oNewSysLogWS.Range("A1").Value = "Type"
oNewSysLogWS.Range("B1").Value = "Date & Time"
oNewSysLogWS.Range("C1").Value = "Source"
oNewSysLogWS.Range("D1").Value = "Category (Code)"
oNewSysLogWS.Range("E1").Value = "Event ID"
oNewSysLogWS.Range("F1").Value = "User"
oNewSysLogWS.Range("G1").Value = "Computer"
'oNewSysLogWS.Range("H1:O1").Merge()
oNewSysLogWS.Range("H1").Value = "Description"
iRow = 2
'Declare an EventLog and EventLogEntry object
Dim elSysEvent As New System.Diagnostics.EventLog("System")
Dim elSysEventEntry As System.Diagnostics.EventLogEntry
For Each elSysEventEntry In elSysEvent.Entries
If Not UCase(elSysEventEntry.EntryType.ToString) =
"INFORMATION" Then
oNewSysLogWS.Cells(iRow, "A") =
elSysEventEntry.EntryType.ToString
oNewSysLogWS.Cells(iRow, "B") =
elSysEventEntry.TimeGenerated.ToString
oNewSysLogWS.Cells(iRow, "C") =
elSysEventEntry.Source.ToString
oNewSysLogWS.Cells(iRow, "D") =
elSysEventEntry.Category.ToString & "(" &
elSysEventEntry.CategoryNumber.ToString & ")"
oNewSysLogWS.Cells(iRow, "E") =
elSysEventEntry.InstanceId.ToString
If elSysEventEntry.UserName Is Nothing Then
oNewSysLogWS.Cells(iRow, "F") = "N/A"
Else
oNewSysLogWS.Cells(iRow, "F") =
elSysEventEntry.UserName.ToString
End If
oNewSysLogWS.Cells(iRow, "G") =
elSysEventEntry.MachineName.ToString
'oNewSysLogWS.Range("H" & iRow & ":O" & iRow).Merge()
oNewSysLogWS.Cells(iRow, "H") =
elSysEventEntry.Message.ToString
iRow = iRow + 1
End If
Next

oNewWBK.Save()
oNewWBK.Close()

SendMail(strXLNewFile)

Catch ex As Exception
objOutputLog.WriteLine(Err.Number & vbCrLf & ex.Message)

Finally
objOutputLog.writeline(Now() & " Completed")
objOutputLog.Close()

End Try

End Sub

Private Function GetComputerName() As String
Dim objWMI As New clsWMI()
Dim strComputerName As String
With objWMI
strComputerName = .ComputerName
End With
GetComputerName = strComputerName
End Function

Public Sub SendMail(ByVal strXLNewFile As String)
Dim MailClient As New SmtpClient
Dim msg As New Net.Mail.MailMessage
Dim FileAttachment As Attachment
'Dim msgRequestNotification As New Net.Mail.MailMessage
Dim strRecipientEmail As String = "Em******@domain.com"
Dim strSenderEmail As String = "Em******@domain.com"

MailClient.Host = "###.###.###.###"

msg.From = New MailAddress(strSenderEmail)
msg.To.Add(New MailAddress(strRecipientEmail))
msg.Priority = MailPriority.High
msg.Subject = " Event Logs for " & GetComputerName() & " on " &
Today
msg.Body = ""

FileAttachment = New Attachment(strXLNewFile)
msg.Attachments.Add(FileAttachment)

MailClient.Send(msg)

End Sub

End Module
Please advise.

Many thanks in advance.

Regards,
SB

May 3 '06 #2
Thanks for your reply.

May I know where can I obtain a copy of msvcr71.dll to be put in the
system32 directory?

"vbnetdev" wrote:
Put msvcr71.dll in the system32 directory. It should work.

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"Seok Bee" <se*****@yahoo.com> wrote in message
news:9B**********************************@microsof t.com...
Dear Experts,

I have created a script to extract the Event Logs from the system into an
excel sheet. The logs are separated into 2 worksheets (Application Log and
System Log). After this excel file being created, it will be sent out via
email to the list of recipients.

I run the script on my notebook (also developed on th same machine) it
works
fine. However, when I copy all the programs into the server which running
on
Windows 2000 sp4 with NET Framework 2.0 installed. The error message that
I
received was as follow:

-2147467261
Attempted to read or write protected memory. This is often an indication
that other memory is corrupt.

My program code is as follow:

Imports System.Net.Mail
Imports System.Reflection
Imports System.Runtime.InteropServices
Imports System.IO
Imports System.Diagnostics
Imports Excel

Module Module1
Public strXLFile, strXLNewFile, strOldXLFile, strLogFile As String
Sub Main()
Dim oXL As New Excel.Application
Dim objExcel As Object
Dim objWorkbook As Object

'Dim oNewWBKs As Excel.Workbooks
Dim oNewWBK As Excel.Workbook
Dim oNewAppLogWS As New Excel.Worksheet
Dim oNewSysLogWS As New Excel.Worksheet

Dim iRow As Integer
Dim strComputerName As String

Dim strLogFile As String
Dim objOutputLog As Object

Try
Dim objFSO = CreateObject("Scripting.FileSystemObject")

'Set output log file
strLogFile = objFSO.getSpecialFolder(2).path & "\" &
"EventLogFile.txt"
objOutputLog = New StreamWriter(strLogFile, True)
objOutputLog.WriteLine(vbCrLf & Now() & " : Started")

strComputerName = GetComputerName()
strXLNewFile = objFSO.getSpecialFolder(2).path & "\" &
strComputerName & "-" & Today.ToString("ddMMMyyyy") & "-" &
Now().ToString("HHmm") & ".xls"
'strXLNewFile = "C:\Data\EventLog\" & strComputerName & "-" &
Today.ToString("ddMMMyyyy") & "-" & Now().ToString("HHmm") & ".xls"
objExcel = CreateObject("Excel.Application")
objWorkbook = objExcel.Workbooks.Add
objWorkbook.SaveAs(strXLNewFile)
objExcel.workbooks.close()
objWorkbook = Nothing
objExcel.quit()
objExcel = Nothing

'Create Header for Application Log
oNewWBK = oXL.Workbooks.Open(strXLNewFile)
oNewAppLogWS = oXL.Worksheets("Sheet1")
oNewAppLogWS.Name = "Application Log"
oNewAppLogWS.Range("A1").Value = "Type"
oNewAppLogWS.Range("B1").Value = "Date & Time"
oNewAppLogWS.Range("C1").Value = "Source"
oNewAppLogWS.Range("D1").Value = "Category (Code)"
oNewAppLogWS.Range("E1").Value = "Event ID"
oNewAppLogWS.Range("F1").Value = "User"
oNewAppLogWS.Range("G1").Value = "Computer"
'oNewAppLogWS.Range("H1:O1").Merge()
oNewAppLogWS.Range("H1").Value = "Description"
iRow = 2

'Declare an EventLog and EventLogEntry object
Dim elAppEvent As New
System.Diagnostics.EventLog("Application")
Dim elAppEventEntry As System.Diagnostics.EventLogEntry

' Iterate through a collection
For Each elAppEventEntry In elAppEvent.Entries
If Not UCase(elAppEventEntry.EntryType.ToString) =
"INFORMATION" Then
oNewAppLogWS.Cells(iRow, "A") =
elAppEventEntry.EntryType.ToString
oNewAppLogWS.Cells(iRow, "B") =
elAppEventEntry.TimeGenerated.ToString
oNewAppLogWS.Cells(iRow, "C") =
elAppEventEntry.Source.ToString
oNewAppLogWS.Cells(iRow, "D") =
elAppEventEntry.Category.ToString & "(" &
elAppEventEntry.CategoryNumber.ToString & ")"
oNewAppLogWS.Cells(iRow, "E") =
elAppEventEntry.InstanceId.ToString

If elAppEventEntry.UserName Is Nothing Then
oNewAppLogWS.Cells(iRow, "F") = "N/A"
Else
oNewAppLogWS.Cells(iRow, "F") =
elAppEventEntry.UserName.ToString
End If
oNewAppLogWS.Cells(iRow, "G") =
elAppEventEntry.MachineName.ToString
'oNewAppLogWS.Range("H" & iRow & ":O" & iRow).Merge()
oNewAppLogWS.Cells(iRow, "H") =
elAppEventEntry.Message.ToString
iRow = iRow + 1
End If
Next

'Create Header for System Log
oNewSysLogWS = oXL.Worksheets("Sheet2")
oNewSysLogWS.Name = "System Log"
oNewSysLogWS.Range("A1").Value = "Type"
oNewSysLogWS.Range("B1").Value = "Date & Time"
oNewSysLogWS.Range("C1").Value = "Source"
oNewSysLogWS.Range("D1").Value = "Category (Code)"
oNewSysLogWS.Range("E1").Value = "Event ID"
oNewSysLogWS.Range("F1").Value = "User"
oNewSysLogWS.Range("G1").Value = "Computer"
'oNewSysLogWS.Range("H1:O1").Merge()
oNewSysLogWS.Range("H1").Value = "Description"
iRow = 2
'Declare an EventLog and EventLogEntry object
Dim elSysEvent As New System.Diagnostics.EventLog("System")
Dim elSysEventEntry As System.Diagnostics.EventLogEntry
For Each elSysEventEntry In elSysEvent.Entries
If Not UCase(elSysEventEntry.EntryType.ToString) =
"INFORMATION" Then
oNewSysLogWS.Cells(iRow, "A") =
elSysEventEntry.EntryType.ToString
oNewSysLogWS.Cells(iRow, "B") =
elSysEventEntry.TimeGenerated.ToString
oNewSysLogWS.Cells(iRow, "C") =
elSysEventEntry.Source.ToString
oNewSysLogWS.Cells(iRow, "D") =
elSysEventEntry.Category.ToString & "(" &
elSysEventEntry.CategoryNumber.ToString & ")"
oNewSysLogWS.Cells(iRow, "E") =
elSysEventEntry.InstanceId.ToString
If elSysEventEntry.UserName Is Nothing Then
oNewSysLogWS.Cells(iRow, "F") = "N/A"
Else
oNewSysLogWS.Cells(iRow, "F") =
elSysEventEntry.UserName.ToString
End If
oNewSysLogWS.Cells(iRow, "G") =
elSysEventEntry.MachineName.ToString
'oNewSysLogWS.Range("H" & iRow & ":O" & iRow).Merge()
oNewSysLogWS.Cells(iRow, "H") =
elSysEventEntry.Message.ToString
iRow = iRow + 1
End If
Next

oNewWBK.Save()
oNewWBK.Close()

SendMail(strXLNewFile)

Catch ex As Exception
objOutputLog.WriteLine(Err.Number & vbCrLf & ex.Message)

Finally
objOutputLog.writeline(Now() & " Completed")
objOutputLog.Close()

End Try

End Sub

Private Function GetComputerName() As String
Dim objWMI As New clsWMI()
Dim strComputerName As String
With objWMI
strComputerName = .ComputerName
End With
GetComputerName = strComputerName
End Function

Public Sub SendMail(ByVal strXLNewFile As String)
Dim MailClient As New SmtpClient
Dim msg As New Net.Mail.MailMessage
Dim FileAttachment As Attachment
'Dim msgRequestNotification As New Net.Mail.MailMessage
Dim strRecipientEmail As String = "Em******@domain.com"
Dim strSenderEmail As String = "Em******@domain.com"

MailClient.Host = "###.###.###.###"

msg.From = New MailAddress(strSenderEmail)
msg.To.Add(New MailAddress(strRecipientEmail))
msg.Priority = MailPriority.High
msg.Subject = " Event Logs for " & GetComputerName() & " on " &
Today
msg.Body = ""

FileAttachment = New Attachment(strXLNewFile)
msg.Attachments.Add(FileAttachment)

MailClient.Send(msg)

End Sub

End Module
Please advise.

Many thanks in advance.

Regards,
SB


May 3 '06 #3
email me off list.

ad***@nospamkjmsolutions.com remove no spam.

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"Seok Bee" <se*****@yahoo.com> wrote in message
news:DA**********************************@microsof t.com...
Thanks for your reply.

May I know where can I obtain a copy of msvcr71.dll to be put in the
system32 directory?

"vbnetdev" wrote:
Put msvcr71.dll in the system32 directory. It should work.

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"Seok Bee" <se*****@yahoo.com> wrote in message
news:9B**********************************@microsof t.com...
> Dear Experts,
>
> I have created a script to extract the Event Logs from the system into
> an
> excel sheet. The logs are separated into 2 worksheets (Application Log
> and
> System Log). After this excel file being created, it will be sent out
> via
> email to the list of recipients.
>
> I run the script on my notebook (also developed on th same machine) it
> works
> fine. However, when I copy all the programs into the server which
> running
> on
> Windows 2000 sp4 with NET Framework 2.0 installed. The error message
> that
> I
> received was as follow:
>
> -2147467261
> Attempted to read or write protected memory. This is often an
> indication
> that other memory is corrupt.
>
> My program code is as follow:
>
> Imports System.Net.Mail
> Imports System.Reflection
> Imports System.Runtime.InteropServices
> Imports System.IO
> Imports System.Diagnostics
> Imports Excel
>
> Module Module1
> Public strXLFile, strXLNewFile, strOldXLFile, strLogFile As String
> Sub Main()
> Dim oXL As New Excel.Application
> Dim objExcel As Object
> Dim objWorkbook As Object
>
> 'Dim oNewWBKs As Excel.Workbooks
> Dim oNewWBK As Excel.Workbook
> Dim oNewAppLogWS As New Excel.Worksheet
> Dim oNewSysLogWS As New Excel.Worksheet
>
> Dim iRow As Integer
> Dim strComputerName As String
>
> Dim strLogFile As String
> Dim objOutputLog As Object
>
> Try
> Dim objFSO = CreateObject("Scripting.FileSystemObject")
>
> 'Set output log file
> strLogFile = objFSO.getSpecialFolder(2).path & "\" &
> "EventLogFile.txt"
> objOutputLog = New StreamWriter(strLogFile, True)
> objOutputLog.WriteLine(vbCrLf & Now() & " : Started")
>
> strComputerName = GetComputerName()
> strXLNewFile = objFSO.getSpecialFolder(2).path & "\" &
> strComputerName & "-" & Today.ToString("ddMMMyyyy") & "-" &
> Now().ToString("HHmm") & ".xls"
> 'strXLNewFile = "C:\Data\EventLog\" & strComputerName & "-"
> &
> Today.ToString("ddMMMyyyy") & "-" & Now().ToString("HHmm") & ".xls"
> objExcel = CreateObject("Excel.Application")
> objWorkbook = objExcel.Workbooks.Add
> objWorkbook.SaveAs(strXLNewFile)
> objExcel.workbooks.close()
> objWorkbook = Nothing
> objExcel.quit()
> objExcel = Nothing
>
> 'Create Header for Application Log
> oNewWBK = oXL.Workbooks.Open(strXLNewFile)
> oNewAppLogWS = oXL.Worksheets("Sheet1")
> oNewAppLogWS.Name = "Application Log"
> oNewAppLogWS.Range("A1").Value = "Type"
> oNewAppLogWS.Range("B1").Value = "Date & Time"
> oNewAppLogWS.Range("C1").Value = "Source"
> oNewAppLogWS.Range("D1").Value = "Category (Code)"
> oNewAppLogWS.Range("E1").Value = "Event ID"
> oNewAppLogWS.Range("F1").Value = "User"
> oNewAppLogWS.Range("G1").Value = "Computer"
> 'oNewAppLogWS.Range("H1:O1").Merge()
> oNewAppLogWS.Range("H1").Value = "Description"
> iRow = 2
>
> 'Declare an EventLog and EventLogEntry object
> Dim elAppEvent As New
> System.Diagnostics.EventLog("Application")
> Dim elAppEventEntry As System.Diagnostics.EventLogEntry
>
> ' Iterate through a collection
> For Each elAppEventEntry In elAppEvent.Entries
> If Not UCase(elAppEventEntry.EntryType.ToString) =
> "INFORMATION" Then
> oNewAppLogWS.Cells(iRow, "A") =
> elAppEventEntry.EntryType.ToString
> oNewAppLogWS.Cells(iRow, "B") =
> elAppEventEntry.TimeGenerated.ToString
> oNewAppLogWS.Cells(iRow, "C") =
> elAppEventEntry.Source.ToString
> oNewAppLogWS.Cells(iRow, "D") =
> elAppEventEntry.Category.ToString & "(" &
> elAppEventEntry.CategoryNumber.ToString & ")"
> oNewAppLogWS.Cells(iRow, "E") =
> elAppEventEntry.InstanceId.ToString
>
> If elAppEventEntry.UserName Is Nothing Then
> oNewAppLogWS.Cells(iRow, "F") = "N/A"
> Else
> oNewAppLogWS.Cells(iRow, "F") =
> elAppEventEntry.UserName.ToString
> End If
> oNewAppLogWS.Cells(iRow, "G") =
> elAppEventEntry.MachineName.ToString
> 'oNewAppLogWS.Range("H" & iRow & ":O" &
> iRow).Merge()
> oNewAppLogWS.Cells(iRow, "H") =
> elAppEventEntry.Message.ToString
> iRow = iRow + 1
> End If
> Next
>
> 'Create Header for System Log
> oNewSysLogWS = oXL.Worksheets("Sheet2")
> oNewSysLogWS.Name = "System Log"
> oNewSysLogWS.Range("A1").Value = "Type"
> oNewSysLogWS.Range("B1").Value = "Date & Time"
> oNewSysLogWS.Range("C1").Value = "Source"
> oNewSysLogWS.Range("D1").Value = "Category (Code)"
> oNewSysLogWS.Range("E1").Value = "Event ID"
> oNewSysLogWS.Range("F1").Value = "User"
> oNewSysLogWS.Range("G1").Value = "Computer"
> 'oNewSysLogWS.Range("H1:O1").Merge()
> oNewSysLogWS.Range("H1").Value = "Description"
> iRow = 2
> 'Declare an EventLog and EventLogEntry object
> Dim elSysEvent As New System.Diagnostics.EventLog("System")
> Dim elSysEventEntry As System.Diagnostics.EventLogEntry
> For Each elSysEventEntry In elSysEvent.Entries
> If Not UCase(elSysEventEntry.EntryType.ToString) =
> "INFORMATION" Then
> oNewSysLogWS.Cells(iRow, "A") =
> elSysEventEntry.EntryType.ToString
> oNewSysLogWS.Cells(iRow, "B") =
> elSysEventEntry.TimeGenerated.ToString
> oNewSysLogWS.Cells(iRow, "C") =
> elSysEventEntry.Source.ToString
> oNewSysLogWS.Cells(iRow, "D") =
> elSysEventEntry.Category.ToString & "(" &
> elSysEventEntry.CategoryNumber.ToString & ")"
> oNewSysLogWS.Cells(iRow, "E") =
> elSysEventEntry.InstanceId.ToString
> If elSysEventEntry.UserName Is Nothing Then
> oNewSysLogWS.Cells(iRow, "F") = "N/A"
> Else
> oNewSysLogWS.Cells(iRow, "F") =
> elSysEventEntry.UserName.ToString
> End If
> oNewSysLogWS.Cells(iRow, "G") =
> elSysEventEntry.MachineName.ToString
> 'oNewSysLogWS.Range("H" & iRow & ":O" &
> iRow).Merge()
> oNewSysLogWS.Cells(iRow, "H") =
> elSysEventEntry.Message.ToString
> iRow = iRow + 1
> End If
> Next
>
> oNewWBK.Save()
> oNewWBK.Close()
>
> SendMail(strXLNewFile)
>
> Catch ex As Exception
> objOutputLog.WriteLine(Err.Number & vbCrLf & ex.Message)
>
> Finally
> objOutputLog.writeline(Now() & " Completed")
> objOutputLog.Close()
>
> End Try
>
> End Sub
>
> Private Function GetComputerName() As String
> Dim objWMI As New clsWMI()
> Dim strComputerName As String
> With objWMI
> strComputerName = .ComputerName
> End With
> GetComputerName = strComputerName
> End Function
>
> Public Sub SendMail(ByVal strXLNewFile As String)
> Dim MailClient As New SmtpClient
> Dim msg As New Net.Mail.MailMessage
> Dim FileAttachment As Attachment
> 'Dim msgRequestNotification As New Net.Mail.MailMessage
> Dim strRecipientEmail As String = "Em******@domain.com"
> Dim strSenderEmail As String = "Em******@domain.com"
>
> MailClient.Host = "###.###.###.###"
>
> msg.From = New MailAddress(strSenderEmail)
> msg.To.Add(New MailAddress(strRecipientEmail))
> msg.Priority = MailPriority.High
> msg.Subject = " Event Logs for " & GetComputerName() & " on " &
> Today
> msg.Body = ""
>
> FileAttachment = New Attachment(strXLNewFile)
> msg.Attachments.Add(FileAttachment)
>
> MailClient.Send(msg)
>
> End Sub
>
> End Module
>
>
> Please advise.
>
> Many thanks in advance.
>
> Regards,
> SB


May 3 '06 #4
Hi,
I have the same issue.
I have created an application that is using VS2005, .Net Fr 2.0, MSOffice
2003 and I
am trying to run it on Windows 2000 profesional with MS Office 2000.

When I try to open an Excel file I have the same error:Attempted to read or
write protected memory. This is often an indication that other memory is
corrupt.

I've put the msvcr71.dll file into system32 but no luck.
Please let me know if any other advice.

Thank you,
"Seok Bee" wrote:
Dear Experts,

I have created a script to extract the Event Logs from the system into an
excel sheet. The logs are separated into 2 worksheets (Application Log and
System Log). After this excel file being created, it will be sent out via
email to the list of recipients.

I run the script on my notebook (also developed on th same machine) it works
fine. However, when I copy all the programs into the server which running on
Windows 2000 sp4 with NET Framework 2.0 installed. The error message that I
received was as follow:

-2147467261
Attempted to read or write protected memory. This is often an indication
that other memory is corrupt.

My program code is as follow:

Imports System.Net.Mail
Imports System.Reflection
Imports System.Runtime.InteropServices
Imports System.IO
Imports System.Diagnostics
Imports Excel

Module Module1
Public strXLFile, strXLNewFile, strOldXLFile, strLogFile As String
Sub Main()
Dim oXL As New Excel.Application
Dim objExcel As Object
Dim objWorkbook As Object

'Dim oNewWBKs As Excel.Workbooks
Dim oNewWBK As Excel.Workbook
Dim oNewAppLogWS As New Excel.Worksheet
Dim oNewSysLogWS As New Excel.Worksheet

Dim iRow As Integer
Dim strComputerName As String

Dim strLogFile As String
Dim objOutputLog As Object

Try
Dim objFSO = CreateObject("Scripting.FileSystemObject")

'Set output log file
strLogFile = objFSO.getSpecialFolder(2).path & "\" &
"EventLogFile.txt"
objOutputLog = New StreamWriter(strLogFile, True)
objOutputLog.WriteLine(vbCrLf & Now() & " : Started")

strComputerName = GetComputerName()
strXLNewFile = objFSO.getSpecialFolder(2).path & "\" &
strComputerName & "-" & Today.ToString("ddMMMyyyy") & "-" &
Now().ToString("HHmm") & ".xls"
'strXLNewFile = "C:\Data\EventLog\" & strComputerName & "-" &
Today.ToString("ddMMMyyyy") & "-" & Now().ToString("HHmm") & ".xls"
objExcel = CreateObject("Excel.Application")
objWorkbook = objExcel.Workbooks.Add
objWorkbook.SaveAs(strXLNewFile)
objExcel.workbooks.close()
objWorkbook = Nothing
objExcel.quit()
objExcel = Nothing

'Create Header for Application Log
oNewWBK = oXL.Workbooks.Open(strXLNewFile)
oNewAppLogWS = oXL.Worksheets("Sheet1")
oNewAppLogWS.Name = "Application Log"
oNewAppLogWS.Range("A1").Value = "Type"
oNewAppLogWS.Range("B1").Value = "Date & Time"
oNewAppLogWS.Range("C1").Value = "Source"
oNewAppLogWS.Range("D1").Value = "Category (Code)"
oNewAppLogWS.Range("E1").Value = "Event ID"
oNewAppLogWS.Range("F1").Value = "User"
oNewAppLogWS.Range("G1").Value = "Computer"
'oNewAppLogWS.Range("H1:O1").Merge()
oNewAppLogWS.Range("H1").Value = "Description"
iRow = 2

'Declare an EventLog and EventLogEntry object
Dim elAppEvent As New System.Diagnostics.EventLog("Application")
Dim elAppEventEntry As System.Diagnostics.EventLogEntry

' Iterate through a collection
For Each elAppEventEntry In elAppEvent.Entries
If Not UCase(elAppEventEntry.EntryType.ToString) =
"INFORMATION" Then
oNewAppLogWS.Cells(iRow, "A") =
elAppEventEntry.EntryType.ToString
oNewAppLogWS.Cells(iRow, "B") =
elAppEventEntry.TimeGenerated.ToString
oNewAppLogWS.Cells(iRow, "C") =
elAppEventEntry.Source.ToString
oNewAppLogWS.Cells(iRow, "D") =
elAppEventEntry.Category.ToString & "(" &
elAppEventEntry.CategoryNumber.ToString & ")"
oNewAppLogWS.Cells(iRow, "E") =
elAppEventEntry.InstanceId.ToString

If elAppEventEntry.UserName Is Nothing Then
oNewAppLogWS.Cells(iRow, "F") = "N/A"
Else
oNewAppLogWS.Cells(iRow, "F") =
elAppEventEntry.UserName.ToString
End If
oNewAppLogWS.Cells(iRow, "G") =
elAppEventEntry.MachineName.ToString
'oNewAppLogWS.Range("H" & iRow & ":O" & iRow).Merge()
oNewAppLogWS.Cells(iRow, "H") =
elAppEventEntry.Message.ToString
iRow = iRow + 1
End If
Next

'Create Header for System Log
oNewSysLogWS = oXL.Worksheets("Sheet2")
oNewSysLogWS.Name = "System Log"
oNewSysLogWS.Range("A1").Value = "Type"
oNewSysLogWS.Range("B1").Value = "Date & Time"
oNewSysLogWS.Range("C1").Value = "Source"
oNewSysLogWS.Range("D1").Value = "Category (Code)"
oNewSysLogWS.Range("E1").Value = "Event ID"
oNewSysLogWS.Range("F1").Value = "User"
oNewSysLogWS.Range("G1").Value = "Computer"
'oNewSysLogWS.Range("H1:O1").Merge()
oNewSysLogWS.Range("H1").Value = "Description"
iRow = 2
'Declare an EventLog and EventLogEntry object
Dim elSysEvent As New System.Diagnostics.EventLog("System")
Dim elSysEventEntry As System.Diagnostics.EventLogEntry
For Each elSysEventEntry In elSysEvent.Entries
If Not UCase(elSysEventEntry.EntryType.ToString) =
"INFORMATION" Then
oNewSysLogWS.Cells(iRow, "A") =
elSysEventEntry.EntryType.ToString
oNewSysLogWS.Cells(iRow, "B") =
elSysEventEntry.TimeGenerated.ToString
oNewSysLogWS.Cells(iRow, "C") =
elSysEventEntry.Source.ToString
oNewSysLogWS.Cells(iRow, "D") =
elSysEventEntry.Category.ToString & "(" &
elSysEventEntry.CategoryNumber.ToString & ")"
oNewSysLogWS.Cells(iRow, "E") =
elSysEventEntry.InstanceId.ToString
If elSysEventEntry.UserName Is Nothing Then
oNewSysLogWS.Cells(iRow, "F") = "N/A"
Else
oNewSysLogWS.Cells(iRow, "F") =
elSysEventEntry.UserName.ToString
End If
oNewSysLogWS.Cells(iRow, "G") =
elSysEventEntry.MachineName.ToString
'oNewSysLogWS.Range("H" & iRow & ":O" & iRow).Merge()
oNewSysLogWS.Cells(iRow, "H") =
elSysEventEntry.Message.ToString
iRow = iRow + 1
End If
Next

oNewWBK.Save()
oNewWBK.Close()

SendMail(strXLNewFile)

Catch ex As Exception
objOutputLog.WriteLine(Err.Number & vbCrLf & ex.Message)

Finally
objOutputLog.writeline(Now() & " Completed")
objOutputLog.Close()

End Try

End Sub

Private Function GetComputerName() As String
Dim objWMI As New clsWMI()
Dim strComputerName As String
With objWMI
strComputerName = .ComputerName
End With
GetComputerName = strComputerName
End Function

Public Sub SendMail(ByVal strXLNewFile As String)
Dim MailClient As New SmtpClient
Dim msg As New Net.Mail.MailMessage
Dim FileAttachment As Attachment
'Dim msgRequestNotification As New Net.Mail.MailMessage
Dim strRecipientEmail As String = "Em******@domain.com"
Dim strSenderEmail As String = "Em******@domain.com"

MailClient.Host = "###.###.###.###"

msg.From = New MailAddress(strSenderEmail)
msg.To.Add(New MailAddress(strRecipientEmail))
msg.Priority = MailPriority.High
msg.Subject = " Event Logs for " & GetComputerName() & " on " & Today
msg.Body = ""

FileAttachment = New Attachment(strXLNewFile)
msg.Attachments.Add(FileAttachment)

MailClient.Send(msg)

End Sub

End Module
Please advise.

Many thanks in advance.

Regards,
SB

May 10 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: hiralparikh | last post by:
Hi, I am using .NET 2.0 and trying to use a function from a native DLL file. Here is the syntax that I am using: definition: public static extern String getPwd(String strServerName, String...
3
by: XJ | last post by:
Hi experts, i try to use vb.net 2005 call dll, then give me "Attempted to read or write protected memory.This is often an indication that other memory is corrupt". i have chk some message others...
1
by: ianyian | last post by:
Hi experts, i try to use vb.net 2005 call C++ dll, then give me "Attempted to read or write protected memory.This is often an indication that other memory is corrupt". i have chk some message...
2
by: Ilkka | last post by:
I have created an C++ application with Windows Forms, ADO and SQL server 2005. Now I need to change something and started debugging the code. Then suddenly I receive an error. "An unhandled...
2
by: Pieter | last post by:
Hi, Since 10 days (the first time was the 10th of november) I have some weird exception happening in an application here: All (except 1 of the total of 5) users had this error now 1 of 2 times...
2
by: adypoly | last post by:
Hi guys... I am having a typical problem in using one of the native dll in C# I'll explain what am trying to do, I've a dll written in C language which i am trying to include in my C# project,...
6
by: Sugandh Jain | last post by:
Hi, I am getting the error message Attempted to read or write protected memory. This is often an indication that other memory is corrupt. It was not coming until yet, for around 2 months. Now,...
6
by: Scott Gravenhorst | last post by:
Windows XP SP3 My application is set to open a SaveFile dialog when an exit is requested. When I click the app's close button, the save dialog opens, but when I click to change the folder, the...
3
by: sriram347 | last post by:
Hi I am a newbie to ASP.NET. I developed a web page (project type is web application) and I keep getting this error. B]Error message : "System.AccessViolation Exception attempted to read or...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.