Category: Developer

New Community Center for ArcGIS Mobile!

The ArcGIS Mobile Resource Center introduced a new Community Center today!

The goal of the Community Center is to grow a vibrant online community centered around Mobile GIS. The community center aggregates all sources of information that change frequently so you have the most recent information. It includes this blog site, forums, knowledge base articles, and a code gallery for developers.

With the launch of the community center, the mobile dev team has uploaded a number of code samples that you can download in the code gallery. All samples uploaded by the dev team are clearly indicated by the “ArcGIS Mobile Development Team” tag on the sample.

During our presentations at UC2008 (both in the technical workshops and at the Mobile Island Demo Theatre), we wrote a lot of code and those of you who attended our presentations have asked for us to share it with you. So the code samples prefixed with “ArcGIS Mobile – ” are exactly those samples. Once you have taken a look, please come back to the code gallery and give these samples a rating!

To post your code to the code gallery, all you need to do is log into the code gallery using your ESRI Global account. If you do not yet have one, you can sign up for one here.

 

Posted in Developer, Mobile | Tagged , , , , , , , , , | Leave a comment

What every ArcObjects programmer should know about Singletons

When you are programming your application using the ArcGIS ArcObjects API it’s best to remain aware of classes which support only one instance across your application or in each thread.  This type of class is called a “singleton”.  The coding techniques for how objects of this type of class are created, used, and disposed of are a little different than other object classes.   This topic is sometimes a little confusing, and carries with it its own idiosyncracies, so we wanted to bring this up, describe it, and see if the developer community out there have any thoughts or helpful hints we can all share with each other. 

Advanced coders might see this topic are fairly basic, but we at ESRI have seen difficulties and a bit of confusion come up often enough on our developer support help hotline and from students in our instructor-led developer training classes, that we figured it might be a good topic to discuss here.

Typically a co-createable class gives you the flexibility to create as many instances as your application design needs.  Singleton classes are an important exception.  A list of which classes are used as singletons (versions 9.2 and 9.3) can be found here:

Looking through the list, the reason why some of these classes are limited to singleton usage might be fairly obvious.  For example the AppRef, MonitorSettings, or SystemHelper classes.  But others may not be so obvious, like the StyleGallery, FindDialog, and the various ~WorkspaceFactory and ~ToolbarEnvironment classes, so watch out for them because you’ll use and manage singletons differently than other class instances you create.

Singletons, how and why

How it works is this.  A singleton class declares the class constructor as private so that no other object can create a new instance and prevent other objects from instantiating their own copies of the singleton object, ensuring that all operations throughout your application access the single instance. Using the proper instantiation mechanism and by providing a central mechanism by which all objects can obtain a reference to the single instance, it is possible to manage your use of singleton objects correctly, keeping full control over the stability and memory usage of your application.

singletons:  you can only eat one…

Creating and managing singleton objects

Even though the special techniques for using singletons are fairly straightforward, there are few important things to understand, otherwise, singletons are left dangling (called pinning).   If you have ever received this runtime error:

Unable to cast object of type System.__ComObject to type <Typename>”  

…good chance you are trying to create a new instance of a singleton class that already exists.  Bad news.  But easy to fix. 

The following piece of code raises an error with Visual Basic’s New keyword as the .NET Framework is unable to wrap in a strongly typed RCW an instance of an object that has previously been wrapped in the generic System.__ComObject RCW. 

[VB.NET]
‘The following line of code is incorrect and generates an “Unable to cast…” runtime error. 
Dim sg As ESRI.ArcGIS.Display.IStyleGallery = New ESRI.ArcGIS.Framework.StyleGalleryClass

Singleton classes can only be used by using the Activator class.  This class provides a CreateInstance method which you will use to create a singleton objects and other variable references to it.  Here is one proper way to make it work:

[VB.NET]
‘The proper way to use singleton object classes 
Dim t As Type = Type.GetTypeFromProgID(“esriFramework.StyleGallery”)
Dim obj As System.Object = Activator.CreateInstance(t)
Dim pApp As ESRI.ArcGIS.Display.IStyleGallery = obj

As you can see, a little different than creating objects using other classes. 

Releasing singleton objects

Now that you have created a singleton object or additional references to it, any object variables in scope which reference singletons must eventually be explicitly released using the ComReleaser class.
The following example code shows how you can call the ReleaseComObject method to release a StyleGallery object.
 
[VB.NET]
Dim refsLeft As Integer = 0
Do
    refsLeft = System.Runtime.InteropServices.Marshal.ReleaseComObject(pApp)
Loop While (refsLeft > 0)

The code follows a loop that calls ReleaseComObject until the returned value is zero. This indicates there are no longer any managed references to the StyleGallery, and such code should only be used when you are sure no other managed code will require further access to the object. The ComReleaser class can be found in the ESRI.ArcGIS.ADF namespace. 

For more info, or for just fun reading

1.  Here is some more information and MSDN documentation about .NET’s System.Activator class.

2.  If your application design includes creating singleton classes of your own, here’s a clever and entertaining blog rant called “Singleton Considered Stupid” from Steve Yegge about how singletons are used and often misused nowadays. 

Thoughts?  Ideas?  Questions anyone?

Contributed by Sirisha Karamchedu from ESRI Educational Services

 

Posted in Developer | Tagged , , | 4 Comments

Technical Workshop: Building Solutions with ArcGIS Engine

If you are headed to San Diego to attend the 2008 ESRI International User Conference next week, we look forward to seeing you there.  Feel free to stop by the EDN and ArcGIS Engine product islands and meet the teams.

And if you have been using ArcGIS Engine or just getting started, consider attending the valuable “Building Solutions” technical workshop for ArcGIS Engine.  Actually there will be two workshops, one for Java developers and one for .NET.

For JAVA developers:   Tuesday, August 5th, 3:15-4:30pm, in Room 15A

For .NET developers:  Tuesday, August 5th, 1:30-2:45pm, in Room 15A  (offered again on Thursday, same time/room)

 

Posted in Developer | Tagged , , , | 1 Comment

ESRITV: ESRI videos now on YouTube™

ESRI is now posting short and informative videos on YouTube.  You will find clips covering many different topics of interest, both general and specific, conceptual and technical.  And while it’s certainly not just for ArcObjects developers, there are a few developer-oriented videos there now and more are on the way.

The URL is:  https://www.youtube.com/esritv

 

Posted in Developer | Tagged , | 4 Comments

Eclipse Update Manager hangs when installing the ArcGIS Doc plug-in at 9.3.

The Eclipse Update Manager hangs when installing the ArcGIS Doc plug-in for Engine or Server on some machines.   The following workaround will help you get the plug-in up and running.

 

Step 1: Unzip com.esri.arcgis.doc_9.3.0.1770.jar located in the <ArcGIS Install>/java/tools/eclipse_plugin/arcgis_update_site/doc/plugins/ folder to <Eclipse Install folder>/pluginsStep 2: Restart Eclipse using the –clean command line argument to eclipse.exe to update the Eclipse configuration.  

Additional information about the Eclipse plug-ins for ArcGIS can be found on the EDN site:

http://resources.esri.com/help/9.3/ArcGISServer/adf/java/help/doc/6c7a7b84-5168-4843-9536-34e5ef2ec424.htm

Posted in Developer | Tagged , , , | 1 Comment

Developer info for new PDF functionality at ArcGIS 9.3 (including pdf patch)

Many developers have asked how to take advantage of the enhanced PDF export capabilities in 9.3 and the “Map Export Patch to Support Acrobat 9 PDF” in their code, so we’ve prepared a short primer on this new functionality.

All of these new capabilities are contained in a new interface, IExportPDF2.  Unfortunately the web help for the SDK was erroneously published based on an older version of the interface.  We are in the process of updating the web help, but in the mean time here is the skinny on the new interface’s two properties:

 

IExportPDF2::ExportPDFLayersandFeatureAttributes

This one is pretty self-explanatory.  There are three possible values for this parameter, that control what content is exported into the resultant PDF:

esriExportPDFLayerOptionsNone No Layers and Feature Attributes.
esriExportPDFLayerOptionsLayersOnly Layers Only. This is the default value.
esriExportPDFLayerOptionsLayersAndFeatureAttributes Layers and Feature Attributes.

  

Be careful when using the option “LayersAndFeatureAttributes”.  All of the visible attribute fields in each feature class in the ArcMap document will be exported to the PDF. 

Exporting attributes to PDF can lead to performance problems when viewing the file in supported PDF readers. If possible, limit exported fields to one layer per map. To suppress field export, turn off field visibility in the Fields tab of the Layer Properties dialog.

IExportPDF2::ExportMeasureInfo

Recent versions of Adobe Acrobat and Adobe reader allow for encoding of map coordinate system and georeference information inside the PDF file.  Exporting a map with the ExportMeasureInfo property set to True will record map georeference information inside the PDF.  If you have installed the 9.3 PDF patch, ExportMeasureInfo will be True by default.  This means with any patched install of ArcGIS, even your existing PDF export code will include the new georeference info in exported PDF files.  Set this property to False to suppress the inclusion of georeference info in your PDF. 

For more detailed information on the functionality controlled by these properties, take a look at the desktop help for Advanced PDF Features.  Here’s a link to the web help version of this topic:  http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Advanced_PDF_features

Let us know what you think of this new functionality!

 

Posted in Developer | Tagged , , , | 3 Comments

Whoa… What's up with the EDN website?

As you may or may not have noticed, the content-rich EDN website has recently changed to a thin jump site with four links.  So to get right to the point your first question may be: “Where do I find the resources I need right now?

Starting with ArcGIS version 9.3 in July 2008, developers are encouraged to use the new ESRI Resource Centers to access SDK documentation, samples, product technical information, as well as tools and resources for interacting with communities of ArcGIS developers around the world.

For the time being, the old EDN website will continue to exist and be the repository for developer content for ArcGIS versions 9.2 and prior.  It will no longer be used for ArcGIS version 9.3 nor beyond.

Why?

Our goal here is to create one single website for all users’ product usage resource needs.  At version 9.2 and prior, developers used the EDN website and end-users of ESRI’s GIS software tended to use the ESRI Support Center online. 

Feedback from the user community, as well as our own technology development goals indicate that developers need information about product installation, architecture, administration, and functional usage as much as any other user, and end-users more and more often are making use of information for product customization, components, scripting, programming, and other resources typically associated with application developers.  As our technology continues to grow along with the maturity of information technology, the lines between “user” and “developer” continue to blur and overlap.  It makes less and less sense to maintain two sites and have users decide which one to use.

So as you use the ESRI Resource Center online, we encourage you to interact with other developers like yourself, as well as GIS end-users and the resources they all use to be successful.  That is the place online where the EDN community will continue to grow, through code sharing galleries, discussion forums, video, and blogs from ESRI development teams, as well as new community tools and resources upcoming such as open chat, tech workshop webcasts, and a fully wiki’d Knowledge Base technical documentation set.

What about the EDN program?

The ESRI Developer Network software subscription program and its add-on training and support products are not changing. 

Developers around the world have found EDN to be a very cost-effective and simple way to access the entire ArcGIS technology and product base for product customization, implementation, as well as the design and development of applications and systems.   This has been a popular product and is not going anywhere.   Actually, ESRI is committed to making improvements and additions to the subscription program as our leadership position in the geospatial technology industry continues to grow.  

Posted in Developer | Tagged , | 2 Comments

Why is the Visual Basic Editor grayed out after installing ArcGIS 9.3?

VBA version 6.5 is required for ArcGIS 9.3 (installs with Microsoft Office 2007). This does not get installed automatically when installing ArcGIS using the setup.msi file. One of the more noticeable indicators that the correct version of VBA was not installed is when navigating to Tools > Macros > Visual Basic Editor will be grayed out. However, it can be installed after using the setup.msi file by installing the files referenced below or it can be automatically installed if you use the setup.exe instead of the setup.msi. 

The ArcGIS Installation Guide > Installing ArcGIS Desktop silently, states the following: The installation of ArcGIS Desktop (setup.exe) serves as a single installer that integrates three separate installers required to run ArcGIS Desktop.  If you are deploying ArcGIS Desktop or need to install using setup.msi directly, you will need to install the other setup programs as well. The setup.msi programs and installation order are:

  1. The ArcGIS Desktop setup.msi (with custom installation information supplied below)
  2. <media or administrative installation>VBAVBAOF11.msi /qb  (no installation parameters are required)  
  3. <media or administrative installation>VBA1033VBAOF11i.msi /qb (no installation parameters are required) 

Additional Resources:
http://resources.esri.com/help/9.3/arcgisdesktop/installGuides/ArcGIS_Desktop/whnjs.htm 
http://support.esri.com/index.cfm?fa=knowledgebase.techArticles.articleShow&d=17844 

 

 

Posted in Developer | Tagged , , , | 3 Comments

ArcObjects .NET Snippet Finder

New for .NET developers at 9.3 is the ArcGIS Snippet Finder.   This is a neat tool for finding commonly used blocks of code you can use in your application development.  In this video, Don Kemlage from ESRI’s .NET development team takes a few moments to describe this new tool and how to get the most from it to shorten your development time with solid blocks of useful ArcObjects code.   The Snippet Finder contains a few hundred snippets to start with, but more are being added.

     

Posted in Developer | Tagged , , , , | Leave a comment

ArcGIS 9.3 .NET developer help: improvements, tips, tricks

The recent release of ArcGIS version 9.3 has been an opportunity for ESRI to improve the developer help system significantly.  Feedback during the beta cycle helped make additional improvements to help developers find the content they’re looking for so that they are more productive when coding against these APIs and components.

In this video, Don Kemlage from ESRI’s ArcGIS .NET development team takes a few minutes to describe many of these improvements.  Discussed are enhancements to the samples, code snippets, help topics, and walkthough tutorials.  Don also describes some neat tips and tricks for searching and filtering results.

        
 

 

Posted in Developer | Tagged , , | Leave a comment