AnsweredAssumed Answered

Dataset from AFTable does not get imported (AF Client 2014)

Question asked by AvanadeShellSSP on Sep 15, 2015
Latest reply on Sep 16, 2015 by AvanadeShellSSP

Currently I'm working on a sync between two AF databases.

For this I'm using AfDatabase.PISystem.ExportXml and AfDatabase.PISystem.ImportXml. When using AF Client 2014, the AF Table gets created correctly, but the content is not imported.

In AF Client 2015 both creation of the table as importing of the content is working, but I'm currently not able to upgrade the client on this specific environment.


In the release notes of AF Client 2015 I've found the following bug fix related to this:

37499 - The XmlImport method of the AF SDK could skip objects when the Xml was created with an XmlWriter with no formatting, such as might occur when using a MemoryStream. This issue was only possible via custom programs.


Is there a way to work around this when using AFSDK v2.6.1.6238?


This is the code we are using to export and import:


ExportAfObjectToXml(AfDatabase, PIExportMode.Library);

private string ExportAfObjectToXml(object exportObject, PIExportMode piExportMode)
  using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture))
  var xmlWriter = XmlWriter.Create(stringWriter);

  AfDatabase.PISystem.ExportXml(exportObject, piExportMode, xmlWriter, null, null, eventHandler);

  return stringWriter.ToString();



/// <summary>
  /// Import the AF XML string for a library to this database.
  /// </summary>
  /// <param name="xmlSourceLibrary">The XML string to import.</param>
  /// <exception cref="System.ArgumentException">xmlSourceLibrary</exception>
  public void ImportLibrary(string xmlSourceLibrary)
  if (string.IsNullOrEmpty(xmlSourceLibrary)) throw new ArgumentException(Resource.ElementHierarchyRepository_ImportLibraryXmlStringCannotBeEmpty, "xmlSourceLibrary");
 ImportAfObjectFromXml(xmlSourceLibrary, AfDatabase);

  private void ImportAfObjectFromXml(string sourceXmlSource, object importObject)
  using (var stringReader = new StringReader(sourceXmlSource))
  var xmlReader = XmlReader.Create(stringReader);

  PIImportMode.AllowCreate | PIImportMode.AllowUpdate | PIImportMode.CreateConfig |
  PIImportMode.CreateCategories, xmlReader, eventHandler);