Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
3.80/5 (4 votes)
See more: , +
Hi, this is my first question, I've been looking for a solution for 2 days and nothing.


Im creating a custom control that uses a picturebox and im trying to select the image from the property grid... but I get this error:

Error 2 The type or namespace name 'ImageEditor' does not exist in the namespace 'System.Drawing.Design' (are you missing an assembly reference?) C:\Users\Personal\...\ImageButton.cs 33 51 My Project


C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Design;

namespace MyNamespace
{

  public partial class ImageButton : UserControl
  {
    public ImageButton()
    {
      InitializeComponent();
    }

    private Image normal;

    public string TestString // Just for test if the property is displayed in the property box -and it does -
    {
      set;
      get;
    }

    // Im getting the error in the next line.. 
[EditorAttribute(typeof(System.Drawing.Design.ImageEditor),typeof(System.Drawing.Design.UITypeEditor))] // According to http://msdn.microsoft.com/en-us/library/system.drawing.design.imageeditor.aspx
    public Image ImageNormal
    {
      set  
      {
        normal = value;
      }
      get
      {
         return normal;
      }

    }
}
}


I've tried using differents versions of .net framework 2.0, 3.5, 4 and the same problem, also i've tried to use VS2010 Express Edition and Professional on different PCs and im getting the same problem...

I can assign the Image property programmatically, but when I show the form on the designer, I get another error, saying that the custom control class does not have a property called ImageNormal... but it does..

when I browse the namespace System.Drawing.Design I cannot see all the classes that it should have (according to http://msdn.microsoft.com/en-us/library/ks225801[^]), only
VB
CategoryNameCollection
PaintValueEventArgs
PropertyValueUIItem
ToolboxComponentsCreatedEventArgs
ToolboxComponentsCreatingEventArgs
ToolboxItem
ToolboxItemCollection
UITypeEditor


all the Prebuilt UITypeEditors classes are missing! (BitmapEditor, ColorEditor, ContentAlignmentEditor, CursorEditor, FontEditor, FontNameEditor, IconEditor, ImageEditor, MetafileEditor)

so I wonder why is this happenig to me, I supose im doing something wrong... the APP is a Windows Forms Application.

Any help will be appreciated.

PS: Excuse me if there is anything wrong/weird with my English.
Posted

For the namespace to get recognised you should add it's dll as a reference.

You should add the System.Drawing.Design dll as reference.
 
Share this answer
 
v3
Thanks for the help.. when I realized that System.Drawing.Design was not on the reference list

I found the solution by:

1) My project target was ".NET FW 4.0 Client Profile". Changed to ".NET FW 4.0" (System.Drawing.Design is not available for client profiles!!)
2) Project restarted..
3) Deleted Previous Reference of System.Drawing
4) Added reference to System.Drawing and System.Drawing.Design(after switching to .NET FW 4.0 it appeared on the reference list.)
5) Problem solved.

thanks Rajeev Jayaram.
 
Share this answer
 
Comments
Rajeev Jayaram 28-Jun-12 15:52pm    
You're welcome.

Note: If you mean to add comments to any solution you should use the "Have a Question or Comment?" option.
sal0m0n 28-Jun-12 16:45pm    
Thanks again.

:)
[no name] 17-Dec-15 9:46am    
want the solution for my problem
Dave Kreskowiak 17-Dec-15 10:10am    
Sorry, we can't prescribe medication.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900