06-15-2015 04:35 PM
Hi,
I'm new to C# but I have to write dll for LabVIEW that reads information about windows processes. I've prepared code (working as Win32 application), built it as dll and used Call Library Function to call it. I've tried another C-language code before and it worked fine. But when I do the same with C#, I have an error in LabVIEW:
"The function name specified for this node cannot be found in the library. Right-click the Call Library Function node and select Configure, then choose the correct function name."
The function I've created (I've pasted it below this post) has proper function but LabVIEW does not see it. Do you have any idea how to fix it? I couldn't find any tutorial for C# and LabVIEW, I saw some for C# and I it should work.
Best regards,
Piotr
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading;
using System.Xml.Linq;
namespace GetProcessDataLib
{
public class ProcessData
{
public static String GetProcessDataFunction(out string result)
{
String xmlOutput = "";
try
{
//sample code
}
catch (Exception ex)
{
Console.WriteLine(ex.Message + "\r\n" + ex.StackTrace + "\r\n" + ex.Source);
xmlOutput = "";
}
result = xmlOutput;
GetProcessDataFunction(out result);
return xmlOutput;
}
}
}
Solved! Go to Solution.
06-15-2015 05:22 PM
Are you sure you built this as a standard DLL, and not a C# assembly? They both use the .dll extension, but you can't call a C# assembly the same way. Instead, you need to use the functions on the .NET palette - Constructor, Property Node, Invoke Node.
06-16-2015 02:07 AM
Hi Nathan,
Thanks for replying. I'm new to C#... I'm not sure 🙂 I've tried to:
1/ create dll with Visual Studio Command Prompt (both 32 and 64). I used this command:
csc /target:library /out:GetProcessDataLib64.DLL GetProcessData.cs
2/ take dll that was automatically create during build.
06-16-2015 03:19 AM
06-16-2015 03:40 AM
Any functions appears. Only this default "funcName". I cannot see implemented functions. Maybe there's sth wrong with this:
-----
public static String GetProcessDataFunction(out string result)
GetProcessDataFunction(out result);
return xmlOutput;
-----
or I have to change way of creating this dll in Visual Studio.
06-16-2015 04:55 AM
06-16-2015 07:47 AM
@Piotr.Zawistowski wrote:
Hi Nathan,
Thanks for replying. I'm new to C#... I'm not sure 🙂 I've tried to:
1/ create dll with Visual Studio Command Prompt (both 32 and 64). I used this command:
csc /target:library /out:GetProcessDataLib64.DLL GetProcessData.cs
2/ take dll that was automatically create during build.
csc is the C Sharp compiler and will create a .Net assembly by default, not a Windows function DLL. So you need to use the .Net functions in LabVIEW to access it. And anyhow from that source code you cannot directly create a Windows function DLL since there are no exportable functions in there, but only .Net objects.
And Nathan, C(++/#) compilers don't create header files for DLLs. Those header files have to be created by the programmer creating the DLL source code.
06-16-2015 08:02 AM
06-16-2015 08:06 AM
Or at least get a coffee first
06-16-2015 12:06 PM
Thanks all for help!
What I had to do, was follow this instruction:
If the DLL is a .NET assembly:
http://digital.ni.com/public.nsf/allkb/DCB90714981A1F148625731E00797C33
And it works. Thx!