<?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: Marshal.GetActiveObject(&amp;quot;Inventor.Application&amp;quot;) fails with CO_E_CL in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/3630822#M134396</link>
    <description>&lt;P&gt;I was running Visual Studo as admin but still no dice. I have not had this problem in a while now and I dont know how to recreate it.&lt;/P&gt;</description>
    <pubDate>Mon, 24 Sep 2012 07:59:07 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-09-24T07:59:07Z</dc:date>
    <item>
      <title>Marshal.GetActiveObject("Inventor.Application") fails with CO_E_CLASSSTRING</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/3624000#M134392</link>
      <description>&lt;P&gt;I have the following helper class. It have worked fine for a long time but suddenly it does not work in one solution.&lt;/P&gt;&lt;P&gt;It still works in another solution, I have restarted the computer and is now fresh out of ideas of how to fix this.&lt;/P&gt;&lt;P&gt;Any suggestions to why I see this problem and how to solve it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error message:&amp;nbsp;Invalid class string (Exception from HRESULT: 0x800401F3 (CO_E_CLASSSTRING))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; public static class InventorUtilities
    {
        public static Inventor.Application GetInventorApplication(bool startNewIfNotFound=false)
        {
            if (_inventorApplication != null)
                return _inventorApplication;
            try
            {
                _inventorApplication = (Inventor.Application)Marshal.GetActiveObject("Inventor.Application");
            }
            catch (COMException ex)
            {
                if (startNewIfNotFound)
                {
                    _inventorApplication = StartInventorApplication();
                }
                throw new COMException("Inventor application not found", ex);
            }

            return _inventorApplication;
        }

        private static Inventor.Application _inventorApplication;
        public static Application InventorApplication { get { return GetInventorApplication(); } }

        public static Inventor.Application StartInventorApplication()
        {
            try
            {
                // Start Inventor.
                System.Type oType = System.Type.GetTypeFromProgID("Inventor.Application");
                _inventorApplication = (Inventor.Application)System.Activator.CreateInstance(oType);

                // Make Inventor visible.
                _inventorApplication.Visible = true;
            }
            catch (COMException ex)
            {
                throw new COMException("Failed to start Inventor", ex);
            }
            return _inventorApplication;
        }

        public static MeasureTools MeasureTools { get { return InventorApplication.MeasureTools; } }

        public static TransientGeometry TransientGeometry { get { return InventorApplication.TransientGeometry; } }

        public static TransientObjects TransientObjects { get { return InventorApplication.TransientObjects; } }

        public static UnitsOfMeasure UnitsOfMeasure { get { return InventorApplication.UnitsOfMeasure; } }

        public static T GetActiveDocument&amp;lt;T&amp;gt;()
        {
            return (T)InventorApplication.ActiveDocument;
        }

    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2012 13:49:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/3624000#M134392</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-09-18T13:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: Marshal.GetActiveObject("Inventor.Application") fails with CO_E_CL</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/3624274#M134393</link>
      <description>&lt;P&gt;To clearify, the method GetInventorApplication() fails on row&amp;nbsp;&lt;/P&gt;&lt;P&gt;_inventorApplication = (Inventor.Application)Marshal.GetActiveObject("Inventor.Application");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code works when called from one soultion but fails when used in another.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2012 15:56:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/3624274#M134393</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-09-18T15:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: Marshal.GetActiveObject("Inventor.Application") fails with CO_E_CL</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/3624394#M134394</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Now the code works in both solutions, I have a suspicion that it had something to do with code for registering an Inventor add-in.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The solution that failed had a project with code for registering an add-in. I unloaded that project and restarted Visual studio among other things and now it works. The only thing I am sure of is that the code that failed is untouched.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2012 16:59:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/3624394#M134394</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-09-18T16:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: Marshal.GetActiveObject("Inventor.Application") fails with CO_E_CL</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/3630748#M134395</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="line-height: 14px;"&gt;T&lt;/SPAN&gt;he only issue with GetActiveObject&amp;nbsp;I have ever heard was: at the machine of one customer, get object failed&amp;nbsp;if the program [requestedExecutionLevel level="requireAdministrator" ] while&amp;nbsp;Inventor&amp;nbsp;running with different &amp;#24;ExecutionLevel.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Sep 2012 05:51:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/3630748#M134395</guid>
      <dc:creator>xiaodong_liang</dc:creator>
      <dc:date>2012-09-24T05:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: Marshal.GetActiveObject("Inventor.Application") fails with CO_E_CL</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/3630822#M134396</link>
      <description>&lt;P&gt;I was running Visual Studo as admin but still no dice. I have not had this problem in a while now and I dont know how to recreate it.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Sep 2012 07:59:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/3630822#M134396</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-09-24T07:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: Marshal.GetActiveObject("Inventor.Application") fails with CO_E_CL</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/3635902#M134397</link>
      <description>&lt;P&gt;When you recreate this issue next time, please try to use Process Monitor to watch if there is any failure for loading some modules. Probably it may be helpful to know something.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2012 03:05:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/3635902#M134397</guid>
      <dc:creator>xiaodong_liang</dc:creator>
      <dc:date>2012-09-27T03:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: Marshal.GetActiveObject("Inventor.Application") fails with CO_E_CL</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/3817653#M134398</link>
      <description>&lt;P&gt;I just found the same thing. If I ran Inventor 2013 or Visual Studio 2012 as Administrator then I got the COMException:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Invalid class string (Exception from HRESULT: 0x800401F3 (CO_E_CLASSSTRING))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I ran both &lt;U&gt;&lt;STRONG&gt;without&lt;/STRONG&gt; &lt;/U&gt;selecting Run As Adminstrator then I could call&amp;nbsp;Marshal.GetActiveObject("Inventor.Application") without any issues.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the end I made sure my taskbar shortcuts weren't set to Run As Administrator for Inventor 2013 and Visual Studio 2012. I'm running Windows 8 64 bit with Any CPU projects.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was just using this sample for my tests:&lt;/P&gt;&lt;P&gt;&lt;A href="http://modthemachine.typepad.com/files/inventor_training_module_01_samples.zip" target="_self"&gt;http://modthemachine.typepad.com/files/inventor_training_module_01_samples.zip&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2013 16:54:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/3817653#M134398</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-03-28T16:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: Marshal.GetActiveObject("Inventor.Application") fails with CO_E_CL</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/3839790#M134399</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;&lt;A id="link_13de33abbdd" class="lia-link-navigation lia-page-link lia-user-name-link" href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1056272" target="_self"&gt;adam.davidson&lt;/A&gt;,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Sorry I have not more comments than what I have shared for this problem. This looks a specific issue on specific scenario. I'd appreciate you could use&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;Process Monitor to watch if there is any failure for loading some modules, and provide with us. It may be helpful to diagnose what happened.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Apr 2013 06:43:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/3839790#M134399</guid>
      <dc:creator>xiaodong_liang</dc:creator>
      <dc:date>2013-04-07T06:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: Marshal.GetActiveObject("Inventor.Application") fails with CO_E_CL</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/4505599#M134400</link>
      <description>&lt;P&gt;I am facing same issue while attempting to connect/create Inventor instance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code:&lt;/P&gt;&lt;PRE&gt;        /// &amp;lt;summary&amp;gt;
        /// Connects to a running instance of Inventor or
        /// Creates a new instance and connects to it.
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;returns&amp;gt;Instance of Inventor app&amp;lt;/returns&amp;gt;
        private Inventor.Application Connect()
        {
            string InventorProgID = "Inventor.Application";
            Inventor.Application inventorApp = null;

            // Try to get an active instance of Inventor
            try
            {
                inventorApp = System.Runtime.InteropServices.Marshal.GetActiveObject(InventorProgID) as Inventor.Application;
                //This throws Invalid class string (Exception from HRESULT: 0x800401F3 (CO_E_CLASSSTRING))
            }
            catch
            {
                //(MK_E_UNAVAILABLE)) is expected when Inventor is not running in interactive mode.
            }

            // If Inventor is not running, create a new Inventor session
            if (null == inventorApp)
            {

                Type inventorAppType = Type.GetTypeFromProgID(InventorProgID); //This returns null, when process is Run As Administrator.
                Debug.Assert(inventorAppType != null, "inventorAppType is null.");

                if (null != inventorAppType)
                {
                    inventorApp = Activator.CreateInstance(inventorAppType) as Inventor.Application;
                    Debug.Assert(inventorApp != null, "inventorApp is null.");
                }
            }

            return inventorApp;
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what we observed in using process monitor.&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[A] While running as Non-Admin User:&lt;/P&gt;&lt;P&gt;Process monitor shows successfull registry events as below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/65027i28500747C4977B11/image-size/original?v=mpbl-1&amp;amp;px=-1" alt="ProcessMonitorInventorConnection-NonAdminMode.jpg" border="0" align="center" title="ProcessMonitorInventorConnection-NonAdminMode.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[B] While running as Admin User:&lt;/P&gt;&lt;P&gt;Process monitor shows unsuccessfull registry events as below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/65025iF2620C4974A2256E/image-size/original?v=mpbl-1&amp;amp;px=-1" alt="ProcessMonitorInventorConnection-AdminMode.jpg" border="0" align="center" title="ProcessMonitorInventorConnection-AdminMode.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2013 13:38:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/4505599#M134400</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-10-09T13:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: Marshal.GetActiveObject("Inventor.Application") fails with CO_E_CL</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/6227892#M134401</link>
      <description>&lt;P&gt;Same problem here with AutoCAD. GetActiveObject fails when running as administrator.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2016 09:50:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/6227892#M134401</guid>
      <dc:creator>FRFR1426</dc:creator>
      <dc:date>2016-03-22T09:50:41Z</dc:date>
    </item>
    <item>
      <title>Re: Marshal.GetActiveObject("Inventor.Application") fails with CO_E_CL</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/6257824#M134402</link>
      <description>&lt;P&gt;Probably same issue as the one mentioned here and same explanation for it too.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://forums.autodesk.com/t5/inventor-customization/not-able-to-create-inventor-instance-when-visual-studio-in-admin/m-p/6063010" target="_self"&gt;http://forums.autodesk.com/t5/inventor-customization/not-able-to-create-inventor-instance-when-visual-studio-in-admin/m-p/6063010&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2016 16:19:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/6257824#M134402</guid>
      <dc:creator>adam.nagy</dc:creator>
      <dc:date>2016-04-07T16:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: Marshal.GetActiveObject("Inventor.Application") fails with CO_E_CL</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/8512161#M134403</link>
      <description>&lt;P&gt;public static class Marshal is a Member of System.Runtime.InteropServices&lt;/P&gt;
&lt;P&gt;you just have to add:&lt;/P&gt;
&lt;P&gt;using System.Runtime.InteropServices; in that .cs file&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 06:24:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/marshal-getactiveobject-quot-inventor-application-quot-fails/m-p/8512161#M134403</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-01-10T06:24:09Z</dc:date>
    </item>
  </channel>
</rss>

