LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use C# dll in Labwindows CVI 2015

Hi,

I need to use a dll which is created using visual studio 2019 c# library.

I saw some discussion in the forum.  But I am not clear about it, especially in the exported function signature.  Can anyone share me an example codeset, please?

 

My Example C# code

 
using System;
// namespace declaration
namespace HelloWorld{ 
    // Class declaration
    public class program
   {
       public static void MainEntry()
       { 
           MyFunction(); 
           Console.ReadKey();
        }
    }
}
static int MyFunction()
{
Console.WriteLine("Hello World!");
return 0;
}
 
From the above example, I need to call the function "MainEntry()"  in my CVI application.  Can anyone help me?
Regards,
Rahul.
0 Kudos
Message 1 of 3
(2,690 Views)

I use Robert Giesecke's "Unmanaged Exports," installable with Nuget.

https://sites.google.com/site/robertgiesecke/Home/uploads/unmanagedexports

 

using System;
using RGiesecke.DllExport;
// namespace declaration
namespace HelloWorld{ 
    // Class declaration
    public class program
   {
       [DllExport( "MainEntry", CallingConvention = CallingConvention.Cdecl )]
       public static void MainEntry()
       { 
           MyFunction(); 
           Console.ReadKey();
        }
    }
}
-----------------------
/* Nothing past this point should fail if the code is working as intended */
0 Kudos
Message 2 of 3
(2,615 Views)

Much thanks for the replay.

Can you please key in few lines of example code which I should use in CVI for the same example provided.  In CVI side do I need to do any thing with RGiesecke.DLLExpor ?

 

Regards,

Rahul.

 

0 Kudos
Message 3 of 3
(2,599 Views)