cancel
Showing results for 
Search instead for 
Did you mean: 

Use dll from C# class in Groovy Script

GeorgeM
New Contributor

Use dll from C# class in Groovy Script

Hello there.

 

I am trying to call a function from a dll generated from a C# class.

I use the following script:

 

import com.sun.jna.Native
import com.sun.jna.Library

interface Hello extends Library {
String GregFunc()
}

def nativeLibraryC = Native.loadLibrary('TestSas', Hello.class)

def methods = nativeLibraryC.getClass().getDeclaredMethods()

for (method:methods) log.info(method);

def lala = nativeLibraryC.GregFunc()

log.info(lala)

 

GregFunc() normaly should just return a string.

The problem is that even though library is loaded i get an error message that GregFunc() cannot be found.

Can anyone help?

3 REPLIES 3
sonya_m
Community Manager

Re: Use dll from C# class in Groovy Script

Thank you @GeorgeM for your question! 

 

@msiadak  @ChrisAdams @nmrao , could you take a look? Thank you!


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
msiadak
Community Hero

Re: Use dll from C# class in Groovy Script

@GeorgeM This sounds like a very interesting problem. Would you be able to provide a sample DLL that I could poke at this with? Otherwise I can try to find one that might be similar to use.

 




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
GeorgeM
New Contributor

Re: Use dll from C# class in Groovy Script

Hi @msiadak .

Thanks for your interest.

I am sharing my dll.

It is pretty simple, i created a class project, there a class "TestClass" in namespace TestSas.

This TestClass has a function "TestFunc" that returns a string message.

GeorgeM_1-1613384991493.png

 

The names are a little different from the ones at the script.

I bulti the project, took the dll and placed it in system32 folder but script cannot execute the function.

I dont know if my way is correct, please let me know if you have any feedback!

Thanks again.

 

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors