# How To: Use DllImport from C# to call a clarion procedure

**URL:** <https://clarionhub.com/t/how-to-use-dllimport-from-c-to-call-a-clarion-procedure/1104>\
**Category:** Interop\
**Created:** [April 1, 2017, 3:37am UTC](https://clarionhub.com/t/how-to-use-dllimport-from-c-to-call-a-clarion-procedure/1104 "2017-04-01T03:37:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![brahn](https://clarionhub.com/user_avatar/clarionhub.com/brahn/32/756_2.png) [@brahn](https://clarionhub.com/u/brahn)\
**Post date:** [April 1, 2017, 3:37am UTC](https://clarionhub.com/t/how-to-use-dllimport-from-c-to-call-a-clarion-procedure/1104/1 "2017-04-01T03:37:02Z")

</div>

Just for fun, can we call into ClaRun directly from C#?

Why yes, we can! 🙂

```auto
using System;
using System.Runtime.InteropServices;

namespace ClarionDllImport
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Testing ClarionDllImport");
            Console.WriteLine(MyClaToday());
            Console.ReadKey();
        }

        [DllImport("ClaRun.dll", EntryPoint = "Cla$TODAY")]
        public static extern int MyClaToday();
    }
}

```

Result:

 ![image](https://clarionhub-uploads.s3.dualstack.eu-north-1.amazonaws.com/original/2X/2/2c6b0a058bbbff03963a8ef241cb3c3c02d8422b.png)

---

<div class="post-metadata">

**Author:** ![Steverson\_Lira](https://clarionhub.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@Steverson\_Lira](https://clarionhub.com/u/Steverson_Lira)\
**Post date:** [May 25, 2023, 3:24pm UTC](https://clarionhub.com/t/how-to-use-dllimport-from-c-to-call-a-clarion-procedure/1104/2 "2023-05-25T15:24:37Z")

</div>

Is this still possible?  
I got an error when performing this procedure.

---

<div class="post-metadata">

**Author:** ![CarlBarnes](https://clarionhub.com/user_avatar/clarionhub.com/carlbarnes/32/1859_2.png) [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Post date:** [May 25, 2023, 4:45pm UTC](https://clarionhub.com/t/how-to-use-dllimport-from-c-to-call-a-clarion-procedure/1104/3 "2023-05-25T16:45:29Z")

</div>

> [@Steverson\_Lira](#):
>
> I got _ **an error** _ when performing this procedure

Sounds like you have “_a bug_”. Fix that bug and it will work.

If that does not work maybe tell us the Error Message (screen shot is nice), and show your code and project settings.

---

<div class="post-metadata">

**Author:** ![Steverson\_Lira](https://clarionhub.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@Steverson\_Lira](https://clarionhub.com/u/Steverson_Lira)\
**Post date:** [May 25, 2023, 5:45pm UTC](https://clarionhub.com/t/how-to-use-dllimport-from-c-to-call-a-clarion-procedure/1104/5 "2023-05-25T17:45:05Z")

</div>

I was able to use claRun like the example.  
We have to run the program in 32Bits  
In my case, I need to do a little more work to understand the process of using my Clarion procedures in C#.

Thanks for the feedback.

---

<div class="post-metadata">

**Author:** ![CarlBarnes](https://clarionhub.com/user_avatar/clarionhub.com/carlbarnes/32/1859_2.png) [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Post date:** [May 25, 2023, 6:42pm UTC](https://clarionhub.com/t/how-to-use-dllimport-from-c-to-call-a-clarion-procedure/1104/6 "2023-05-25T18:42:02Z")

</div>

Can you give us the Error Message you were getting so we can more easily spot the 32-bit problem? Also a screen shot of the project setting in VS you changed?

---

<div class="post-metadata">

**Author:** ![Steverson\_Lira](https://clarionhub.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@Steverson\_Lira](https://clarionhub.com/u/Steverson_Lira)\
**Post date:** [May 25, 2023, 6:50pm UTC](https://clarionhub.com/t/how-to-use-dllimport-from-c-to-call-a-clarion-procedure/1104/7 "2023-05-25T18:50:16Z")

</div>

DLL Clarion

 ![image](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/e/e8df6511e2a8bc3a39420224a13d63376e8eae00.png)

 ![image](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/0/0cc952820c2468a1477eebdc60a1210c364b0f64.png)  
 ![image](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/8/801c2c1c3e180a5ffe08c0de5e7d12bf2b84af59.png)
