• VB6 to .NET Migration Series: Getting ready for the ArcGIS 9.4 release

    At the 2008 ESRI International User Conference  we announced that ESRI would no longer support the development of Visual Basic 6.0 applications at the ArcGIS 9.4 release.   Well, it is true.  As we speak, the development team is in the process of removing the VB6 DLLs and dependencies throughout the system.  So what does this mean for VB6 developers that plan to release their software applications on ArcGIS 9.4?  Well here are some inside tips that will help you plan for the future.
     
    migrate 
     
    Visual Basic 6.0 SDK and Runtime
     
    1. The Visual Basic 6.0 SDK will not be delivered with any of the ArcGIS 9.4 products.  Developers will not have access to the VB 6 developer help files, tools, add-ins and utility applications. 
     
    2. The Visual Basic 6.0 Runtime will no longer be installed with any of the ArcGIS 9.4 products.   Therefore, if you still plan to deploy VB applications, you will need to ensure the VB 6 runtime has been installed by another application or you will need to install it as part of your deployment solution. 
     
    Can you still develop with VB6?
    Compilation:  The ArcObjects Type Libraries (OLBs) will still be shipped and installed with ArcGIS 9.4. As a result, as long as you don’t mind not having the ArcObjects VB6 SDK or any development tools, technically speaking, if you have a Visual Basic 6.0 development platform, you can still reference libraries and compile your applications.
     
    Compatibility:  As long as the VB6 runtime is in place, it is possible that your applications will just work on an ArcGIS 9.4 system.  But please remember, while we make every effort to maintain backward compatibility, it is still your responsibility as the developer to reference the type changes and ensure that all applications behave as expected.
     
    Microsoft Support:  In February, Microsoft released a “it just works” support statement indicating that they will continue to support the VB6 runtime on Windows 2008 and Vista; however, it is important to note that the VB6 IDE has gone past the period of extended support.  So that is something you may want to consider this as well.
     
    What about VBA?
    The Visual Basic for Applications SDK will still be released with ArcGIS 9.4 to support VBA development inside of the ArcGIS Desktop applications.  So VBA developers do not need to migrate their applications to .NET.
     
    Should you still be developing with VB6? 
    The bottom line is that if you are planning to develop applications for ArcGIS 9.4 and beyond, we strongly encourage you to start moving your VB6 applications to C#, VB.NET or VC++.
     
    Making the Leap
    You can find a number of articles on MSDN about how to make the switch from VB6 to .NET.  If you are thinking of transitioning to Visual Basic .NET today, there’s also a good set of articles here to get you started.   You’ll find that most of the documentation refers to Visual Studio 2005, but most of it applies to 2008 as well.  That said, you’ll need to decide whether to move to Visual Studio 2005 or 2008.  The current release of ArcGIS 9.3 supports development with both platforms.
     
    Future blog series
    To help you make the transition, be sure to stop by again or subscribe to view the upcoming VB6 to .NET Migration Series for ArcGIS developers.
     
     
     out
     
     
    Feel free to share your comments, links and experience here as well.

     
  • Code Snippets: write 'em, save 'em, reuse 'em

    The “DRY” principle describes an element of programming efficiency:  Don’t Repeat Yourself.  

    One of the tools available to help you with this are Code Snippets.  ArcGIS 9.3 products ship with hundreds of these snippets you can quickly and easily find and use, but how can you create them, add to this repository, and share them with others?

    Back on July 14th, Don Kemlage from the ArcGIS SDK team posted a video here on the blog to describe what snippets are, how to get to the ones we provide with ArcGIS, and how to use the Snippet Finder.   At about 10:50 minutes into that video, Don mentions briefly that developers can make their own snippets too.  In this post here, we wanted to dig a little more into that, and provide some tips on how to do it in more detail.

    Frameworks such as Visual Studio and Eclipse provide several ready-to-use Code Snippets.  You can even add your own snippets into the library, organizing them into a directory structure by the subject or task they accomplish. Creating your own code snippets helps you and your team members have snippets which are greatly customized for your development.

    Code snippets are defined in XML format and are stored with the *.snippet file extension. You can use your favorite XML or text editor or Visual studio or Eclipse to create and maintain them.

     

    Creating Code Snippets in Visual Studio 2005/2008

    MSDN has a nice concise "How To" article on creating code snippets.

    In short, using Visual Studio 2005/2008 start with the File > New > File > XML File menu item.  That allows you to create the new file and save it in place, ready for editing.  Then the next step is to plug in the required information to make it an individual code snippet. Let’s show you an example code snippet, then further below we’ll explore the tags one by one.

     

    Let’s walk through it, top to bottom.

    CodeSnippets
    The <CodeSnippets> element is the root element of the code snippet XML schema and has xmlns attribute value.

    CodeSnippet
    The  <CodeSnippet> element is used to create an individual code snippet and this is where all declarations on your snippet must reside.

    Header, Title, Shortcut, Description, Author, SnippetTypes
    The <CodeSnippet> tag has a <Header> section that contains information needed by the IDE in these additional tags.  Visual Studio gives you a description of what each one does when you hover your mouse on these tags. 

    Snippet
    The <Snippet> tag is a little bit more complex. It contains both the <References> and <Code> tags.

    References
     The <References> tag is used by the IDE to add references to the project when the snippet is inserted. In this example, the code snippet adds a reference to ESRI.ArcGIS.esriSystem.dll when the snippet is inserted. Note that Visual C# code snippets do not support the References section, so a reference to ESRI.ArcGIS.esriSystem.dll must be added to the project manually.

    Code
    The <Code> tag contains the specific code to insert as <Code Language="VB"> that says that the language of the code snippet is Visual Basic. All snippet code must be placed between <![CDATA[ and ]]> brackets. You can also mention (in comments) what ArcGIS Products and which versions (9.2, 9.3) can use this snippet and any other namespaces that you wish the user imports before adding.


    Ok, so after doing this a couple of times they are pretty simple to create.  And whether you write them using Visual Studio or a plain text editor, give each one a *.snippet file extension and use the Tools > Code Snippets Manager menu item to ensure the IDE knows where these folders are.

    Code Snippets not only provide a wide variety of productivity-enhancing solutions and their real power lies in their extensibility. Give them a shot.

  • 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?

  • 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)

     

  • 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:  http://www.youtube.com/esritv

     

  • 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>/plugins

    Step 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

  • 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!

     
  • 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.  

  • 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>\VBA\VBAOF11.msi /qb  (no installation parameters are required)  
    3. <media or administrative installation>\VBA\1033\VBAOF11i.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 

     

     

  • 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.

         

  • 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.

            
     

     

  • Welcome!

    Welcome to the launch of this ArcObjects Development Blog! 

    Our purpose is to create a place where ESRI developers can share topics of interest and spark discussion with developers around the world who are building applications using the ArcGIS Desktop and ArcGIS Engine development kits, using the ArcObjects API. 

    A few months back we created a blog just for ArcGIS Engine developers, but after weighing some ideas and getting some feedback, we decided to broaden the scope.   We continue to see that all developers using the ArcObjects API have a lot of things in common regardless of the actual ESRI product being used.  So to keep things simple, we have decided to retire the old ArcGIS Engine blog, and hope that those who have supported it will continue to receive timely and helpful information about ArcGIS Engine and about ArcObjects in general here.

    We continue to appreciate hearing from you.  We hope you find this blog informative and productive!