Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / September 2005

Tip: Looking for answers? Try searching our database.

AssemblyResolve: Missleading multicastdelegate, unusable in real scenarios by design?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dotnet007 - 10 Sep 2005 10:45 GMT
Hi to All,

To jump into the deep instantly: Multicast event must not have return
value... by definition
Well, AssemblyResolve event has...

It returns the resolved assembly. But what if when you subscribe more than
one handler _independently_
to listen this event? That is why "Multicast event must not have return
value..."

Unfortunatelly localization (satellite assemblys) rely on AssemblyResolve.
So if you use localization, you can not attach your custom event handler ot
AssemblyResolve, because there is no way (by design of  AssemblyResolve
event signature)  to cooperate with each other.

As a last chance you think you go back 40 years to interrupt vector
chaining, and before you subscribe, you save the existing handler, and call
it in your new handler... But this is bad idea in three ways:

1) First of all it is impossible to get the existing handlers, because it is
an event, and not a "delegate type property" so we have a compiler
restriction (This is a good thing. the design error not in here, but the
event signature)
2) There is no guarantee that other subscribers will do the same if their
subscription is happen later in time... (after yours)

So the pretty += operator what are we using to subscribe is really a
randomly overriding = operator in this case.

What would be a good design?

No return value, and an bool Handled property in the ResolveEventArgs, and
the ResolvedAssembly property in ResolveEventArgs shoud do the work.

Missed I something?

thx for answers
- - 11 Sep 2005 17:51 GMT
It actually depends on whether the subscribers to the event are well
behaved (in an undocumented way, unfortunately), meaning they should
return null if they couldn't resolve the assembly.

The current implementation settles with the first non null result; your
proposed design would work just the same (until the first handled call),
though it does look more consistent.
dotnet007 - 11 Sep 2005 21:07 GMT
Hi, thx for answer.

I suppose this means that Fireer (caller) of this event can not simple fire
the multicastdelegate, but must explicit write a (foreach) cycle on
delegate's invocationlist, and call separately each one, and break the cycle
if one of the called handlers returns not null...

No comment...

> It actually depends on whether the subscribers to the event are well
> behaved (in an undocumented way, unfortunately), meaning they should
[quoted text clipped - 3 lines]
> proposed design would work just the same (until the first handled call),
> though it does look more consistent.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.