惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Darknet – Hacking Tools, Hacker News & Cyber Security
V
Vulnerabilities – Threatpost
Cloudbric
Cloudbric
G
GRAHAM CLULEY
S
Securelist
Schneier on Security
Schneier on Security
Help Net Security
Help Net Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Project Zero
Project Zero
Spread Privacy
Spread Privacy
P
Privacy International News Feed
C
Cyber Attacks, Cyber Crime and Cyber Security
Cisco Talos Blog
Cisco Talos Blog
T
Tailwind CSS Blog
博客园_首页
有赞技术团队
有赞技术团队
Simon Willison's Weblog
Simon Willison's Weblog
Stack Overflow Blog
Stack Overflow Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Latest news
Latest news
T
Tor Project blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Attack and Defense Labs
Attack and Defense Labs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
O
OpenAI News
J
Java Code Geeks
T
Tenable Blog
K
Kaspersky official blog
AWS News Blog
AWS News Blog
S
Security @ Cisco Blogs
The GitHub Blog
The GitHub Blog
T
Threatpost
月光博客
月光博客
H
Heimdal Security Blog
Security Latest
Security Latest
The Hacker News
The Hacker News
Y
Y Combinator Blog
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
C
Cisco Blogs
美团技术团队
Microsoft Security Blog
Microsoft Security Blog
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
C
CERT Recently Published Vulnerability Notes
D
Docker
Google Online Security Blog
Google Online Security Blog
D
DataBreaches.Net
V
Visual Studio Blog
H
Help Net Security

博客园 - bestcomy

在OPENSUE 11.3 上安装 sysstat Upload bug in MOSS 2007 / Windows Server 2008 - bestcomy Excel列名转换 Clienside ProgressIndicator - bestcomy - 博客园 ASP.NET MVC 源代码发布! 微软项目组招聘.NET开发人员(北京) 欢迎访问我的新BLOG空间 SharePoint 胡言乱语 你觉得vs.net那些地方让你使用起来很不爽? Include javascript and css dynamically - bestcomy Two ways to get HtmlTextWriter for HTML rendering How to set value for webpart’s properties when I create a new sharepoint template Get the true value of a calculate field in SharePoint self==top 如何设置AD用户的"用户下次登陆时须更改密码"属性 (LDAP Provider) 微软 and 香烟 Cool!!! Virtual Earth Technology Preview sth about our coding life 还没有Windows Live Messenger的朋友看过来
调用自定义event时需要注意的一个问题
bestcomy · 2006-08-01 · via 博客园 - bestcomy

问题重现
WebForm中定义event
public delegate void AppendFinishedEventHandler(Page sender,SqlTransaction trans);
public event AppendFinishedEventHandler AppendFinished;

激发event
this.AppendFinished(this,trans);

WebForm中通过一个Factory Method 动态Load UserControl.
测试发现WebForm load 某些 UserControl 之后到了激发event的时候抛出了一个NullReferenceException


分析原因
当UserControl 未注册event(AppendFinished)时,AppendFinished 将为null,此时会抛出NullReferenceException
刚发现这个错误的时候一直不明白什么时候AppendFinished 会为null.实际上可以这样想:当Usercontrol并未定义此方法(未注册此event)而去调用,必然会出错。

解决办法
if(this.AppendFinished != null)
 this.AppendFinished(this,trans);