Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

.NET v1.1 changes delegate accessibility checking!

From the GotDotNet .NET 1.1 backwards-breaking change log: http://www.gotdotnet.com/team/changeinfo/Backwards1.0to1.1/default.aspx#00000139

"Calling a method through a Delegate performs the same accessibility checks as calling that method directly."

Does this mean that protected event-handling methods are now forced to be public (if not handling an event from a class that it inherits)?

This doesn't really make sense, because the only way you could create a delagate of a protected or private method is if you could already see it... But now the class you pass the delegate to must have access to that method in order to call it? I hope not!

Sign up for the .NET 1.1 beta here and find out! http://msdn.microsoft.com/netframework/productinfo/next/download.asp

Marcus Lum
Saturday, September 21, 2002

Not sure why they did this, but it seems logical that delegates would undergo the same ACL-checking that all other CLR resources do. Just because you have a delegate reference doesn't necessarily mean you have any rights on it.

Jake
Monday, September 23, 2002

Well, it does mean you have rights on it...  As Marcus mentioned, you couldn't have gotten the delegate in the first place unless it were provided to you directly or if you had retrieved it using a method or property that you did have access to.  It's really no different than being provided a reference to a private field or property of an object -- if another object receiving the reference (say, as an argument to one of its methods) doesn't have proper access to the private member that the reference goes to, that still doesn't keep it from using the reference.

Mike Paxton
Monday, September 23, 2002

YOU have rights on it.

Jake
Friday, September 27, 2002

This change was also included in .NET v1.0 SP2.

Michael Giagnocavo
Saturday, September 28, 2002

The change you're talking about isn't quite what you think.  Check out this thread from the DOTNET-CLR list over on discuss.develop.com:

http://discuss.develop.com/archives/wa.exe?A2=ind0209C&L=DOTNET-CLR&D=0&I=-3&P=3844

That should clarify things.

Ben Lowery
Saturday, September 28, 2002

*  Recent Topics

*  Fog Creek Home