<?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 Re: Workspace Factory COMException 0x80040228 in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/workspace-factory-comexception-0x80040228/m-p/649789#M17432</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Neil,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks very much for your (as usual) correct response.&amp;nbsp; Changing the EngineOrDesktop option to Desktop solved the problem with opening the file GDB.&amp;nbsp; I'll have to wrap this in a try/catch block.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I haven't opened shapefiles with AO in a while and seemed to recall having to pass in the actual shapefile name, but I guess I mis-remembered.&amp;nbsp; If I had read a bit further in the help, I would have seen this.&amp;nbsp; I'll note here that the bug doesn't seem to affect opening the shapefile workspace.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Chris.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;The workspace for a shapefile is the directory that contains the files that make up the shapefile.&amp;nbsp; The problem with the code that you posted is that you're passing in the path to the *.shp file, which is incorrect.&amp;nbsp; The workspace for a file geodatabase is also a directory.&amp;nbsp; The workspace for a personal geodatabase is the database file.&amp;nbsp; So, make sure you're passing in the correct path for the type of workspace you're trying to open.&amp;nbsp; A recent thread also suggested that there is a bug when binding using the EngineOrDesktop option.&amp;nbsp; If you have Engine installed but not licensed then the binding will fail even if you have Desktop installed and properly licensed.&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 06 Sep 2011 15:55:57 GMT</pubDate>
    <dc:creator>ChristopherBennett1</dc:creator>
    <dc:date>2011-09-06T15:55:57Z</dc:date>
    <item>
      <title>Workspace Factory COMException 0x80040228</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/workspace-factory-comexception-0x80040228/m-p/649786#M17429</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've seen so many previous posts....&amp;nbsp; Tried all the things I could find, but still get this stubborn error when I try to instantiate a workspace from a file spec.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Environment:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Windows 7, sp 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Intel i7, 8Gb RAM&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Visual Studio 2010, sp 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Arc version: 10.0.2414&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;.NET build target: 3.5&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a very simple example console program to test opening a simple shape file.&amp;nbsp; (I'm actually trying to get a file gdb workspace opened, but that fails as well, so does personal gdb.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;All the other posts I've seen have been resolved by one or the other things I've added into the following code, so I'm turning to the real experts &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
using System;
using System.Text;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.esriSystem;

namespace EngineProj
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; class Program
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [STAThread]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; static void Main(string[] args)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string gdbName = @"C:\Projects\test\lines.shp";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IWorkspace workspace = null;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IAoInitialize ao = new AoInitializeClass();

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ao.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcEditor);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Type factoryType = Type.GetTypeFromProgID("esriDataSourcesFile.ShapefileWorkspaceFactory");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // This line fails with COMException: Exception from HRESULT: 0x80040228
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; workspace = workspaceFactory.OpenFromFile(gdbName, 0);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any hints are most appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Chris.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Sep 2011 15:55:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/workspace-factory-comexception-0x80040228/m-p/649786#M17429</guid>
      <dc:creator>ChristopherBennett1</dc:creator>
      <dc:date>2011-09-05T15:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: Workspace Factory COMException 0x80040228</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/workspace-factory-comexception-0x80040228/m-p/649787#M17430</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;try this&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//00490000008m000000" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//00490000008m000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-family:Arial;"&gt;using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.DataSourcesFile;

&lt;/SPAN&gt;&lt;SPAN style="font-family:Arial;"&gt;IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactoryClass();
IWorkspace workspace = workspaceFactory.OpenFromFile(string_ShapefileDirectory, 0);
IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;
IFeatureClass featureClass = featureWorkspace.OpenFeatureClass(string_ShapefileName);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:33:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/workspace-factory-comexception-0x80040228/m-p/649787#M17430</guid>
      <dc:creator>DubravkoAntonic</dc:creator>
      <dc:date>2021-12-12T03:33:42Z</dc:date>
    </item>
    <item>
      <title>Re: Workspace Factory COMException 0x80040228</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/workspace-factory-comexception-0x80040228/m-p/649788#M17431</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The workspace for a shapefile is the directory that contains the files that make up the shapefile.&amp;nbsp; The problem with the code that you posted is that you're passing in the path to the *.shp file, which is incorrect.&amp;nbsp; The workspace for a file geodatabase is also a directory.&amp;nbsp; The workspace for a personal geodatabase is the database file.&amp;nbsp; So, make sure you're passing in the correct path for the type of workspace you're trying to open.&amp;nbsp; A recent thread also suggested that there is a bug when binding using the EngineOrDesktop option.&amp;nbsp; If you have Engine installed but not licensed then the binding will fail even if you have Desktop installed and properly licensed.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Sep 2011 12:10:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/workspace-factory-comexception-0x80040228/m-p/649788#M17431</guid>
      <dc:creator>NeilClemmons</dc:creator>
      <dc:date>2011-09-06T12:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: Workspace Factory COMException 0x80040228</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/workspace-factory-comexception-0x80040228/m-p/649789#M17432</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Neil,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks very much for your (as usual) correct response.&amp;nbsp; Changing the EngineOrDesktop option to Desktop solved the problem with opening the file GDB.&amp;nbsp; I'll have to wrap this in a try/catch block.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I haven't opened shapefiles with AO in a while and seemed to recall having to pass in the actual shapefile name, but I guess I mis-remembered.&amp;nbsp; If I had read a bit further in the help, I would have seen this.&amp;nbsp; I'll note here that the bug doesn't seem to affect opening the shapefile workspace.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Chris.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;The workspace for a shapefile is the directory that contains the files that make up the shapefile.&amp;nbsp; The problem with the code that you posted is that you're passing in the path to the *.shp file, which is incorrect.&amp;nbsp; The workspace for a file geodatabase is also a directory.&amp;nbsp; The workspace for a personal geodatabase is the database file.&amp;nbsp; So, make sure you're passing in the correct path for the type of workspace you're trying to open.&amp;nbsp; A recent thread also suggested that there is a bug when binding using the EngineOrDesktop option.&amp;nbsp; If you have Engine installed but not licensed then the binding will fail even if you have Desktop installed and properly licensed.&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Sep 2011 15:55:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/workspace-factory-comexception-0x80040228/m-p/649789#M17432</guid>
      <dc:creator>ChristopherBennett1</dc:creator>
      <dc:date>2011-09-06T15:55:57Z</dc:date>
    </item>
  </channel>
</rss>

