06-01-2017 05:35 AM
I am sure this has been asked many time before, but the search here doesn't seem to work with C# and I am having trouble finding it.
I am attempting to write a very simple DLL in C# and have LabWindows call the DLL
namespace Utilities { public static class GetVersion { public static string GetFileVersion(string fileName) { FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(fileName); return myFileVersionInfo.FileMajorPart + "." +
myFileVersionInfo.FileMinorPart + "." +
myFileVersionInfo.FileBuildPart + "." +
myFileVersionInfo.FilePrivatePart; } public static string GetProductVersion(string fileName) { FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(fileName); return myFileVersionInfo.ProductVersion; } } }
The Create .Net Controller... option on the Tools menu fails when trying to convert this DLL, no meaningfull error messages.
Is there somewhere, a simple example of creating a C# class library and then utilising that class library in LabWindows?
06-01-2017 09:08 AM
Hey krugman3,
I've looked into this and found some ideas on an MSDN forum here:
It looks like there's some tweaking you have to do to be able to call your C# DLL from C. I'd try one of the projects within this thread and see if it works from CVI.
Cheers,
Ryan C.
06-05-2017 12:16 PM
I copy/pasted your example code and it built fine for me (.NET 4.5, CVI 2015 SP1).
I've seen cryptic error messages from the .NET controller wizard when it's unable to load the assembly for some reason. Try closing out of Visual Studio (and any other apps that may have loaded the assembly), to make sure that nothing else has it reserved.
06-08-2017 02:00 AM
Thanks for trying that,
I never managed to generate an fp from the dll
I was unable to get Visual studio to build the program with the "Register for COM interop" checkbox ticked, this turned out to be because I do not have admin on this machine. I got a colleague (who has got admin) to build it for me, but I was still unable to generate an fp from the resulting dll.
Using CVI 2010
However, the ultimate aim of the DLL was to make it easier to get file version and product version from exe's and DLLs, but I have now managed to do this from within LabWindows C code. Took some doing though, so much easier with .Net.