<?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 What is the recommended way to execute .NET C# code from ArcGIS Pro Python? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/what-is-the-recommended-way-to-execute-net-c-code/m-p/496328#M38974</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am writing a ArcGIS Pro 2.3 AddIn, which has a few RibbonMenu button that will load up some Geoprocessing tools from a custom Python Toolbox. However, some of the scripts will require to call back into C, C++ and C# to do processing. The C and C++ code is easy enough to do using the 'ctypes' module, which is already part of ArcGIS Pro Python environment. But to interface to C# code, I have been unable to work out how to successfully do this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've been hunting around for a few days now, attempting to find the best / recommended approach for&amp;nbsp;calling C# code from with Python.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Even though I followed many articles and suggestions I found scattered around the web, I have repeated&amp;nbsp;hit a wall.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I was unable to get the UnmanagedExports NuGet package for VS2017 working:&lt;UL&gt;&lt;LI&gt;&lt;A href="https://www.udcus.com/blog/2017/06/27/extending-arcpy-increased-capabilities-arcobjects-and-c"&gt;https://www.udcus.com/blog/2017/06/27/extending-arcpy-increased-capabilities-arcobjects-and-c&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;I tried to use 'ctypes' following this article, but was unable to get it working end-to-end:&lt;UL&gt;&lt;LI&gt;Python --&amp;gt; C --&amp;gt; C++/CLI --&amp;gt; C#&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;&lt;A href="http://pragmateek.com/if-your-plumbing-doesnt-work-youre-just-not-using-enough-pipes/?unapproved=2384&amp;amp;moderation-hash=6e80fec466bee2e4f2cb99d47cd52ecc#comment-2384"&gt;http://pragmateek.com/if-your-plumbing-doesnt-work-youre-just-not-using-enough-pipes/?unapproved=2384&amp;amp;moderation-hash=6e80fec466bee2e4f2cb99d47cd52ecc#comment-2384&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The 'pythonnet' package seems to have the most elegant and simplified way of doing it. But, 'pythonnet'&amp;nbsp;is not one of the available python module shipped with ArcGIS Pro Python.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So my question is, how do I do it, constrained within the ArcGIS Pro Python installation / environment?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it even possible?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or do I need to install the 'pythonnet'&amp;nbsp; package using 'conda' and 'pip', into the arcgispro-py3 environment?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TIA.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 28 May 2019 07:16:37 GMT</pubDate>
    <dc:creator>BenReschke</dc:creator>
    <dc:date>2019-05-28T07:16:37Z</dc:date>
    <item>
      <title>What is the recommended way to execute .NET C# code from ArcGIS Pro Python?</title>
      <link>https://community.esri.com/t5/python-questions/what-is-the-recommended-way-to-execute-net-c-code/m-p/496328#M38974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am writing a ArcGIS Pro 2.3 AddIn, which has a few RibbonMenu button that will load up some Geoprocessing tools from a custom Python Toolbox. However, some of the scripts will require to call back into C, C++ and C# to do processing. The C and C++ code is easy enough to do using the 'ctypes' module, which is already part of ArcGIS Pro Python environment. But to interface to C# code, I have been unable to work out how to successfully do this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've been hunting around for a few days now, attempting to find the best / recommended approach for&amp;nbsp;calling C# code from with Python.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Even though I followed many articles and suggestions I found scattered around the web, I have repeated&amp;nbsp;hit a wall.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I was unable to get the UnmanagedExports NuGet package for VS2017 working:&lt;UL&gt;&lt;LI&gt;&lt;A href="https://www.udcus.com/blog/2017/06/27/extending-arcpy-increased-capabilities-arcobjects-and-c"&gt;https://www.udcus.com/blog/2017/06/27/extending-arcpy-increased-capabilities-arcobjects-and-c&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;I tried to use 'ctypes' following this article, but was unable to get it working end-to-end:&lt;UL&gt;&lt;LI&gt;Python --&amp;gt; C --&amp;gt; C++/CLI --&amp;gt; C#&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;&lt;A href="http://pragmateek.com/if-your-plumbing-doesnt-work-youre-just-not-using-enough-pipes/?unapproved=2384&amp;amp;moderation-hash=6e80fec466bee2e4f2cb99d47cd52ecc#comment-2384"&gt;http://pragmateek.com/if-your-plumbing-doesnt-work-youre-just-not-using-enough-pipes/?unapproved=2384&amp;amp;moderation-hash=6e80fec466bee2e4f2cb99d47cd52ecc#comment-2384&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The 'pythonnet' package seems to have the most elegant and simplified way of doing it. But, 'pythonnet'&amp;nbsp;is not one of the available python module shipped with ArcGIS Pro Python.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So my question is, how do I do it, constrained within the ArcGIS Pro Python installation / environment?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it even possible?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or do I need to install the 'pythonnet'&amp;nbsp; package using 'conda' and 'pip', into the arcgispro-py3 environment?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TIA.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 May 2019 07:16:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/what-is-the-recommended-way-to-execute-net-c-code/m-p/496328#M38974</guid>
      <dc:creator>BenReschke</dc:creator>
      <dc:date>2019-05-28T07:16:37Z</dc:date>
    </item>
  </channel>
</rss>

