2

I am trying to execute the below sample code Copying or loading data while preserving GlobalID values from ArcObjects 10.1 help. I am creating IWorkspace from FileGDB-Path using workspaceFactory.OpenFromFile and passing to this function.

// Converts a GlobalID field to a GUID field.
public static void ConvertGlobalIdToGuid(IWorkspace workspace, String datasetName)
{
    // Open the table.
    IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;
    ITable table = featureWorkspace.OpenTable(datasetName);

    // Get the GlobalID field.
    IClassEx classEx = (IClassEx)table;
    if (!classEx.HasGlobalID)
    {
        throw new Exception(String.Format("No GlobalID column in table: {0}.",
            datasetName));
    }
    String globalIDFieldName = classEx.GlobalIDFieldName;

    // Convert the GlobalID column to a GUID column.
    IClassSchemaEditEx classSchemaEditEx = (IClassSchemaEditEx)table;
    classSchemaEditEx.UnregisterGlobalIDColumn(globalIDFieldName);
}

But unfortunately, i am getting exception on the line

IClassSchemaEditEx classSchemaEditEx = (IClassSchemaEditEx)table;

Exception trace:

System.InvalidCastException was unhandled
  Message=Unable to cast COM object of type 'System.__ComObject' to interface type 'ESRI.ArcGIS.Geodatabase.IClassSchemaEditEx'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{F14139C3-B498-4B42-AA6C-5960028554E0}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
  Source=CMSS.Windows.FGDB.Utilities
  StackTrace:
       at CMSS.Windows.FGDB.Utilities.frmUtilities.ConvertGlobalIdToGuid(IWorkspace workspace, String datasetName) in C:\Dev Temp\CMSS.Windows.FGDB.Utilities\CMSS.Windows.FGDB.Utilities\Form1.cs:line 40
       at CMSS.Windows.FGDB.Utilities.frmUtilities.btnConvertGlobalId_Click(Object sender, EventArgs e) in C:\Dev Temp\CMSS.Windows.FGDB.Utilities\CMSS.Windows.FGDB.Utilities\Form1.cs:line 86
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at CMSS.Windows.FGDB.Utilities.Program.Main() in C:\Dev Temp\CMSS.Windows.FGDB.Utilities\CMSS.Windows.FGDB.Utilities\Program.cs:line 22
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
       at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
       at System.Activator.CreateInstance(ActivationContext activationContext)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

I have tried re-install/new-install the ArcObjects SDK. But the exception still occurs.

It would be helpful, if someone give some idea about this problem. Thanks.

1 Answer 1

3

The help file for this Interface says "These methods apply to unversioned ArcSDE feature classes and tables only". But you say you are accessing a file geodatabase, I guess this is the problem?

3
  • Yes, you are correct. Do you know any other to achieve this for file geodatabases?
    – vasudevanp
    Jan 30, 2014 at 15:55
  • 1
    Looks like this guy was trying the same thing 2 years ago but got no response...
    – Hornbydd
    Jan 30, 2014 at 16:25
  • Finally, I have loaded my File GDB in ArcSDE and achieved this. Thanks.
    – vasudevanp
    Jan 30, 2014 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.