ASP.Net SqlWebEventProvider - 引发自定义事件 - 由于其保护级别而无法访问 WebErrorEvent
我使用 SqlWebEventProvider 将异常记录到 sql server,并且工作正常。
我还想以编程方式将自定义异常记录到 aspnet_WebEvent_Events 表。类似于 - http://fredrik.nsquared2.com/viewpost.aspx ?PostID=107&showfeedback=true
WebBaseEvent.Raise(new WebErrorEvent("我的错误消息", null, 5000, e)); 我收到一条错误消息“由于其保护级别,无法在此处访问构造函数‘WebErrorEvent’。
感谢您的评论...
I use SqlWebEventProvider to log the exceptions to sql server, and it works fine.
I also want to log custom exceptions to aspnet_WebEvent_Events table programmatically. Similar to - http://fredrik.nsquared2.com/viewpost.aspx?PostID=107&showfeedback=true
WebBaseEvent.Raise(new WebErrorEvent("My Error message", null, 5000, e));
I get an error saying "Cannot access constructor 'WebErrorEvent' here due its protection level.
Appreciate your comments...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您希望记录自定义事件,您可以考虑通过继承 System.Web.Management 中的预定义事件类之一来创建您自己的事件。
这是斯科特·米切尔 (Scott Mitchell) 撰写的一份很好的参考资料。这很容易遵循
https://web. archive.org/web/20211020121454/https://www.4guysfromrolla.com/articles/062707-1.aspx
If you wish to log custom events, you may consider creating your own event by inheriting from one of the predefined event classes found in System.Web.Management.
Here is a good reference written by Scott Mitchell. It is pretty easy to follow
https://web.archive.org/web/20211020121454/https://www.4guysfromrolla.com/articles/062707-1.aspx
WebErrorEvent
类的构造函数是私有的。您无法实例化此类的对象。查看标题为 CSharp - A Step Ahead 系列中的构造函数是什么?。
The constructor for class
WebErrorEvent
is private. You can't instantiate an object of this class.Take a look at Using Access Modifier private with Constructor in the article titled What are constructors in CSharp - A Step Ahead Series?.