<?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: Open Dgn file:Error HRESULT E_FAIL has been returned from a call to a COM compone in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/open-dgn-file-error-hresult-e-fail-has-been/m-p/687716#M18479</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Never use New to create an instance of a singleton object like a workspace factory.&amp;nbsp; Always use the Activator class.&amp;nbsp; Also, is this a standalone application?&amp;nbsp; If so, are you binding to a product then checking out a license before running this code?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks Neil,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried to use Activator, but still not successful.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Type factoryType = Type.GetTypeFromProgID(
&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; "esriDataSourcesFile.CadWorkspaceFactory");
System.Object obj = Activator.CreateInstance(factoryType);

IWorkspaceFactory factory = obj as IWorkspaceFactory;
IFeatureWorkspace workspace = (IFeatureWorkspace)factory.OpenFromFile(dgnFilePath, 0);
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can I use dgn file path in the OpenFromFile method ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks and regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Tai&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 04:55:51 GMT</pubDate>
    <dc:creator>TaiBui</dc:creator>
    <dc:date>2021-12-12T04:55:51Z</dc:date>
    <item>
      <title>Open Dgn file:Error HRESULT E_FAIL has been returned from a call to a COM component ?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/open-dgn-file-error-hresult-e-fail-has-been/m-p/687714#M18477</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi everyone,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying open and read Dgn file. But, I got the error when using below codes:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
 IWorkspaceFactory factory = new CadWorkspaceFactoryClass ();

 IWorkspace workspace = factory.OpenFromFile(fileName, 0); // Throw exception
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you know why ? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I attached the dgn file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks and regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Tai&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jan 2014 00:57:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/open-dgn-file-error-hresult-e-fail-has-been/m-p/687714#M18477</guid>
      <dc:creator>TaiBui</dc:creator>
      <dc:date>2014-01-23T00:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: Open Dgn file:Error HRESULT E_FAIL has been returned from a call to a COM compone</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/open-dgn-file-error-hresult-e-fail-has-been/m-p/687715#M18478</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Never use New to create an instance of a singleton object like a workspace factory.&amp;nbsp; Always use the Activator class.&amp;nbsp; Also, is this a standalone application?&amp;nbsp; If so, are you binding to a product then checking out a license before running this code?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jan 2014 12:24:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/open-dgn-file-error-hresult-e-fail-has-been/m-p/687715#M18478</guid>
      <dc:creator>NeilClemmons</dc:creator>
      <dc:date>2014-01-23T12:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: Open Dgn file:Error HRESULT E_FAIL has been returned from a call to a COM compone</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/open-dgn-file-error-hresult-e-fail-has-been/m-p/687716#M18479</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Never use New to create an instance of a singleton object like a workspace factory.&amp;nbsp; Always use the Activator class.&amp;nbsp; Also, is this a standalone application?&amp;nbsp; If so, are you binding to a product then checking out a license before running this code?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks Neil,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried to use Activator, but still not successful.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Type factoryType = Type.GetTypeFromProgID(
&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; "esriDataSourcesFile.CadWorkspaceFactory");
System.Object obj = Activator.CreateInstance(factoryType);

IWorkspaceFactory factory = obj as IWorkspaceFactory;
IFeatureWorkspace workspace = (IFeatureWorkspace)factory.OpenFromFile(dgnFilePath, 0);
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can I use dgn file path in the OpenFromFile method ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks and regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Tai&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:55:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/open-dgn-file-error-hresult-e-fail-has-been/m-p/687716#M18479</guid>
      <dc:creator>TaiBui</dc:creator>
      <dc:date>2021-12-12T04:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: Open Dgn file:Error HRESULT E_FAIL has been returned from a call to a COM component ?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/open-dgn-file-error-hresult-e-fail-has-been/m-p/687717#M18480</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Any news?????&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Apr 2018 19:04:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/open-dgn-file-error-hresult-e-fail-has-been/m-p/687717#M18480</guid>
      <dc:creator>Cristian_Galindo</dc:creator>
      <dc:date>2018-04-02T19:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: Open Dgn file:Error HRESULT E_FAIL has been returned from a call to a COM component ?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/open-dgn-file-error-hresult-e-fail-has-been/m-p/687718#M18481</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I had the same issue with reading DWG files using custom SOE and managed to solve it. It turned out that the OpenFromFile() method must be called with directory path not the file path as argument.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So instead of:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;IWorkspace workspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; factory&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;OpenFromFile&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fileName&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Try with this:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;string&lt;/SPAN&gt; directoryName &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; fileName&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Substring&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; fileName&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;LastIndexOf&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'\\'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

IWorkspace workspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; factory&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;OpenFromFile&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;directoryName&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:55:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/open-dgn-file-error-hresult-e-fail-has-been/m-p/687718#M18481</guid>
      <dc:creator>bojko108</dc:creator>
      <dc:date>2021-12-12T04:55:54Z</dc:date>
    </item>
  </channel>
</rss>

