Error trying to import metadata using MetadataImporter_conversion

Discussion created by gis_tech on Oct 11, 2012
Latest reply on Apr 24, 2014 by pk_davidson
I'm trying to write a script for updating the metadata in a geodatabase by importing XML files. What the script does is to loop through a geodatabase and collect the names of every feature class. Then, it looks for an XML file whose name is equal to the name of the feature class + ".xml".

Unfortnately, I'm getting the following error and I don't know what it means "Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly GpMetadataFunctions".

The XML file is in the same directory that houses the GDB and the python script. My script and the full error are as follows. Any help would be tremendously appreciated.

import arcgisscripting, arcpy, os, sys
from arcpy import env
from arcpy import mapping

gp = arcgisscripting.create(9.3) 

# Set the current workspace by passing the name of the geodatabase
# for example: python HomeViewGeoPlatfrom.gdb
gdb = sys.argv[1]

folder = gdb
env.workspace = folder

# The following file will serve as a list of what we've done and will provide links for pasting into the config file
LogFile = open(folder.replace('.gdb','')+'LogFile.csv', 'w')
LogFile.write("FeatureClass,XMLFileNameGuess,Results" + "\n")

def listFcsInGDB(gdb): 
    ''' list all Feature Classes in a geodatabase, including inside Feature Datasets ''' 
    gp.workspace = gdb 
    print 'Processing ', gp.workspace 

    # create an array that contains the names of all of the FeatureClasses in the geodatabase
    # this info will be used for making a list of XML files with similar names
    fcs = [] 
    for fds in gp.ListDatasets('','feature') + ['']: 
        for fc in gp.ListFeatureClasses('','',fds):
            # If you want to include the name of the FeatureDataset in the XML file name, use this line
            # fcs.append(os.path.join(fds, fc))

            # The following line does not include the FeatureDataset name in the XML file name
    return fcs 
fcs = listFcsInGDB(gdb) 
for fc in fcs: 
    print fc    

    #  the field name, type, and length.
    layer = fc
    # Phase to add in between Popup and Layer Name.xml
    LookForThisXMLFile = layer.replace("\\","_") + ".xml"
        arcpy.MetadataImporter_conversion (LookForThisXMLFile,fc)
        LogFile.write(layer + "," + LookForThisXMLFile + "," + "Success" + "\n")
    except Exception, e:
        LogFile.write(layer + "," + LookForThisXMLFile + "," + e + "\n")


C:\Data\GISData\>python Test.gdb
Processing  Test.gdb

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'GpMetadataFunctions, Version=, Culture=neutral, PublicKeyToken=8f
c3cc631e44ad86' or one of its dependencies. The system cannot find the file specified.
File name: 'GpMetadataFunctions, Version=, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86'
   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boo
lean throwOnFileNotFound, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence
 assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence as
semblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString) at GetManagedType(Char* _assembly, Char* _path, Char* _className)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].