473,385 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 7256
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.