---
title: "[Article] Defensive event publishing in .NET"
url: "https://osherove.com/blog/2005/1/8/article-defensive-event-publishing-in-net.md"
canonical: "https://osherove.com/blog/2005/1/8/article-defensive-event-publishing-in-net.html"
published: "2005-01-08T22:16:00"
updated: "2005-01-08T22:16:00"
tags: [".Net Original"]
author: "Roy Osherove"
description: "Summary Events and delegates in the .NET Framework present an interesting case of apparent simplicity with abundant complexity underneath. Unfortunately, we *have* to take into account the complexity underneath if we…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# \[Article\] Defensive event publishing in .NET

By Roy Osherove January 8, 2005 In [.Net Original](https://osherove.com/blog/category/net-original)

**Historical article** · Originally published January 8, 2005; technical details may be outdated.

**Summary**

Events and delegates in the .NET Framework present an interesting case of apparent simplicity with abundant complexity underneath. Unfortunately, we \*have\* to take into account the complexity underneath if we are to use events correctly in our applications. What I m suggesting here is that most developers today are \*not\* raising events correctly.  Even most of the advanced developers out there are not doing all the necessary steps in order to make sure the events are published in a safe manner.

[Defensive Event Publishing in .NET (Part I)](http://weblogs.asp.net/rosherove/articles/DefensiveEventPublishing.aspx)

_This article was inspired by_ [_Juval Lowy s Advanced .NET master class_](http://www.idesign.net/) _(Copyrights © IDesign 2005) and contains code excerpts from_ [_Programming .NET Components (1st Edition)_](https://www.amazon.com/exec/obidos/ASIN/0596003471/iserializable-20) _By O'Reilly 2003._

## More in .Net Original

[All posts in .Net Original](https://osherove.com/blog/category/net-original)

- Mar 3, 2005

    ### [Solving Binary serialization versioning conflicts](https://osherove.com/blog/2005/3/3/solving-binary-serialization-versioning-conflicts.html)

- Jan 23, 2005

    ### [New stuff on Team Agile: XtUnit and Interception block with basic documentation](https://osherove.com/blog/2005/1/23/new-stuff-on-team-agile-xtunit-and-interception-block-with-b.html)

- Jan 8, 2005

    ### [Making ClickOnce publishing work in VS.Net 2005 Beta 1+](https://osherove.com/blog/2005/1/8/making-clickonce-publishing-work-in-vsnet-2005-beta-1.html)

- Jan 7, 2005

    ### [Full source for The Regulator released](https://osherove.com/blog/2005/1/7/full-source-for-the-regulator-released.html)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
