3

Trying to create a simple line symbol. But getting an error: "The type 'ESRI.ArcGIS.Display.RgbColorClass' has no constructors defined"

public override void OnClick()
    {
        IDocument pdoc = m_application.Document;
        IMxDocument pmxdoc = (IMxDocument)pdoc;
        IActiveView pactive = pmxdoc.ActiveView;
        IRgbColor rgbColorCls = new RgbColorClass();
        rgbColorCls.Red = 138;
        rgbColorCls.Green = 151;
        rgbColorCls.Blue = 255;
        ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol();
        simpleLineSymbol.Color = rgbColorCls;            
    }
2
  • I don't program in c# so may be what I am suggesting is incorrect but in VB I would not have put () after RgbColorClass.
    – Hornbydd
    Commented May 4, 2016 at 13:59
  • 2
    Your syntax is correct according to the Create RGBColor Snippet
    – kenbuja
    Commented May 4, 2016 at 15:38

1 Answer 1

5

Got this fixed. For those facing similar issue: expand the "References", find the ESRI.ArcGIS.Display reference. Right click it and select properties, and change "Embed Interop Types" to false.

2
  • 1
    Yep, that's a trap for young players... this one did my head in for a few days. This is on the borderline between GIS.SE and StackOverflow as it's a Visual Studio build problem and not an ArcObjects issue. While it's here though it's worth a +1, no doubt someone else will have the same problem and search this site. Commented May 6, 2016 at 5:38
  • Thanks - I had this problem when debugging some existing project and had to adopt the code to run against a different version of ArcMap - then I got all these weird errors when I did a clone of the project from Git. This helped alleviate the head scratching!!
    – Vidar
    Commented May 23, 2018 at 9:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.