I had a bit of trouble running this down. Thought it might help someone.
IMxDocument pMxDoc = (IMxDocument)ArcMap.Application.Document; IContentsView pTOC = pMxDoc.CurrentContentsView; IFeatureLayer exportLayer = (IFeatureLayer)pTOC.SelectedItem; // Selected Layer if (!exportAll) { IFeatureLayerDefinition iDefLayer = (IFeatureLayerDefinition)pTOC.SelectedItem; exportLayer = iDefLayer.CreateSelectionLayer(pTOC.Name, true, null, null); // Selected features } Geoprocessor gp = new Geoprocessor(); gp.OverwriteOutput = true; gp.AddOutputsToMap = false; LayerToKML layerToKML = new LayerToKML(); layerToKML.layer = exportLayer; layerToKML.layer_output_scale = 10000; layerToKML.out_kmz_file = fileName; try { object result = gp.Execute(layerToKML, null); messages = new string[gp.MessageCount]; for (int i = 0; i < gp.MessageCount; i++) { messages = gp.GetMessage(i); } return true; } catch (Exception ex) { messages = new string[gp.MessageCount]; for (int i = 0; i < gp.MessageCount; i++) { _logger.Error($"GP Message #{i} :"+gp.GetMessage(i)); } return false; }