Results 1 to 11 of 11

Thread: Namespaces and visibility.

  1. #1

    Thread Starter
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Namespaces and visibility.

    I'm trying to derive my own class from System.Drawing.Image which represents a bitmap stored in a DirectDraw offscreen surface.

    But when I compile it gives me the error
    'System.Drawing.Image.Image()' is inaccessible due to its protection level
    for every constructor of my class.

    Now I would normally guess that this means the constructor is protected, internal or private. But:
    It can't be protected, my derived class would have access to it.
    It can't be private, else no class could be derived from Image (there's no friend keyword in C#, right?).
    It can't be internal, because a) I placed my image class in System.Drawing and b) System.Drawing.Imaging.Metafile is derived from Image and has access.

    Why does it deny me the access? How can I solve this problem?

    Code:
    public class DdImage : System.Drawing.Image
    {
    	//...
    	public new int Flags
    	{
    		get
    		{
    			return 0;
    		}
    	}
    
    	public new Guid[] FrameDimensionsList
    	{
    		get
    		{
    			return null;
    		}
    	}
    	// etc.
    }
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Because System.Drawing.Image is an abstract class.
    Dont gain the world and lose your soul

  3. #3

    Thread Starter
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I know that. I'm deriving from it. I never call any Image constructor explicitly. But the compiler gives me errors!
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4

    Thread Starter
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Ok, as it is I'll assume Image is somehow guarded in it's namespace (still seems strange to me).

    Damn, that would have been nice.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    You might want to use the Bitmap class instead. I think there is the same functionality and you can create an instance of it.

  6. #6
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    Code:
    public new int Flags
    	{
    		get
    		{
    			return 0;
    		}
    	}
    what does this do? proprieties aren't in the format of:
    <access> <type> <name> ? what does the new do?
    \m/\m/

  7. #7

  8. #8
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    what does this do? proprieties aren't in the format of:
    <access> <type> <name> ? what does the new do?
    The new keyword is there to hide a member with the same name in the base class.
    Dont gain the world and lose your soul

  9. #9

    Thread Starter
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Yep, it won't allow me nothing, it won't allow me override, so I have to use new.

    Bitmap does too much of its own. I don't want it allocating memory behind my back.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  10. #10

    Thread Starter
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Originally posted by kovan
    this MIGHT help...

    http://radio.weblogs.com/0111551/sto...ctClasses.html
    Thanks, but it didn't.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  11. #11

    Thread Starter
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Could it be that I have to implement ALL public methods and properties from Image, even when they are derived from another class (MarshallByRefObject or Object)?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width