ASP.Net SqlWebEventProvider - 引发自定义事件 - 由于其保护级别而无法访问 WebErrorEvent

发布于 2024-08-30 18:12:56 字数 443 浏览 3 评论 0原文

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

临走之时 2024-09-06 18:12:56

如果您希望记录自定义事件,您可以考虑通过继承 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

坏尐絯℡ 2024-09-06 18:12:56

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?.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文