PRB: "?????? ?? ?? ????????? ????? ?????? ???? ??" ?????? ????? ?? asp.NET ????????? ???????? ??? ?? EventSource ????? ?? ?????? ???? ??, ??

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

?? ????? ??

?????

?? ?? asp.NET ????? ??? ??? ????? ?? ???? ?? ????? ?? ????? ?? ??? ????? ?? ??, ???? ????? ?????? ????? ??????? ?? ???? ??:
System.Security.SecurityException: ???????? ????????? ????? ?????? ???? ???

????

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

????????

???????????? ???, ????, ?? ????? ?? ????????? ?? ??????? ???? ?? ??? ????? ????? ??? ???? ???????, ??? ?? ????????? ?? ??? ??? ?? ??????? ???? ??? ?? ????? ???????? ??????? ?? ???? ???.. ?????, ????????? ???? ?? ?? ?? ????? ?? ??????????? ???? ???? ???.. ?????? ??????? ?? ???, ????????? ?? ??????? ???? ?? ???? ???? ??? ?? ???.. ???, ??? ??? ?????? ??????? ???? ?? ?? ?? ????????? ?? ???????????? ?? ???? ???.. ????????? ?? ??? ?? ???? ?? ???????????? ???? ?? ????? ?? ???? ??? ???? ??????? ?? ???, Microsoft ?????? ??? ??? ???? ????? ?? ??? ????? ???? ?????? ????? ????::
322756??? ?? ???? ?? Windows ??? ????????? ?? ???????????? ???? ????
To resolve this problem, a user who has administrative rights must create the event source before you run the ASP.NET Web Application. To create an event source, use one of the following approaches.

First Approach

Create an event source under the?????????event log in Registry Editor. ??? ???? ?? ???, ????? ????? ?? ???? ????::
  1. ????? ????,????????? ????-????? ????, ?? ???? ????????.
  2. ????????????? ????? ???, ??????regedit.
  3. ????? ????????? ??????? ?? ?????? ?????:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application
  4. ????-????? ?????????????subkey, point to????? ????-????? ????, ?? ???? ????????.
  5. ??????:TESTfor the key name.
  6. ????????? ?????? ?? ??? ????..

Second Approach

TheEventLogInstallerclass in the System.Diagnostics namespace permits you to install and configure an event log that your application reads from or writes to while running. You can create an event source by using EventLogInstaller. ??? ???? ?? ???, ????? ????? ?? ???? ????::
  1. ??? ??? ????? ?? ??? Microsoft Visual Basic .NET ?? Microsoft Visual C# .NET ?? ????? ????????? ?????????EventLogSourceInstaller ?? ??? ??? ???????? ??? ??,Class1.VB????? ??Class1.cs???? ???? ???
  2. ?????? Explorer ???, ???? ?????EventLogSourceInstaller?? ????-????? ????, ?? ???? ????????? ??????.
  3. ??????????? ??????????? ????? ???, ???-????? ????System.Configuration.Install.dll?? ????-????? ????, ?? ???? ???OK.
  4. MyEventLogInstaller.vb\MyEventLogInstaller.cs Class1.vb\Class1.cs ?? ??? ??????
  5. ?????? ??? MyEventLogInstaller.vb ?? MyEventLogInstaller.cs ??? ????? ????? ??? ?? ???????????? ????:

    Visual Basic .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 
    
    ????? 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 ?? ????? 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>
    
    ????? 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. Discussed ?? ?????? ????? ????? ???? ??? "?????" ??? ?? ?? ???? ?? ???
  6. ?? ?????? ?? ?? ???? ?? ??? ??? ????? ????? ?? "??????" ??? ??? discussed ?? ??? ??? ?????, ?? ??? ????? ??? ???????WebForm1.aspx:
    EventLog.CreateEventSource(ev.Source, "Application")
  7. ??? 3 ?? 4 ????????

??????

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

???

???? ID: 329291 - ????? ???????: 04 ?????? 2010 - ??????: 2.0
???? ???? ???? ??:
  • 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 6.0
??????: 
kberrmsg kbwebforms kbsecurity kbprb kbmt KB329291 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??: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