Call C# DLL from a JDE C BSFN

vr_cal

Member
Hello,

We have a need to manipulate the Active Directory Network properties and therefore, i wrote a C# DLL to do the same. I am calling the DLL from a C BSFN in the standard way (LoadLib, GetProcAddress, etc.). However, when i call the actual function and pass strings, the C function crashes. If I pass integers to the C# DLL, no issues. It is only for strings that i have the issue. Any thoughts? If somebody can post a small example of what could be done here, it is very much appreciated.

Kind Regards,
Venkat
 
Venkat,

It is crashing probably due to an error in marshaling the character array to a native C# string. Are you passing JCHAR * to the C# dll?

Here is one way of doing this, but this requires you to make the C# assembly COM visible:
https://support.microsoft.com/en-us...in-visual-studio.net-or-in-visual-studio-2005

Another (much easier) approach is to create a C# console app and just call it from E1 using the arguments you need to pass to it.
 
Hello Hari,

Many thanks for your reply. This is what i am doing: I take the lpDS string parameters and strcpy them to char strings. I pass the char strings to the C# function.

That being said, based on your 1st option: when you said that it requires the assembly COM visible, i am not sure what you meant by that.

On your 2nd solution regarding creating the Console app, will the Console app come up on the screen when i call it from the JDE C BSFN? I would rather it not come up. I have several functions that i would like to build inside the C# function. If i get an idea on an easy and clean approach, i can apply the same everywhere.

Would you have some time to walk me through the options and building one single call? Please let me know and we can do a webex . I appreciate your help in advance.

Kind Regards,
Venkat
 
Back
Top