Hi Cristian,
Thanks for your post.
Based on my understanding, you want to inherit from System.Drawing.Brush
class to implement a customized brush.
However, we can not do this. This is because the designer of
System.Drawing.Brush class do not want us to inherit from it. If you use
Reflector to view the source code of System.Drawing.Brush class. You will
see that its constructor is defined like this:
internal Brush()
{
this.nativeBrush = IntPtr.Zero;
}
Yes, it is marked with "internal", which means that only classes in the
same assembly can access it. That is why the following classes inherited
from System.Drawing.Brush class:
System.Drawing.Drawing2D.HatchBrush
System.Drawing.Drawing2D.LinearGradientBrush
System.Drawing.Drawing2D.PathGradientBrush
System.Drawing.SolidBrush
System.Drawing.TextureBrush
Because they all reside in the System.Drawing.dll assembly.
But if we want to inherit from Brush class, we will get the following
compile time error:
"'System.Drawing.Brush.Brush()' is inaccessible due to its protection level"
This issue is documented in the KB below:
"You receive error messages when you try to inherit from a class that
contains only private constructors in Visual Studio .NET"
http://support.microsoft.com/?kbid=833898
Hope this is clarify and helpful, thanks
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.