Click here to Skip to main content
12,065,888 members (37,037 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# Visual-Studio Design VS2010 , +
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


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
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 28-Jun-12 6:25am
sal0m0n234
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
v3
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  
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.

:)
Member 12097103 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160207.1 | Last Updated 17 Dec 2015
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100