2

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;            
    }
  • 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 May 4 '16 at 13:59
  • 2
    Your syntax is correct according to the Create RGBColor Snippet – kenbuja May 4 '16 at 15:38
4

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.

  • 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. – Michael Stimson May 6 '16 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 May 23 '18 at 9:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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