My.Arcmap.Application Not Recognized

3803
4
01-06-2011 10:41 AM
BradAllen
New Contributor
Hello,

I'm trying to use Visual Basic Express to implement the Visual Basic.NET version of the Zoom to Layer add-in sample located here:

http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/ZoomToLayerButton/004800...

I copied and pasted the code into the IDE and activated all the references listed in the import statements.  My problem is that all instances of My.ArcMap.Application  in the code register as errors.  For example, the IDE identifies My.ArcMap.Application in the following statement as an error:

Enabled = My.ArcMap.Application IsNot Nothing 

The error message says, "Arcmap is not a member of My."  At this point, I've exhausted all my ideas for fixing the problem.  I appreciate any help you can provide.

Thanks,
Brad
0 Kudos
4 Replies
RobHalko
New Contributor II
Hi Brad,

Not sure if you found a solution yet, but I had to deal with this frustrating issue today. In my case it was because I used the '&' character in the Company info when creating the project. The config file (XML) became inconsistent with the build information, not allowing for my tool to show in the add-in manager as well.

Thanks to ESRI, for choosing to use XML. Perhaps if this kind of error was documented... I wouldn't have had such a bad afternoon thus far.

Rob
0 Kudos
MichaelRobb
Occasional Contributor III
OP, I would quickly assume that they did not add their .net developer kit and use the Template to create their addin...
My is the Namespace created when created using the Developer Template addin CLASS.
(Your addin solution)

Namespace My will contain the Friend Module ThisAddin and pass any XML information to the Solution project.

Friend Module ArcMap
  Private s_app As ESRI.ArcGIS.Framework.IApplication
  Private s_docEvent As ESRI.ArcGIS.ArcMapUI.IDocumentEvents_Event

  Public ReadOnly Property Application() As ESRI.ArcGIS.Framework.IApplication
    Get
      If s_app Is Nothing Then
        s_app = TryCast(Internal.AddInStartupObject.GetHook(Of ESRI.ArcGIS.ArcMapUI.IMxApplication)(), ESRI.ArcGIS.Framework.IApplication)
      End If

      Return s_app
    End Get
  End Property

  Public ReadOnly Property Document() As ESRI.ArcGIS.ArcMapUI.IMxDocument
    Get
      If Application IsNot Nothing Then
        Return TryCast(Application.Document, ESRI.ArcGIS.ArcMapUI.IMxDocument)
      End If

      Return Nothing
    End Get
  End Property
  Public ReadOnly Property ThisApplication() As ESRI.ArcGIS.ArcMapUI.IMxApplication
    Get
      Return TryCast(Application, ESRI.ArcGIS.ArcMapUI.IMxApplication)
    End Get
  End Property
  Public ReadOnly Property DockableWindowManager() As ESRI.ArcGIS.Framework.IDockableWindowManager
    Get
      Return TryCast(Application, ESRI.ArcGIS.Framework.IDockableWindowManager)
    End Get
  End Property

  Public ReadOnly Property Events() As ESRI.ArcGIS.ArcMapUI.IDocumentEvents_Event
    Get
      s_docEvent = TryCast(Document, ESRI.ArcGIS.ArcMapUI.IDocumentEvents_Event)
      Return s_docEvent
    End Get
  End Property
End Module


Then you can use My namespace and get ArcMap.Application


rhalko:

Why should ESRI document how to use XML?  We all know special characters in different codes require attention.  Hopefully your afternoon gets better now that you found what was wrong.

XML characters

If you want to use &
&

e.g. <company>AT&amp;T</company>
0 Kudos
KyleBelott
Occasional Contributor
Brad,
Are you creating the project using an Add-In template? I spent a fair amount of time researching the same issue for the Add-In I was developing. Ultimately, I found that the <ArcMap> tag was missing from the 'Config.esriaddinx' file. Once I added this the build ran successfully. If you are using the Add-In template, try adding the following sample text (and modify for your add-in type) within the <Addin> tag of the 'Config.esriaddinx' file.
 
<ArcMap>
<Commands>
<Button
id="Acme_ToggleDockWinBtn"
class="ToggleDockWinBtn"
caption="OpenDockWin"
category="Acme Tools"
image="Images\ToggleDockWinBtn.png"
tip="Toggle dockable window."
message="Open dockable window.">
<Helpheading="Toggle">Turns the ACME dockable window on and off.</Help>
</Button>
</Commands>
</ArcMap>


Hope that helps.
Kyle
MarshallFlynn
New Contributor

Just came across this issue.  Using .NET, it was saying the exact same thing about My.ArcMap not a member.  Well, it turned out to be simple.  The assembly when building was defaulting to have onDemand="true".

 

Just add onDemand="false" to Config.esriaddinx inside the <Button   /> brackets.

0 Kudos