2

I am writing an add-in for ArcMap 10. I am trying to do Dim clickedPoint as IPoint in VB.NET, but I get "Type 'IPoint' is not defined" error. Do I have to import a class or how do I make this work?

5

Yes, since you are presumably using VB.NET (not VB, which is 20+ years old and no longer supported), you need to use the Imports statement to import namespaces.

Specifically you want to put Imports ESRI.ArcGIS.Geometry at the top of your code files.

Alternatively you could fully qualify the IPoint type every time you use it (ESRI.ArcGIS.Geometry.IPoint) but that gets old quick.

Tip: In Visual Studio, use the context-sensitive chip that appears when you hover over a type name with a missing namespace declaration, and click the first option to automatically add an Imports statement for the discovered namespace. This will only work as long as you have a reference to the type's assembly in your project and there is no ambiguity as to its namespace.

  • I tried all this, but it doesn't work. When I use the import statement it seems as though it can't find the Geometry class. I get a warning "Namespace or type specified in the Imports 'ESRI.ArcGIS.Geometry' doesn't contain any public member or cannot be found. etc etc etc" – Xoph May 1 '12 at 17:20
  • 2
    You need to add a reference to ESRI.ArcGIS.Geometry. In Solution Explorer -> Right Click on References -> Add Reference -> Select ESRI.ArcGIS.Geometry – Jakub Sisak GeoGraphics May 1 '12 at 17:49
  • 3
    Instead of using "Add Reference", you should use "Add ArcGIS Reference", since that automatically sets the Specific Version to False. – kenbuja May 1 '12 at 18:02

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.