PRB: "Access ????? ??????? ?? ??? ????? ???" ????? ??? ??? ?????? ????? EventSource ???? ?? ??? ??????? ????????? ASP.NET

?????? ????????? ?????? ?????????
???? ???????: 329291 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

???????

??? ??????? ASP.NET ?????? ???? ??? ???? ?? ??? ??????? "? ?? ????? ????? ????? ???????:
System.Security.SecurityException: ??? ????? ?????? ??? ??????? ???????.

?????

??? ???????? ?? ????? ?????? ASP.NET ???? ??????? ASPNET (?? NetworkService ????????? ???? ???? ??? "????? ??????? ??????" 6.0 [IIS]). ???? ??????? ?? ??? "???????" ???? ??? ??? ?????? ????? ?? ???? ?????? ?????? ?????? ???? ???.

????

??? ??? ?????? ?? ????? ?? ?????? ??? ????? ?????? ?? ????? ????? ???????. ??? ???? ?? ???? ?????? ????? ?? ???? ????? ????? ?????? ??? ?????. ????? ???? ?? ???? ??????? ??????? ??????. ?????? ??? ??????? ??????? ??? ???? ???????? ?? ????? ??? ??????. ?? ????? ??????? ????? ?? ???? ???? ?????. ?????? ??? ???? ?? ????????? ??? ????? ??? ???? ???????? ?? ????? ????????? ???? ??? ??? ??????? ?????? ?????? ?? "????? ??????? ?? Microsoft:
322756????? ??? ???? ???????? ? ??????? ??????? ?? Windows
??? ??? ???????? ??? ?? ?????? ???? ???? ?????? ???????? ????? ???? ????? ??? ????? ????? ??? ASP.NET. ?????? ???? ??? ?????? ???? ????? ???????.

???? ?????

????? ???? ??? ??? ??? ????? ??????? ?? "???? ???????". ?????? ????? ???? ??????? ???????:
  1. ???? ??? ???? ?? ???? ??? ?????.
  2. ?? ???? ???? ??? ? ???? regedit.
  3. ??? ???? ????? ??????? ?????? ??????:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application
  4. ???? ??? ?????? ?????? ??? ??????? ?????? ??????? ???? ??? ???? ?? ?? ???? ??? ?????.
  5. ??? ???????? ??? ???????.
  6. ???? ???? ???????.

???? ??????

??? EventLogInstaller ?? ????? ????? System.Diagnostics ???? ?????? ?????? ??? ????? ??????? ????? ?? ?? ??????? ?? ?? ??????? ????? ???????. ????? ????? ???? ??? ???????? EventLogInstaller. ?????? ????? ???? ??????? ???????:
  1. ??????? Microsoft Visual Basic .NET ?? Microsoft Visual C# .NET ?????? ????? ????? ?????? ?????? EventLogSourceInstaller. ?????????? ??? ????? ??? Class1.vb ?? ??? Class1.cs.
  2. ?? "?????? ??????" ???? ??? ?????? ?????? ??? EventLogSourceInstaller ??? ?? ???? ??? ????? ?????.
  3. ?? ???? ?????? ????? ??????? ???? ????? ??????? ??? System.Configuration.Install.dll ?? ???? ??? ?????.
  4. ????? ????? ?? Class1.vb\Class1.cs MyEventLogInstaller.vb\MyEventLogInstaller.cs.
  5. ??????? ????????? ???????? ???????? ?? MyEventLogInstaller.vb ?? MyEventLogInstaller.cs ????? ????????? ???????? ??????:

    ????? .NET ???????? ???????
    Imports System.Diagnostics
    Imports System.Configuration.Install
    Imports System.ComponentModel
    
    <RunInstaller(True)> _
    Public Class MyEventLogInstaller
        Inherits Installer
        Private myEventLogInstaller As EventLogInstaller
    
        Public Sub New()
            ' Create an instance of 'EventLogInstaller'.
            myEventLogInstaller = New EventLogInstaller()
            ' Set the 'Source' of the event log, to be created.
            myEventLogInstaller.Source = "TEST"
            ' Set the 'Log' that the source is created in.
            myEventLogInstaller.Log = "Application"
            ' Add myEventLogInstaller to 'InstallerCollection'.
            Installers.Add(myEventLogInstaller)
        End Sub 
    End Class 
    
    ????? Visual C# ?? .NET
    using System;
    using System.Diagnostics;
    using System.ComponentModel;
    using System.Configuration.Install;
    
    
    namespace EventLogSourceInstaller 
    {
    	[RunInstaller(true)]
    	public class MyEventLogInstaller : Installer
    	{
    		private EventLogInstaller myEventLogInstaller;
    
    		public MyEventLogInstaller()
    		{
    			//Create Instance of EventLogInstaller
    			myEventLogInstaller = new EventLogInstaller();
    
    			// Set the Source of Event Log, to be created.
    			myEventLogInstaller.Source = "TEST";
    
    			// Set the Log that source is created in
    			myEventLogInstaller.Log = "Application";
    			
    			// Add myEventLogInstaller to the Installers Collection.
    			Installers.Add(myEventLogInstaller);
    		}
    	}
    }
    
    
  6. ?? ??????? ????? ? ???? ??? ????? ???? ?????? EventLogSourceInstaller.dll.
  7. ???? ?? Visual Studio .NET ????.
  8. ?? ???? ????? ??????? ??? ?????? ??? ???? EventLogSourceInstaller.dll.
  9. ?? ?????? ????? ?????? ?????? EventSource:
    InstallUtil EventLogSourceInstaller.dll

??????? ????

????? ????? ????? ?? ????

  1. ?????? Visual Basic .NET ?? Visual C# .NET ?????? ????? ??? ASP.NET ?????. ?????????? ??? ????? ??? WebForm1.aspx.
  2. ?? ????? ??? HTML WebForm1.aspx ? ?????? ????????? ???????? ???????? ????? ????????? ???????? ??????:

    Visual Basic .NET ?????
    <%@ Page Language="vb" AutoEventWireup="true" %>
    <%@ Import namespace="System.Diagnostics" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    	<script language="VB" runat="server">
    	Sub WriteEvent_Click(Src As Object, e As EventArgs)
    	Dim ev As New EventLog("Application")
    	' Event's Source name
    	ev.Source = "TEST" 
    	
    	EventLog.CreateEventSource(ev.Source, "Application")
    	
    Try
    	 ev.WriteEntry(TextBox1.Text)
    	Catch b as exception
    	 Response.write ("WriteEntry " & b.message & "<br>")
    	End Try
    	ev = Nothing
    	End Sub
    	</script>
    
    	<body>
    		<form id="Form1" runat="server">
    			Event message: 
    			<asp:textbox id="TextBox1" runat="server" Width="233px"></asp:textbox>
    			<asp:button id="Button1" onclick="WriteEvent_Click" runat="server" NAME="Button1" text="Write to event log"></asp:button>
    		</form>
    	</body>
    </HTML>
    
    ????? Visual C# ?? .NET
    <%@ Page Language="c#" AutoEventWireup="true" %>
    <%@ Import namespace="System.Diagnostics" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    	<script language="C#" runat="server">
    	void WriteEvent_Click(Object Src, EventArgs e)
    	{
    	EventLog ev = new EventLog("Application");
    	// Event's Source name
    	ev.Source = "TEST";  
    	
    	EventLog.CreateEventSource(ev.Source, "Application");
    
    			try
    			{
    				ev.WriteEntry(TextBox1.Text);
    			}
    			catch (Exception b)
    			{
    				Response.Write("WriteEntry " + b.Message + "<br>");
    			}
    			ev = null;
    	}
    	</script>
    
    	<body>
    		<form id="Form1" runat="server">
    			Event message: 
    			<asp:textbox id="TextBox1" runat="server" Width="233px"></asp:textbox>
    			<asp:button id="Button1" onclick="WriteEvent_Click" runat="server" NAME="Button1" text="Write to event log"></asp:button>
    		</form>
    	</body>
    </HTML>
  3. ?? ??????? "?????" ? ???? ??? "????" ???? ?????? WebForm1.aspx ?? ????????.
  4. ???? ??? ?? ?? ???? ?? ?? ???? ??? ??????? ??? ??? ???????.
  5. ????? ????? ??????? ?? "?????? ?????" ???? ????? ?? ??? ???????.
  6. ??? ??? ???????? ?? ?????? "???? ?????" ??? ?? ???? ?? ??? "????" ???????? ???????? ???????? ??????? ?? WebForm1.aspx:
    EventLog.CreateEventSource(ev.Source, "Application")
  7. ??? ???????? 3 ? 4.

?????

????? ?? ?????????? ?? ?????? ????? Microsoft ??????? ??? ?????:
http://msdn2.microsoft.com/en-us/library/f5dcf6h3(vs.71).aspx
http://msdn2.microsoft.com/en-us/library/system.diagnostics.eventlog(vs.71).aspx

???????

???? ???????: 329291 - ????? ??? ??????: 23/?? ??????/1428 - ??????: 2.10
????? ???
  • Microsoft ASP.NET 1.1
  • Microsoft Visual Basic .NET 2003 Standard Edition
  • Microsoft Visual C# .NET 2003 Standard Edition
  • Microsoft ASP.NET 1.0
  • Microsoft Visual Basic .NET 2002 Standard Edition
  • Microsoft Visual C# .NET 2002 Standard Edition
  • Microsoft Internet Information Services 5.0
  • Microsoft Internet Information Services version 5.1
  • Microsoft Internet Information Services 6.0
????? ??????: 
kbmt kberrmsg kbwebforms kbsecurity kbprb KB329291 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????329291

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com