GxCatalogClass not in 10.1 anymore?  Causes error.

1507
6
08-01-2012 09:53 AM
PeteAtwood
New Contributor II
Hi,
I have code running in 10.0:

Dim pGxObject As ESRI.ArcGIS.Catalog.IGxObject
pGxCatalog = New ESRI.ArcGIS.Catalog.GxCatalogClass

This gives me an error message upon upgrading to 10.1, it appears GxCatalogClass no longer exists.  Anyway to make my code work in 10.1?  I'm trying to gain access to the GetObjectFromFullName method.

Thanks,
Pete
0 Kudos
6 Replies
EricWeber
New Contributor III
Hi,
I have code running in 10.0:

Dim pGxObject As ESRI.ArcGIS.Catalog.IGxObject
pGxCatalog = New ESRI.ArcGIS.Catalog.GxCatalogClass

This gives me an error message upon upgrading to 10.1, it appears GxCatalogClass no longer exists.  Anyway to make my code work in 10.1?  I'm trying to gain access to the GetObjectFromFullName method.

Thanks,
Pete


GxCatalogClass definitely still exists in the ESRI.ArcGIS.Catalog namespace:

http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//00140000002p000000

I have upgraded to 10.1, and the catalog object in the add-in I'm currently working on is still working the same as it did before. I notice in your code that you're declaring a variable, pGxObject, and then initializing a variable, pGxCatalog. Shouldn't those be the same?
0 Kudos
PeteAtwood
New Contributor II
Whoops...  Copied the wrong variable, should be:

Dim pGxCatalog As ESRI.ArcGIS.Catalog.IGxCatalog
pGxCatalog = New ESRI.ArcGIS.Catalog.GxCatalogClass

When the code runs it says "InvalidCastException was unhandled" Unable to cast object of type 'System.__ConObject' to type 'ESRI.ArcGIS.Catalog.GxCatalogClass'.

This was working in 10.0 but not now in 10.1.

Thanks for your help!
0 Kudos
JohnKoch
New Contributor

I realize this is an old post, but I was having the same problem with setting an IGxCatalog variable to a new GxCatalogClass, and the other suggestions did not help (someone on StackExchange (arcgis 10.0 - Cant cast to IGxCatalog - Geographic Information Systems Stack Exchange) suggested using the Activator class, also.)

You did not mention if you were running this inside an Esri program like ArcMap or ArcCatalog, but for us, running inside ArcMap, I found that at 10.1+ ArcMap implements the IGxApplication interface, which has a Catalog property, and using that method worked.  For us.

The properties of IGxApplication and the classes that implement it are available here:

ArcObjects Help for .NET developers

EricWeber
New Contributor III
What line causes the exception? Is it when you create the new gxCatalogClass object, or does it occur at some point after those two lines of code?

Are your references updated to the 10.1 SDK? For example, the ESRI.ArcGIS.Catalog namespace's path should be:
C:\Program Files\ArcGIS\DeveloperKit10.1\DotNet\ESRI.ArcGIS.Catalog.dll
I don't think this is your problem (since I guess you would have compile errors and wouldn't even be able to build the project), but you might want to verify anyway.
0 Kudos
PeteAtwood
New Contributor II
All libraries point to 10.1
0 Kudos
JohnHauck
Occasional Contributor II
Are you binding to Desktop or Engine? Starting at the 10.0 release each product has it's own install directory and you must call bind for standalone applications. This will essentially tell the application what product directory to pull its ESRI resources from. The Catalog assembly is provided with Desktop only so if you are binding to Engine you would expect to get an error because the Engine product doesn't have the Catalog assembly.
0 Kudos