Select to view content in your preferred language

Error updating metadata in ArcObjects 10

1005
1
10-28-2010 06:10 AM
JoseGarcia
Emerging Contributor
Hi

When updating metadata in ArcObjects 10 using a code similar to this:

Dim lyr As ILayer = ...
Dim pDLayer As IDataLayer
Dim pName As IName

pDLayer = CType(lyr, IDataLayer)
pName = pDLayer.DataSourceName
metadata = CType(pName, IMetadata)

Dim metadataPropSet As ESRI.ArcGIS.esriSystem.IPropertySet
Dim metadataXPS As IXmlPropertySet2

metadataPropSet = metadata.Metadata
metadataXPS = CType(metadataPropSet, IXmlPropertySet2)

' Set some properties
metadataXPS.SetPropertyX(metadataProperty1, value1, esriXmlPropertyType.esriXPTText, esriXmlSetPropertyAction.esriXSPAAddOrReplace, False)
metadataXPS.SetPropertyX(metadataProperty2, value2, esriXmlPropertyType.esriXPTText, esriXmlSetPropertyAction.esriXSPAAddOrReplace, False)

' Save metadata             
metadata.Metadata = metadataXPS


I'm getting an exception:

System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
   at ESRI.ArcGIS.Geodatabase.IMetadata.set_Metadata(IPropertySet ppPropertySet)


This only happens when i install the extension i'm creating and use it from ArcGIS 10. Running from Visual Studio IDE the same code executes correctly.

Any help is welcome.

Thanks in advance,
Jose
0 Kudos
1 Reply
JoseGarcia
Emerging Contributor
Hi

Finally seem clear the problem.

If ArcGIS 10 has no permissions to update the metadata file (installed in Program Files folder) is returning this bizarre exception instead of a understandable exception that can be managed correctly to provide useful feedback about the problem.

In ArcGIS 9 same configuration seem working ok.

Regards,
Jose
0 Kudos