<?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: Call Wolfram Mathematica code from ArcGIS Pro add-in with C# in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/call-wolfram-mathematica-code-from-arcgis-pro-add/m-p/1285709#M6574</link>
    <description>&lt;P&gt;Hi Mathias,&lt;/P&gt;&lt;P&gt;Have you tried right-clicking on the included&amp;nbsp;&lt;SPAN&gt;ml64i4.dll file in Visual Studio and set Build Action to Content and Copy to Output Directory to Copy always (or Copy if newer)?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mahj_0-1683214776553.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/69876i81F1DA9C007A5C66/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mahj_0-1683214776553.png" alt="mahj_0-1683214776553.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;/Markus&lt;/P&gt;</description>
    <pubDate>Thu, 04 May 2023 15:41:46 GMT</pubDate>
    <dc:creator>mahj</dc:creator>
    <dc:date>2023-05-04T15:41:46Z</dc:date>
    <item>
      <title>Call Wolfram Mathematica code from ArcGIS Pro add-in with C#</title>
      <link>https://community.esri.com/t5/developers-questions/call-wolfram-mathematica-code-from-arcgis-pro-add/m-p/1281172#M6567</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to make a Wolfram Mathematica call from an ArcGIS Pro add-in with C# like this:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using ArcGIS.Desktop.Framework.Contracts;
using System;
using System.Diagnostics;
using Wolfram.NETLink;

namespace MyAddIn
{
    internal class MathematicaButton : Button
    {
        protected override void OnClick()
        {
            try
            {
                IKernelLink ml = MathLinkFactory.CreateKernelLink();
                ml.WaitAndDiscardAnswer();

                ml.Evaluate("2+2");
                ml.WaitForAnswer();
                int intResult = ml.GetInteger();
                
                ml.Close();

                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("2 + 2 = " + intResult);
            }
            catch (Exception ex) 
            {
                Debug.WriteLine(ex.StackTrace);
                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(ex.StackTrace);
            }
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;I have included ml64i4.dll and Wolfram.NETLink.dll in my project.&lt;/P&gt;&lt;P&gt;When I run my add-in code I get this exception:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Exception thrown: 'System.TypeInitializationException' in Wolfram.NETLink.dll&lt;BR /&gt;at Wolfram.NETLink.Internal.NativeLink..ctor(String cmdLine)&lt;BR /&gt;at Wolfram.NETLink.MathLinkFactory.CreateKernelLink()&lt;BR /&gt;at MyAddIn.MathematicaButton.OnClick() in C:\Users\matti\Desktop\ArcGIS_Pro_add_in\MyAddIn\MathematicaButton.cs:line 14&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Line 14 is:&lt;BR /&gt;IKernelLink ml = MathLinkFactory.CreateKernelLink();&lt;/P&gt;&lt;P&gt;If I run the same code in a console application it is working.&lt;BR /&gt;So my question is, what am I missing or doing wrong in the ArcGIS Pro add-in project?&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Mattias&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 06:57:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/call-wolfram-mathematica-code-from-arcgis-pro-add/m-p/1281172#M6567</guid>
      <dc:creator>MattiasWesterberg</dc:creator>
      <dc:date>2023-04-21T06:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: Call Wolfram Mathematica code from ArcGIS Pro add-in with C#</title>
      <link>https://community.esri.com/t5/developers-questions/call-wolfram-mathematica-code-from-arcgis-pro-add/m-p/1285709#M6574</link>
      <description>&lt;P&gt;Hi Mathias,&lt;/P&gt;&lt;P&gt;Have you tried right-clicking on the included&amp;nbsp;&lt;SPAN&gt;ml64i4.dll file in Visual Studio and set Build Action to Content and Copy to Output Directory to Copy always (or Copy if newer)?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mahj_0-1683214776553.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/69876i81F1DA9C007A5C66/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mahj_0-1683214776553.png" alt="mahj_0-1683214776553.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;/Markus&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 15:41:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/call-wolfram-mathematica-code-from-arcgis-pro-add/m-p/1285709#M6574</guid>
      <dc:creator>mahj</dc:creator>
      <dc:date>2023-05-04T15:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: Call Wolfram Mathematica code from ArcGIS Pro add-in with C#</title>
      <link>https://community.esri.com/t5/developers-questions/call-wolfram-mathematica-code-from-arcgis-pro-add/m-p/1287181#M6585</link>
      <description>&lt;P&gt;Yes. But it is still not working.&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2023 11:19:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/call-wolfram-mathematica-code-from-arcgis-pro-add/m-p/1287181#M6585</guid>
      <dc:creator>MattiasWesterberg</dc:creator>
      <dc:date>2023-05-09T11:19:43Z</dc:date>
    </item>
  </channel>
</rss>

