<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Why am I getting COMException Error in ExportOperation in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/why-am-i-getting-comexception-error-in/m-p/557992#M3760</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hope someone can help me with this... I've been searching for a week or more... can't find an answer...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I just wanted to export a Feature Class to Shapefile so I can try to do a hotspot analysis...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the code that I'm using and getting the error at pExportOperation = New ExportOperation&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;Dim pMap As IMap = Form1.AxMapControl1.ActiveView.FocusMap&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dim pFeatureLayer As IFeatureLayer = pMap.Layer(0)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'Get the target layer in the map&lt;BR /&gt;Dim pFeatureClass As IFeatureClass = pFeatureLayer.FeatureClass&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dim pFeatureLayerDefinition As IFeatureLayerDefinition = pFeatureLayer ' QI from the FeatureLayer&lt;BR /&gt;Dim a As String = pFeatureLayerDefinition.DefinitionExpression.ToString()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'Set the where clause&lt;BR /&gt;Dim pQueryFilter As IQueryFilter = New QueryFilter&lt;BR /&gt;pQueryFilter.WhereClause = a&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'Get the Featureclassname from the featureclass&lt;BR /&gt;Dim pDataset As IDataset = pFeatureClass&lt;BR /&gt;Dim pInFeatureClassName As IFeatureClassName = pDataset.FullName&lt;BR /&gt;Dim pInDsName As IDatasetName = pInFeatureClassName&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'Create Directory if doesn't exist&lt;BR /&gt;If Directory.Exists("C:\Kernel Density Hotspot") Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Directory.Delete("C:\Kernel Density Hotspot", True)&lt;BR /&gt;End If&lt;BR /&gt;Directory.CreateDirectory("C:\Kernel Density Hotspot")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'Define the output featureclass&lt;BR /&gt;'give it the name of the input feature class + exp&lt;BR /&gt;Dim pFeatureClassName As IFeatureClassName = New FeatureClassName&lt;BR /&gt;Dim pOutDatasetName As IDatasetName = pFeatureClassName&lt;BR /&gt;pOutDatasetName.Name = "Kernel_Density_Export"&lt;BR /&gt;Dim pWorkspaceName As IWorkspaceName = New WorkspaceName&lt;BR /&gt;pWorkspaceName.PathName = "C:\Kernel Density Hotspot"&lt;BR /&gt;pWorkspaceName.WorkspaceFactoryProgID = "esriCore.ShapefileWorkspaceFactory.1"&lt;BR /&gt;pOutDatasetName.WorkspaceName = pWorkspaceName&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'Give the output shapefile the same props as the input dataset&lt;BR /&gt;pFeatureClassName.FeatureType = pFeatureClass.FeatureType&lt;BR /&gt;pFeatureClassName.ShapeType = pFeatureClass.ShapeType&lt;BR /&gt;pFeatureClassName.ShapeFieldName = pFeatureClass.ShapeFieldName&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'Export selected features&lt;BR /&gt;Dim pExportOperation As IExportOperation = Nothing&lt;BR /&gt;pExportOperation = New ExportOperation&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;pExportOperation.ExportFeatureClass(pInDsName, pQueryFilter, Nothing, Nothing, pOutDatasetName, 0)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I have used this before in 10.2 now in 10.3 I can't&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried True and False Interop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Standalone system checked the binding with ProductCode.EngineOrDesktop and its good&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried reinstalling the SDK...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using VS 2013...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm just out of ideas...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Mar 2017 08:05:14 GMT</pubDate>
    <dc:creator>Gregory_KevinMorales</dc:creator>
    <dc:date>2017-03-08T08:05:14Z</dc:date>
    <item>
      <title>Why am I getting COMException Error in ExportOperation</title>
      <link>https://community.esri.com/t5/developers-questions/why-am-i-getting-comexception-error-in/m-p/557992#M3760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hope someone can help me with this... I've been searching for a week or more... can't find an answer...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I just wanted to export a Feature Class to Shapefile so I can try to do a hotspot analysis...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the code that I'm using and getting the error at pExportOperation = New ExportOperation&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;Dim pMap As IMap = Form1.AxMapControl1.ActiveView.FocusMap&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dim pFeatureLayer As IFeatureLayer = pMap.Layer(0)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'Get the target layer in the map&lt;BR /&gt;Dim pFeatureClass As IFeatureClass = pFeatureLayer.FeatureClass&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dim pFeatureLayerDefinition As IFeatureLayerDefinition = pFeatureLayer ' QI from the FeatureLayer&lt;BR /&gt;Dim a As String = pFeatureLayerDefinition.DefinitionExpression.ToString()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'Set the where clause&lt;BR /&gt;Dim pQueryFilter As IQueryFilter = New QueryFilter&lt;BR /&gt;pQueryFilter.WhereClause = a&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'Get the Featureclassname from the featureclass&lt;BR /&gt;Dim pDataset As IDataset = pFeatureClass&lt;BR /&gt;Dim pInFeatureClassName As IFeatureClassName = pDataset.FullName&lt;BR /&gt;Dim pInDsName As IDatasetName = pInFeatureClassName&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'Create Directory if doesn't exist&lt;BR /&gt;If Directory.Exists("C:\Kernel Density Hotspot") Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Directory.Delete("C:\Kernel Density Hotspot", True)&lt;BR /&gt;End If&lt;BR /&gt;Directory.CreateDirectory("C:\Kernel Density Hotspot")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'Define the output featureclass&lt;BR /&gt;'give it the name of the input feature class + exp&lt;BR /&gt;Dim pFeatureClassName As IFeatureClassName = New FeatureClassName&lt;BR /&gt;Dim pOutDatasetName As IDatasetName = pFeatureClassName&lt;BR /&gt;pOutDatasetName.Name = "Kernel_Density_Export"&lt;BR /&gt;Dim pWorkspaceName As IWorkspaceName = New WorkspaceName&lt;BR /&gt;pWorkspaceName.PathName = "C:\Kernel Density Hotspot"&lt;BR /&gt;pWorkspaceName.WorkspaceFactoryProgID = "esriCore.ShapefileWorkspaceFactory.1"&lt;BR /&gt;pOutDatasetName.WorkspaceName = pWorkspaceName&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'Give the output shapefile the same props as the input dataset&lt;BR /&gt;pFeatureClassName.FeatureType = pFeatureClass.FeatureType&lt;BR /&gt;pFeatureClassName.ShapeType = pFeatureClass.ShapeType&lt;BR /&gt;pFeatureClassName.ShapeFieldName = pFeatureClass.ShapeFieldName&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'Export selected features&lt;BR /&gt;Dim pExportOperation As IExportOperation = Nothing&lt;BR /&gt;pExportOperation = New ExportOperation&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;pExportOperation.ExportFeatureClass(pInDsName, pQueryFilter, Nothing, Nothing, pOutDatasetName, 0)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I have used this before in 10.2 now in 10.3 I can't&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried True and False Interop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Standalone system checked the binding with ProductCode.EngineOrDesktop and its good&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried reinstalling the SDK...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using VS 2013...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm just out of ideas...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Mar 2017 08:05:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/why-am-i-getting-comexception-error-in/m-p/557992#M3760</guid>
      <dc:creator>Gregory_KevinMorales</dc:creator>
      <dc:date>2017-03-08T08:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting COMException Error in ExportOperation</title>
      <link>https://community.esri.com/t5/developers-questions/why-am-i-getting-comexception-error-in/m-p/557993#M3761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;so after 2 weeks of headbanging on the desk... I have found out the problem...&lt;/P&gt;&lt;P&gt;don't add this both in your code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Engine)&lt;/P&gt;&lt;P&gt;ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;just use this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and everything will be ok...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Mar 2017 05:28:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/why-am-i-getting-comexception-error-in/m-p/557993#M3761</guid>
      <dc:creator>Gregory_KevinMorales</dc:creator>
      <dc:date>2017-03-14T05:28:17Z</dc:date>
    </item>
  </channel>
</rss>

