I'm trying to extend System.Web.Mail.MailMessage in my own class. Let's
call it Company.Common.MailMessage. My project obviously has a reference to
System.Web.dll - in order to inherit from MailMessage.
If I build my Company.Common assembly, reference it from a new application
and attempt to consume Company.Common.MailMessage, I receive the following
compile error:
Reference required to assembly 'System.Web' containing the base class
'System.Web.Mail.MailMessage'. Add one to your project.
Kinda makes sense, but not really. Why doesn't my assembly know where to
find System.Web? It's in the GAC and the reference is to a specific
version, culture, etc. I've tried setting "Copy Local" to true for the
System.Web reference in my Company.Common assembly - no luck.
This is analogous to three people in a car - the driver needs directions, so
he asks the person in the passenger seat. He doesn't know where we're
going, but says that the guy in the backseat does. Why can't the driver
just ask the guy in the backseat without taking his eyes off of the road, of
course)? They're all in the same car!
I suspect it has something to do with Namespace boundaries or code access
security, but am not sure. If there isn't a trick to use
Company.Common.MailMessage in an application without a reference to
System.Web, perhaps there's a trick to getting my application to
automatically add a reference to System.Web when I add a reference to
Company.Common?
Thanks!
Ron.