Chapter 13:The test for RegistryPermissions failed
Why the objLog.WriteEntry are always successful???
================================================== ==============
Private Sub btnTestRegistryPermissions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTestRegistryPermissions.Click
Dim oRp As New RegistryPermission(Security.Permissions.Permission State.Unrestricted)
oRp.Deny()
Dim objLog As New EventLog
Dim objLogEntryType As EventLogEntryType
Try
Throw (New EntryPointNotFoundException)
Catch objA As System.EntryPointNotFoundException
Try
If Not System.Diagnostics.EventLog.SourceExists("Example" ) Then
System.Diagnostics.EventLog.CreateEventSource("Exa mple", "System")
End If
objLog.Source = "Example"
objLog.Log = "System"
objLogEntryType = EventLogEntryType.Information
objLog.WriteEntry("Error: " & objA.Message, objLogEntryType)
Catch objB As System.Exception
MessageBox.Show(objB.Message)
End Try
End Try
End Sub
================================================== ==
Why the objLog.WriteEntry are always successful???
|