Using custom DLL with Citect 8.2

I am trying to use a custom DLL developed in VStudio 2022 in Citect 2018 R2 (8.2)
I have followed the document "Creating Custom .NET DLLs in Vijeo Citect 2015.pdf" and created the DLL with constructor, and property and methods etc.
I have the DLL built in C# and working properly with a Test App (also done in C#)
I have created an msi and installed the DLL and test App in the Citect pc.
However, I am having trouble using the DLL in Citect, both DLLOpen and also DllClassCreate not returning valid object handle.
I have also tried adding the DLL installed folder to Path but no success.

Is anyone there had success doing a similar thing? What are the rules for a DLL to be able to be used in Citect?

  • Did you create your class library in C# with the (.NET framework) template or the .NET ?

    If you used .NET , try to use the "older" .NET framework.

  • I did not use any template but used .NET 6.0, and had to install .NET sdk 6 to make the test App working, Since .NET 6 is now installed on this Citect PC I assumed it will work. should I use older .NET?

  • Yes, you should use .Net framework and not .NET 6 for your C# class library. At least this is my experience with this .net cicode functions.

  • I am doing the same thing right now. I created a .dll to call, run, control the volume, and stop multiple audio files on demand. I also had the same problem as you at first. Ultimately, the problem wasn't on the Citect end. It ended up being a dependencies problem with the .dll. There were methods used in the .dll that required functionality from other .dlls that wasn't present or in the same location as the machine the .dll was written on.. When my .dll was called it was looking for other, dependent .dlls that weren't where my .dll was expecting them to be. Subsequently, it wouldn't work.

    How I fixed the problem was by compiling all of the dependent methods and functions into my .dll. I am sorry, it has been over ten years since I've done any programming in .NET Studio, so I don't remember the exact options you need to choose in the compiler options section of .NET Studio, but at least for me I got it to work by choosing the compiling options that caused all of the functions and methods used by my .dll to be compiled into my .dll. This ended up making my .dll somewhat of a self-supporting program that didn't rely on any external dependencies because they were already internally compiled into mine. Somebody more current and familiar with .NET Studio programming could probably help you out with that.

    The only "drawback", if you can call it that, is file size. When I originally compiled my .dll with external dependencies, the file size was @ 80 KB. When I compiled my .dll with the dependencies compiled in, the file size went to @ 2 MB. However, with as much storage as is available in modern computers, I would think that this wouldn't be a real problem for you.

  • Thanks for the detailed reply.

    I have simplified the dll code (as a test) so that no other dll's coming in addition to the direct project related ones. But I am still getting the same error at the time of DLLOpen: "GetProcAddress failed. LastError=127" (DllClassCreate does not give such detailed response). GetProcAddress error comes when I enter non-existing function too, meaning the function seems to not been exposed although I have defined it as a Public function..!  (my application is in C#)

    As Bart suggested earlier I have used .Net Standard 2.1 as Target framework for the class library (yes, I do use Class Library template).

  • I always use the .net framework 4.8.1 for the class library.

  • After spending lot of time googling around finally I have found the issue and fixed!

    In order to make the new dll class exposed, I needed to add the following directive:

    using System.Runtime.InteropServices;

    and then before the (public) class declaration, I had to add the below line: 

    [ComVisible(true)]

    Once those 2 things done, I am able to see the results on Citect with DllClassCreate, DllClassGetProperty, DllClassSetProperty,  DllClassCallMethod, DllClassDispose functions.

    DLLOpen function however is still giving error GetProcAddress, 

    I will test now with the extra's I removed, to see if they are also causing issues

  • Nice find! I'm glad you got it working now.

    Only thing I wanted to add is that I believe that DLLOpen() works only with native COM DLLs, like VB6 ones. The DllClass functions are the way to go for.Net.DLLs if I recall correctly.