国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > .NET > 正文

關(guān)于ASP.Net寫注冊(cè)表權(quán)限問題的官方解決方法

2024-07-10 13:01:56
字體:
供稿:網(wǎng)友
注冊(cè)會(huì)員,創(chuàng)建你的web開發(fā)資料庫(kù),

prb: "requested registry access is not allowed" error message when asp.net application tries to write new eventsource in the eventlog

the information in this article applies to:
  • microsoft asp.net (included with the .net framework) 1.0
  • microsoft visual basic .net (2002)
  • microsoft visual c# .net (2002)
this article was previously published under q329291 important: this article contains information about modifying the registry. before you modify the registry, make sure to back it up and make sure that you understand how to restore the registry if a problem occurs. for information about how to back up, restore, and edit the registry, click the following article number to view the article in the microsoft knowledge base:
256986 description of the microsoft windows registry

symptoms

when you create a new event source in the event log by using asp.net, you may receive the following error message:
system.security.securityexception: requested registry access is not allowed.

cause

by default, the user token of the asp.net worker process is aspnet. the problem in the "symptoms" section occurs because your account does not have the correct user rights to create an event source.

resolution

warning: if you use registry editor incorrectly, you may cause serious problems that may require you to reinstall your operating system. microsoft cannot guarantee that you can solve problems that result from using registry editor incorrectly. use registry editor at your own risk. 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 application event log in registry editor. to do this, follow these steps:
  1. click start, and then click run.
  2. in the open text box, type regedit.
  3. locate the following registry subkey:
    hkey_local_machine/system/currentcontrolset/services/eventlog/application
  4. right-click the application subkey, point to new, and then click key.
  5. type test for the key name.
  6. close registry editor.

second approach

the eventloginstaller class 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. to do this, follow these steps:
  1. use microsoft visual basic .net or microsoft visual c# .net to create a new class library named eventlogsourceinstaller. by default, the class1.vb file or the class1.cs file is created.
  2. in solution explorer, right-click eventlogsourceinstaller, and then click add references.
  3. in the add reference dialog box, double-click system.configuration.install.dll, and then click ok.
  4. rename the class1.vb/class1.cs to myeventloginstaller.vb/myeventloginstaller.cs.
  5. replace the existing code in myeventloginstaller.vb or myeventloginstaller.cs with the following sample code:

    visual basic .net sample
    imports system.diagnosticsimports system.configuration.installimports 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 sample
    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. on the build menu, click build solution to create eventlogsourceinstaller.dll.
  7. open the visual studio .net command prompt.
  8. at the command prompt, change to the folder where eventlogsourceinstaller.dll is located.
  9. run the following command to create the eventsource:
    installutil eventlogsourceinstaller.dll

more information

steps to reproduce the behavior

  1. use visual basic .net or visual c# .net to create a new asp.net web application. by default, webform1.aspx file is created.
  2. in the html view of webform1.aspx, replace the existing code with the following sample code:

    visual basic .net sample
    <%@ 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 sample
    <%@ 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. on the debug menu, click start to view the webform1.aspx page in the browser.
  4. type some text in textbox, and then click write to event log.
  5. the error message that is discussed in the "symptoms" section of this article appears.
  6. to resolve this problem, create an event source as discussed in the "resolution" section, and comment the following code in webform1.aspx :
    eventlog.createeventsource(ev.source, "application")
  7. repeat steps 3 and 4.

references

for more information, visit the following microsoft web sites:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbwlkwalkthroughcreatingeventloginstallers.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdiagnosticseventlogclasstopic.asplast reviewed:1/3/2003keywords:kbprb kberrmsg kbwebforms kbsecurity kb329291 kbauddeveloper kbauditpro
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 西藏| 东台市| 江达县| 措美县| 濮阳市| 凌海市| 开江县| 巩留县| 通化市| 揭阳市| 青海省| 三门峡市| 华阴市| 罗城| 上栗县| 绥棱县| 高台县| 贵溪市| 福泉市| 宁武县| 聊城市| 蓝田县| 阿荣旗| 东阿县| 郎溪县| 桐庐县| 巴南区| 德钦县| 永福县| 伊通| 武鸣县| 余江县| 大石桥市| 朔州市| 清徐县| 平潭县| 桐城市| 淳化县| 二连浩特市| 徐水县| 隆林|