Beware Using .NET Generics in ArcGIS Customizations

Posted by Dave Bouwman | Posted in .NET, ArcGIS Devt | Posted on 31-08-2007

1

We’ve been having some issues where Visual Studio 2005 crashes when building some of our projects. Nothing graceful here – the IDE just disappears. To make things more fun, it’s inconsistent, but for some projects it’s happening about 80% of the time. As you can imagine this is wasting a ton of time and is incredibly frustrating.

Today I was working on enhancing our MSBuild scripts to do something more elegant than just building one master solution and I ran into the same problem – only this time I could see an error message:

    Target UnmanagedRegistration:
        C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets : warning : Type library exporter warning processing ‘Sanborn.ArcEnterprise.Productivity.Query.sbenumQueryStepTypeCollection, ArcEnterprise.Productivity.Query’. Warning: Type library exporter encountered a type that derives from a generic class and is not marked as [ClassInterface(ClassInterfaceType.None)]. Class interfaces cannot be exposed for such types. Consider marking the type with [ClassInterface(ClassInterfaceType.None)] and exposing an explicit interface as the default interface to COM using the ComDefaultInterface attribute.

Shazam! The error message actually tells you what’s wrong and how to solve it! Only you can’t see this message when building in the IDE if the IDE crashes.

The problem in a nutshell is that there are no COM types which can be mapped to .NET Generics, and when the type exporter tries to export them, it sometimes causes the compiler and Visual Studio to bomb. (For those not using generics, I recommend checking them out – here’s an intro)

Since we are doing ArcGIS Development, most of our assemblies are marked to be registered for interop when they build.

reg-for-com

By default, the type exporter tries to export all classes in the assembly for COM interop. To avoid this, you just decorate your classes with some attributes which stop the class from being exported.

Specifically, you should decorate any classes which inherit from generics, or have a generic type in a method signature, or implement an interface that has a generic in a method signature. The example below shows the syntax in VB.NET

   10  <ComVisible(False), ClassInterface(ClassInterfaceType.None)> _

   11     Public Class sbenumQueryStepTypeCollection

   12         Inherits ReadOnlyCollection(Of sbenumQueryStepTypeClass)

 

You’ll also need a using/import statement for System.Runtime.InteropServices.

If you have defined interfaces which have generics in the method signature, just use the <ComVisible(False)> attribute.

Imports System.Runtime.InteropServices

    <ComVisible(False)> _

    Public Interface ICreateViewScriptsPluginView

Once I made these changes, MSBuild was stable, and it seems like builds in Visual Studio are now stable as well.

The GIS Community is an Archipelago…

Posted by Dave Bouwman | Posted in Blogging, General | Posted on 18-08-2007

7

One way to get a conversation started is to bring up something the entire group has in common – in this case the “G” in GIS… and so the un-conversation continues.

[This started as a comment on Aaron's GISDevCafe, but got longish, and so it's here.]

I agree that there is something of a lack of cohesion and conversation between the various users/bloggers/analysts/forum-ers/managers/conference-ers etc involved in “GIS”.  And I think the reason is quite simple – I believe that the GIS “world” is fracturing. Or, looking at it differently - people have been specializing. 

For a long time GIS users were all-around technologists. Pretty much everyone worked directly with data. We all handled weird projections and conversion of strange data formats. Serious thought was put into how to run an analysis because the processing would take so long that you could not simply run it again. Automation was limited but we did what we could and many poor souls took on sed, awk and grep with reckless abandon. Although we may have been using GIS for different purposes, we could all talk about the largely shared experience of “doing” GIS. 

Over the last 5 years, this specialization has been accelerating. I think this is especially prevalent in the developer community, where we have, by necessity, jumped into the software development/engineering pool. Heck we now have our own ESRI conference. The spatial analysis people have headed towards Model Builder / Python land and lived with days of processing time, or gotten all serious and hit it with C++ and GDAL/OGR to get some performance. Data Managers have become DBAs. The meta data crew are now working with Xml and Xslt .  And the web crew have ripped into Xml, REST, Javascript and Ajax. Hell – Google Maps pretty much defined “Web 2.0″. Throw in open source & mashups and you’ve got quite a ruckus just in “online maps”.

As for me, I spend much more time reading .NET & software development blogs than PlanetGeospatial or anything from ESRI. Sure the ESRI blogs are good, but they are still very much about the mechanics. I’ve specialized to the point that I know we can solve the mechanics (sometimes with hacks) but I want to know more about the best way to design the software - for testability, re-use and maintainability. And these topics are never discussed in the GIS “space”. Thus, I spend my time and consequently my “conversations” at locations where these topics are discussed. And this same thing is going on all over the place. Specialization is rampant.

Add to that the fact that there are few really “new” core GIS concepts, and the “GIS Community” as a whole has little to talk about – other than ESRI licensing or other “shared experience” items – Google’s new re-routing feature etc. We are now a whole set of smaller communities, specialized in our own areas, and united by the “where” of the data we work with. And Aaron put it quite nicely…

I see a microcosm of isolated islands loosely held together by the ocean of Geography

And essentially that’s where we are – the “Archipelago of GIS”.

Some may see this as “bad”, but I don’t think so. It’s just a function of a maturing Information Technology sector. Back when Databases were the “new” thing I’m sure there were loads of discussions about all kinds of stuff – like normalization and set theory. Do you think DBA’s are all yearning for those old days? Nah – I’m thinking they kinda like stuffing Xml documents into tables and being able to use SQL and XPath to query them and still getting response times only dreamed of back in the day.

GIS is merging into mainstream IT, and I for one welcome our new better-paying overlords.

New Feeds in ArcExperts.net

Posted by Dave Bouwman | Posted in ArcGIS Devt, Blogging | Posted on 15-08-2007

1

arcexperts-site-title

Just a quick note that I’ve added 5 feeds to the ArcExperts.net aggregator. They are:

Just a reminder – if you write a GIS Development blog and want to see it in the ArcExperts aggregator, just use the contact me link at the top (and I promise to add feeds faster in the future!)

Future of ArcDeveloper.net…

Posted by Dave Bouwman | Posted in ArcGIS Devt, Blogging | Posted on 15-08-2007

5

As I sit here looking at my little $10/month hosting account, I’m seeing that ArcDeveloper.net is taking up a lot of space, and getting relatively little traffic. In addition, I believe that the vast majority of the “1279″ the registered users are actually spam accounts which never activated because their email addresses were bogus. And you can bet I’m enthusiastic to dig in there and clear them all out. 

On the bright side, Google Analytics shows a consistent 100 or so visits a day, with 70% of the traffic coming from Search Engines – at least it shows that people are searching for what the few participants are discussing.

arcdeveloper-analytics

And I know from talking to some of you that it has been a good resource from time to time. But, as ESRI is now fully supporting .NET 2.0 (a primary reason for starting this up), and their forums are threatening to add RSS feeds any day now, perhaps this site’s time has come and gone.

The question for me (and I guess for you) is – should I keep it going? I’ve got a lot of other stuff on the go, and so promoting/maintaining the site is just not happening. The wider ESRI Developer crowd has not jumped in either – I’m guessing it has too much overlap with the main support forums.

If people think it’s still useful, please let me know in the comments, or via the Contact link at the top of this page. Is there anything else you’d like to see on the site? Different forums? Should it be running on different software (Community Server does many things “ok”, but nothing really well in my opinion – and it’s a pain to administer).

What would drag me in is one or two simple forums:

1) Agile Development and ArcGIS – which would cover things like Test Driven Development, Continuous Integration, Automated builds, WiX, Sandcastle, and all the other good “goo” that goes around a successful development team.

2) Quick Hits – killer questions and  simple solutions. Kinda like a light-weight community blog where you can post questions that just are not going to get any play at the ESRI forums, and where people without blogs can post how-to’s.

Another option would be to kill Community Server all together and slap up a semi-secured wiki (i.e. read-only for public, editable for email validated users). Much more free-form, but that also has it’s uses.

Anyhow – let me know what you think the future of ArcDeveloper.net should be. If someone else wants to take over the site (and move it to their hosting account) I’d be up for that too.

Cisco VPN Client Causing LAN Problems…

Posted by Dave Bouwman | Posted in Security | Posted on 14-08-2007

3

cisco I’ve been doing some work for a client and in order to connect to their system, I need to use a Cisco VPN client. I ran into some problems, and after asking Google about it, really did not find anything useful. So – for the sake of others who may run into this – here’s what happened.

After installing the VPN client on my main development workstation, I noticed that connections to other servers on our LAN were slow. Really slow. 30-60 seconds to connect, and the same time to list files in a folder. Essentially I could not use my workstation to do anything on my LAN. This is a problem because nearly everything I work with in enterprise system development is NOT on my workstation – the database, ArcGIS Server, Visual Studio Templates, AzMan etc.

We eliminated problems with my domain account by having other users log into my system, and having me log into other systems. Anyone who logged into my box experienced this same behavior. If I logged into another box, connections to LAN resources were just fine. The problem was isolated to my Windows XP workstation (SP2). 

I un-installed the Cisco VPN client, only to find that the problem did not go away. I tried to restore my system to a previous check point, but that failed (regardless of how far back I chose to go). From here, I turned to our IT group and after a lot of remoting into my box, it was determined that re-paving the box was likely the solution.

While that system was being re-built, I still had to address my client’s needs. So I installed the same Cisco VPN client on my notebook and tried to connect via wireless with little success. After some calls to the client’s IT group, apparently this VPN client does not jive with wireless – no specifics, just “use the LAN”. Since the Ethernet adapter on my notebook is toasted, I warily installed the VPN client on yet another workstation. As soon as it was installed, I experienced exactly the same behavior as on my workstation – exceptionally slow LAN connectivity. Thinking I had just signed up another workstation for re-paving, I tried using system restore, and this time it worked.

I then went back to my notebook and tried accessing LAN resources – and it too has the very slow LAN access. Three out of three – I think I can say that it’s the Cisco software! I can live with this on my notebook since I don’t do any development with it – mainly presentations and research type coding. I was able to dig up an old USB to Ethernet converter, got hooked into Ethernet, and am working away on my client’s system. Getting files to my notebook has devolved into sneaker-net +USB-drive fun and games. And my main workstation is up and running again (still need to install ArcGIS Desktop et al)

Solutions

I don’t have any solution that keeps the VPN client on the box. Maybe upgrading, but in talking to others, it sounds like you need to keep the client and server sides of the VPN in synch, so that may not be an option.

  1. Un-install the VPN client if at all possible – dedicated an old PC for VPN access if you can.
  2. Try doing a system restore in Windows XP – restore to a date prior to installing the Cisco VPN client.
  3. Failing that, you’re looking at a re-format & re-install your OS. Have fun!

Some stuff for Google…

Software Version: Cisco VPN Connection 4.8.01.0300, Windows XP SP2
Keywords: Slow LAN Windows file share network mounted drives

Agile Update…

Posted by Dave Bouwman | Posted in Blogging, Fundamentals, Productivity | Posted on 10-08-2007

0

Back at the 2007 ESRI Developer Summit, I did a presentation on “Being Agile“. At that time, I mentioned that we simply followed general agile principles, but did not particularly follow any doctrine. For a variety of reasons we have had to become more formal in our quest for agility, and have adopted Scrum.

For those not familliar with Scrum, it’s a very light-weight project managment methodology that’s based on agile principles. Work items are managed in a set of backlogs and are done in a series of 2 or 4 week sprints at the end of which they produce a “potentially shippable product increment. Here’s a good diagram that shows it all. Every day the team meets for 10-15 minutes to repost status – this is the “scrum”.

What’s really nice is that there are alot of success stories that one can reference with “selling” Scrum within an organization and to clients. Not to mention a slew of great books. Including what I’d recommend as a really good intro to the topic  Agile Project Management with Scrum (Microsoft Professional) by Ken Schwaber.

Thus far, I have to say that it’s the best way to develop software that I’ve ever seen. It’s easy – nothing in it seems to be “extra” – to put it another way – no TPS reports. Things proceed smoothly, the team is all bought in, and we are cranking out the code. Last week my co-worker Chris Spagnuolo and I attended a “Certified Scrum Master” training course in Denver. Led by Mike Cohn (blog), this was a great two day class that covered everything you need to know to run a scrum team – aka being a “scrum master”.

We liked this initial class so much that we are heading out to Orlando in September for Mike’s course on Agile Estimating (here’s Mike’s book on the same topic and YouTube videos – part 1 and part 2 - of a presentation he gave @ Google in March 2007). We are really excited about this because it will be driven by the detailed historical data from our team’s sprints and it should be more much more accurate than other “gut-based” estimating systems.

If this sort of thing strikes your fancy, Chris Spagnuolo (our “scrum master”) has started a GeoScrum blog where he will be covering the on-going journey of managing a cutting edge geospatial development group with Scrum. We are constantly adapting the process and our tools and Chris will share tips on what works and what doesn’t, as well as general project managment zen.

Secure ArcMap Commands with AzMan

Posted by Dave Bouwman | Posted in Uncategorized | Posted on 08-08-2007

0

Following up on a previous post about using Authorization Manager to implement Role Based security in your application, I’ve created a simple example that shows how to use AzMan to control access to commands in ArcMap (or ArcCatalog, or anything really).

As noted in that post, if you are working on Windows XP you will need the Windows Server 2003 admin kit, which will install the AzMan library and it’s management console (azman.msc), which you will need before you can run the example.

About the Sample

Before we jump into the code and how to configure it on your system, let’s review the sample. The premise here is that you have two “special” types of users on your system – “managers” and “power users”. You want to create tools that are specifically for these users, but you also want to ensure that other users can not access to these tools. Maybe these tools allow the managers to grant formal “approval”, or allow the power user to circumvent some business logic to handle some corner cases. Whatever the reason, I’ve seen this to be a common scenario in Citrix hosted environments where everyone runs exactly the same dlls and you can’t solve the problem by simply not installing certain tools on some machines.

In the sample, the tools themselves do nothing more than pop message boxes indicating if you have access to the command – after all the point of the sample is how to apply security, not to implement some particular business logic. ;-)

Getting it Running

The main thing you need to do is edit the AzMan repository to grant your self access to the commands. Once you have done that, you’ll need to edit the path to the AzMan repository file in the command classes. For a real implementation I’d suggest pulling the path to the repository from the ArcMap.exe.config file, or store it in an application extension.

Step by Step

First, download the code.

Next, unzip it somewhere. You should have a folder structure like the one shown below.

Assuming you have AzMan installed, go to Start –> run azman.msc. This will open AzMan. Right click on the top level node and navigate to the repository xml file shown above. Open this in AzMan. Open up the tree a little until you can see the Role Assignments folder.

Now,  all you have to do is add yourself to the role. To do this, right click on the Role (Managers or Power Users) and select “Assign Windows Users and Groups…”. You will then get a standard windows dialog for selecting users and groups. Simply type in your windows login and click “Check Names”. If you are on a domain, you will need to add that in like this DOMAIN\username. If you are using a local login, just your login name should be fine. Once you’ve added yourself, it should look like this…

Next, open the solution in Visual Studio 2005. Open up the ManagerCommand.cs and PowerUserCommand.cs files. You need to change the path to the AzMan file. There is a private member variable setup for this – just change the path to where your repository file is located.

private string _pathToAzManFile = “msxml://g:/your/path/here/dabo_repository.xml”;

Finally, build it. This will register the commands in ArcMap. Then open ArcMap, got to Tools –> Customize, and in the “DaBo_Sample” category you will find two commands – Manager Command and Power User Command.

Drag these onto a toolbar, and click away. Depending on your access, you’ll get different message boxes.

Summary

Although this sample is very simple, and by no means shows any sort of best practices as far as coding standards go, it does show how easy it is to use AzMan to check security credentials from within ArcMap. There are lots of places you can go from here, and over the following months I’ll post about some of the ways we are implementing this on various projects.

ESRI Known Bugs List… Coming Soon?

Posted by Dave Bouwman | Posted in Uncategorized | Posted on 07-08-2007

2

I seemed to recall hearing something at the User Conference about ESRI publishing a list of all know issues with ArcGIS. We have been doing some design work relating to proactive topological validation, and wanted to do to a little digging to see if there are any known issues with the interfaces we’ll be relying on.

I dug back through some emails to find the  link to the Pre-Conference Questions where I thought I saw this mentioned. After linking off th the ESRI site, I found this  item (screen cap below) 

 

As of now (August 7, 10:30am MST) there is nothing on the support site, but I did find news of this on the Support Center News blog. Apparently things are “close” – quote from the blog…

At this point, we’re waiting on a few last-minute changes that will help make sure that the bug info you’ll be seeing will make as much sense as possible.

So – I’ll sit on my hands for a few more days and then give it a good shakedown when it comes online.

PC Synchronization Tools

Posted by Dave Bouwman | Posted in Productivity | Posted on 06-08-2007

1

Thought I’d share a little about two tools that help keep my computing life sane. I regularly work on 3 different PCs – my development box at work, my home PC and my notebook, and I need a few things to be consistent across all of them.

Bookmarks

Like a lot of people, my bookmarks have become an extension of my brain. I don’t pay attention to a site’s Url, I just remember where I filed the bookmark. So it’s really important to me that all 3 systems have the same bookmarks, and that they all update each other. I’ll also note that I’ve also become totally addicted to the FireFox Bookmark toolbar. Having all my bookmarks easily available in folders across the top of the browser is very efficient.

 When I used to use IE, I would create folders below Favorites\Links and get the same sort of functionality.  

But, to the point of this - FoxMarks is a FireFox add-in that facilitates synchronization of your FireFox bookmarks across multiple machines. It’s super simple to  use, and it just works. Get it. Use it. Love it. 

File Synchronization

While I don’t need everything synched up all the time, I regularly need files moved between all three systems – particularly presentations. Foldershare solves this problem really elegantly. You have to install a small program that runs on each PC and connects across the net to securely synch pre-determined folders. The synchronization is real-time while you are connected. If you go offline for a while, it will automatically re-synch as soon as you re-connect.

Additionally, you can access the shared files from any web browser by simply logging into the FolderShare site – a nice feature (although I’ve never used it), and a good reason to use a strong password!

Although you can share whatever folders you want, I try to keep this simple, I just create a “Shared Desktop” folder on my desktop. Anything I want replicated I just drop in there. This is sooooooo much easier than toting things around on USB memory sticks etc. I’ll also mention that Microsoft bought FolderShare and thus this is now a “Windows Live service”. And it’s in “beta”. ;-)

Taking the Plunge: Moving to Subversion…

Posted by Dave Bouwman | Posted in Devt Tools, Team System | Posted on 06-08-2007

1

This week I will be transitioning from Microsoft Team System to Subversion for our source control system. There are two main reasons for this change - cost and ease of use.

Cost

The cost issue is two fold – first there is the internal cost of using the Team Editions of Visual Studio. For the MSDN subscription, Team Edition (not Team Suite) runs $1000 more per develper, per year than Visual Studio Professional. While this is not bad for a small team, it’s prohibitive if you are looking at growing significantly, or standardizing across large group. I can think of many useful ways to spend $7,000 per year besides sending it to Microsoft. Not that Team System is not cool and useful, but in the end, I just don’t see it being $7,000 per year cooler than Subversion + TRAC (open source issue/bug tracking system) and that’s the real bottom line – value. 

The second cost aspect is somewhat inverse – if we are using Subversion and an open source build/unit testing/coverage/installer stack, then we can ship this to our clients. Since we build state level enterprise systems, and most of our clients expect to take on the longer term support and maintenance of the system, there is some serious value in being able to turn it all over to them as a comprehensive development platform. If we are on Team System, then it would be doubtful if we could ship the whole stack.

Ease of Use

Since Team System is fully integrated into Visual Studio Team Edition, the user experience for most things is pretty good. Actually I really like the check-in rules you can implement. However, we have had many issues working with web projects, as well as dealing with “other” files such as CodeSmith templates. Of course CodeSmith does not “know” about Team System, so it can’t automatically “check out” the files prior to editing them. Since Team System sets your working copy to read-only when you check in (there may be a way to change this – not sure), in order to make a change to my template, I need to open Visual Studio (slow), connect to Team Server (slow), navigate to the templates in source control, check out the file, make the change, go back to Visual Studio and check in the file again. Compared to working with  Subversion, this is a major pain.

The Transition

At this point we have our Subversion server setup, and our domain accounts are authenticating through Apache. All is well. The next step is at the end of our current Sprint, get the latest code from Team System, do a build, run all the tests, clean the solutions (using Omar Shahine / Jeff Atwood’s Clean Sources) and then load the files into Subversion. I did some Googling for tools which would take the history etc. along for the ride, but I did not find anything. At this point we are early enough in the project where losing history would not be too much of a problem, and we’ll be able to have the Team Server running for at least 6 months incase we really need to get some old version.

Tools

At this point we are planning on using the very well regarded TortoiseSVN as the main client for Subversion, but we’ll also be trying AnkhSVN and VisualSVN to handle the Visual Studio integration. I’ll let you know how those tools pan out.