<?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: Visual Studio Versions and Inventor Interop in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/visual-studio-versions-and-inventor-interop/m-p/11972212#M152789</link>
    <description>&lt;P&gt;If you treat the selected object as &lt;STRONG&gt;dynamic&lt;/STRONG&gt; then you can still access the &lt;STRONG&gt;Type&lt;/STRONG&gt; property. With&amp;nbsp;&lt;STRONG&gt;Microsoft.VisualBasic&lt;/STRONG&gt; assembly you can also get the &lt;STRONG&gt;TypeName&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="adamnagy_0-1684398763705.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1216089i9AE78CB39600A556/image-size/medium?v=v2&amp;amp;px=400" role="button" title="adamnagy_0-1684398763705.png" alt="adamnagy_0-1684398763705.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 18 May 2023 08:33:32 GMT</pubDate>
    <dc:creator>adam.nagy</dc:creator>
    <dc:date>2023-05-18T08:33:32Z</dc:date>
    <item>
      <title>Visual Studio Versions and Inventor Interop</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/visual-studio-versions-and-inventor-interop/m-p/6038213#M61688</link>
      <description>&lt;P&gt;Has anyone else run into this issue? I'm in the process of finally updating my Addins for 2016/2017 and thought I would take the opportunity to also move my projects to Visual Studio 2015 so I could take advantage of some of the new C# 6 language features.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As seen in this &lt;A href="https://forums.autodesk.com/t5/inventor-customization/how-to-get-parameter-s-unit-in-c-net/td-p/4939786" target="_self"&gt;post (parameter.get_Units() vs. parameter.Units)&lt;/A&gt;&amp;nbsp;the Inventor interop doesn't always line up nicely with C#. Using Visual Studio 2015 the same issue still exists. However even though the project compiles fine it throws a member not found exception when trying to resolve parameter.get_Units() method. The CommandType enum also sometimes shows an error in the editor but compiles ok. Reverted back to VS 2013 and the same code works fine. I know the VS uses the&amp;nbsp;new Roslyn C# compiler so I'm wondering if it's something to do with that or if it's something with my .NET installation.&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2016 02:13:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/visual-studio-versions-and-inventor-interop/m-p/6038213#M61688</guid>
      <dc:creator>rjay75</dc:creator>
      <dc:date>2016-02-14T02:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: Visual Studio Versions and Inventor Interop</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/visual-studio-versions-and-inventor-interop/m-p/6046778#M61810</link>
      <description>Hi Rodney ,&lt;BR /&gt;&lt;BR /&gt;This sounds a  like a legacy issue while what we have known it does not either work in VS2013. The workaround is to call the get_Units and set_Units methods separately instead of using the Units property.&lt;BR /&gt;&lt;BR /&gt;Could you provide some code sample on the issue of VS2015, thus we can make sure if it is the same issue we have known above.</description>
      <pubDate>Fri, 19 Feb 2016 06:21:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/visual-studio-versions-and-inventor-interop/m-p/6046778#M61810</guid>
      <dc:creator>xiaodong_liang</dc:creator>
      <dc:date>2016-02-19T06:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: Visual Studio Versions and Inventor Interop</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/visual-studio-versions-and-inventor-interop/m-p/6048686#M61838</link>
      <description>&lt;P&gt;I think I've figured out the issue. It has to deal with how the Inventor interop is referenced. In updating my reference from 2013 to 2015 I didn't realize I had the interop marked to be embedded.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems with the 2015 interop set to embed the reference using Visual Studio 2015 it has resolution issues. Of not is it also compiles to the largest dll size too. If you're not careful in setting the reference it will mark it to embed. If it's set to true the resolution error happens. Making sure it's set to false allows it to work.&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/219411i729594B5A1E47E3F/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="IV_interop.png" title="IV_interop.png" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the sample there are 4 dlls. To test them place them in your iLogic Dlls Addin folder. Rename the dll you're testing&amp;nbsp;to test IVApiTest.dll.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create a rule with the following code to run the test sample.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN&gt;AddReference&lt;/SPAN&gt; &lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;IVApiTest.dll&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;
&lt;SPAN&gt;Imports&lt;/SPAN&gt; &lt;SPAN&gt;IVApiTest&lt;/SPAN&gt;

&lt;SPAN&gt;IVTest&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;ConvertParams&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Document&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Attach is a sample project with 4 dlls and the project. Using "IVApiTest_e_15_2015.dll" renamed to IVApiTest.dll causes the error. It is the dll compiled with the embed option set to True in Visual Studio 2015.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I always use the get_Units() method for parameters on all versions because this has always been an issue. Just recently realized the embedded option causes an issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hopefully this may help others if they have strange resolution issues when migrating projects.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Feb 2016 09:42:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/visual-studio-versions-and-inventor-interop/m-p/6048686#M61838</guid>
      <dc:creator>rjay75</dc:creator>
      <dc:date>2016-02-20T09:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: Visual Studio Versions and Inventor Interop</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/visual-studio-versions-and-inventor-interop/m-p/6052497#M61873</link>
      <description>&lt;P&gt;Hi Rodney,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And also set it to &lt;STRONG&gt;False&lt;/STRONG&gt; to avoid issues with events:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://modthemachine.typepad.com/my_weblog/2012/07/set-embed-interop-types-to-false-to-avoid-problems-with-events.html" target="_self"&gt;http://modthemachine.typepad.com/my_weblog/2012/07/set-embed-interop-types-to-false-to-avoid-problems-with-events.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So basically, I'm not aware of any good reason to set it to &lt;STRONG&gt;True&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2016 15:13:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/visual-studio-versions-and-inventor-interop/m-p/6052497#M61873</guid>
      <dc:creator>adam.nagy</dc:creator>
      <dc:date>2016-02-23T15:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: Visual Studio Versions and Inventor Interop</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/visual-studio-versions-and-inventor-interop/m-p/9833780#M117477</link>
      <description>&lt;P&gt;I have a dilemma related to this topic. I am running an Inventor Addin using Forge DA for Inventor. If I set the&amp;nbsp;Autodesk.Inventor.Interop Embed Interop Types to "False" I get this error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[10/30/2020 02:19:40] Could not load file or assembly 'Autodesk.Inventor.Interop, Version=25.1.0.0, Culture=neutral, PublicKeyToken=[some key]' or one of its dependencies. The system cannot find the file specified.&lt;BR /&gt;[10/30/2020 02:19:41] End Inventor Core Engine standard output dump.&lt;BR /&gt;[10/30/2020 02:19:41] Error: Application InventorCoreConsole.exe exits with code -1 which indicates an error.&lt;BR /&gt;[10/30/2020 02:19:41] End script phase.&lt;BR /&gt;[10/30/2020 02:19:41] Error: An unexpected error happened during phase CoreEngineExecution of job.&lt;BR /&gt;[10/30/2020 02:19:41] Job finished with result FailedExecution&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However I want to use the parameter.get_Units() method. If I set it to "True" It runs but throws the "member not found" exception.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any advice&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2020 02:32:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/visual-studio-versions-and-inventor-interop/m-p/9833780#M117477</guid>
      <dc:creator>josiah_pekary</dc:creator>
      <dc:date>2020-10-30T02:32:09Z</dc:date>
    </item>
    <item>
      <title>Re: Visual Studio Versions and Inventor Interop</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/visual-studio-versions-and-inventor-interop/m-p/9839553#M117535</link>
      <description>&lt;P&gt;Apart from setting&amp;nbsp;"&lt;STRONG&gt;Embed Interop Types&lt;/STRONG&gt;"&amp;nbsp; to &lt;STRONG&gt;"False"&lt;/STRONG&gt;, you should also set &lt;STRONG&gt;"Copy Local"&lt;/STRONG&gt; to &lt;STRONG&gt;"True"&lt;/STRONG&gt; so that the specific &lt;STRONG&gt;Inventor interop dll&lt;/STRONG&gt; your project is using will be available in the &lt;STRONG&gt;AppBundle&lt;/STRONG&gt;:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="EmbedInteropTypes.png" style="width: 716px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/839265i3C70BBA3D862AA84/image-size/large?v=v2&amp;amp;px=999" role="button" title="EmbedInteropTypes.png" alt="EmbedInteropTypes.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Nov 2020 10:22:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/visual-studio-versions-and-inventor-interop/m-p/9839553#M117535</guid>
      <dc:creator>adam.nagy</dc:creator>
      <dc:date>2020-11-02T10:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: Visual Studio Versions and Inventor Interop</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/visual-studio-versions-and-inventor-interop/m-p/11970856#M152758</link>
      <description>&lt;P&gt;Hi Adam,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found one reason for setting Embed Interop Types to true. The GetType() method on a SelectSet item returns a "__ComObject", so it it useless for determining the type of the Inventor object.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;drawingDocument.SelectSet[1].GetType()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Setting Embed Interop Types to true, makes the Type property available on the SelectSet, which returns an ObjectTypeEnum.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;drawingDocument.SelectSet[1].Type&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But choosing between this and the reported issues with events, let's me think twice about actually enabling it.&lt;/P&gt;&lt;P&gt;Luckily I have found a workaround to get the ComObject type.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Alain&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2023 16:54:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/visual-studio-versions-and-inventor-interop/m-p/11970856#M152758</guid>
      <dc:creator>alain_miltenburg</dc:creator>
      <dc:date>2023-05-17T16:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: Visual Studio Versions and Inventor Interop</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/visual-studio-versions-and-inventor-interop/m-p/11971793#M152781</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4597177"&gt;@alain_miltenburg&lt;/a&gt;&amp;nbsp; what's the workaround you found to&amp;nbsp;get the ComObject type in C#?&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 02:52:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/visual-studio-versions-and-inventor-interop/m-p/11971793#M152781</guid>
      <dc:creator>abdullah_elq</dc:creator>
      <dc:date>2023-05-18T02:52:32Z</dc:date>
    </item>
    <item>
      <title>Re: Visual Studio Versions and Inventor Interop</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/visual-studio-versions-and-inventor-interop/m-p/11972212#M152789</link>
      <description>&lt;P&gt;If you treat the selected object as &lt;STRONG&gt;dynamic&lt;/STRONG&gt; then you can still access the &lt;STRONG&gt;Type&lt;/STRONG&gt; property. With&amp;nbsp;&lt;STRONG&gt;Microsoft.VisualBasic&lt;/STRONG&gt; assembly you can also get the &lt;STRONG&gt;TypeName&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="adamnagy_0-1684398763705.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1216089i9AE78CB39600A556/image-size/medium?v=v2&amp;amp;px=400" role="button" title="adamnagy_0-1684398763705.png" alt="adamnagy_0-1684398763705.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 08:33:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/visual-studio-versions-and-inventor-interop/m-p/11972212#M152789</guid>
      <dc:creator>adam.nagy</dc:creator>
      <dc:date>2023-05-18T08:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: Visual Studio Versions and Inventor Interop</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/visual-studio-versions-and-inventor-interop/m-p/11973492#M152812</link>
      <description>&lt;P&gt;This is the way I access the Type property for the com objects using reflection so I don't have to embed types or add more dependencies.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;                Type objType = obj.GetType();
                ObjectTypeEnum ote;
                try
                {
                    ote = (ObjectTypeEnum)objType.InvokeMember("Type", BindingFlags.InvokeMethod, null, obj, null);

                }
                catch (Exception castExp)
                {

                    throw new InvalidCastException("Object is not an Inventor Type:/n" + castExp.Message);
                }&lt;/LI-CODE&gt;
&lt;P&gt;I also took this one step further and passed the ote variable to a giant switch statement to return the actual Inventor type. You can also have it only contain the types you're interested in.&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;        public Type GetInventorType(object obj)
        {
            Type rVal = null;
            if (obj != null)
            {
                Type objType = obj.GetType();
                ObjectTypeEnum ote;
                try
                {
                    ote = (ObjectTypeEnum)objType.InvokeMember("Type", BindingFlags.InvokeMethod, null, obj, null);

                }
                catch (Exception castExp)
                {

                    throw new InvalidCastException("Object is not an Inventor Type:/n" + castExp.Message);
                }
                switch (ote)
                {
                    case ObjectTypeEnum.kAngularGeneralDimensionObject:
                        rVal = typeof(AngularGeneralDimension);
                        break;
                    case ObjectTypeEnum.kApplicationAddInObject:
                        rVal = typeof(ApplicationAddIn);
                        break;
                    case ObjectTypeEnum.kApplicationAddInSiteObject:
                        rVal = typeof(ApplicationAddInSite);
                        break;
                    case ObjectTypeEnum.kApplicationAddInsObject:
                        rVal = typeof(ApplicationAddIns);
                        break;
                    case ObjectTypeEnum.kApplicationEventsObject:
                        rVal = typeof(ApplicationEvents);
                        break;
                    case ObjectTypeEnum.kApplicationObject:
                        rVal = typeof(Application);
                        break;
                    case ObjectTypeEnum.kDiameterGeneralDimensionObject:
                        rVal = typeof(DiameterGeneralDimension);
                        break;
                    default:
                        break;
                }
            }
                return rVal;
        }
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 17:56:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/visual-studio-versions-and-inventor-interop/m-p/11973492#M152812</guid>
      <dc:creator>rjay75</dc:creator>
      <dc:date>2023-05-18T17:56:03Z</dc:date>
    </item>
    <item>
      <title>Re: Visual Studio Versions and Inventor Interop</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/visual-studio-versions-and-inventor-interop/m-p/11979746#M152922</link>
      <description>&lt;P&gt;Hi Adam,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your suggestion! In general, am not that fond of using the dynamic keyword, but I will definitely review &lt;SPAN&gt;your solution for replacement of my current solution. As mine has downsides as well.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As with the solution of Rodney, I am currently using reflection to get the ObjectTypeEnum:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        public static ObjectTypeEnum GetObjectTypeEnum(object comObject)
        {
            const string propertyName = "Type";

            if (comObject is null)
            {
                throw new ArgumentNullException(nameof(comObject), "Argument cannot be null.");
            }
          
            try
            {
                return (ObjectTypeEnum)comObject.GetType().InvokeMember(propertyName,
                    BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance,
                    null, comObject, null);
            }
            catch
            {
                throw new MissingMemberException($"Property '{propertyName}' is not found on object.");
            }
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2023 10:48:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/visual-studio-versions-and-inventor-interop/m-p/11979746#M152922</guid>
      <dc:creator>alain_miltenburg</dc:creator>
      <dc:date>2023-05-22T10:48:00Z</dc:date>
    </item>
  </channel>
</rss>

