Search code examples
c#clarion

Unnable to pass paramters to Clarion Dll on C#


I have a Clarion Dll and I need to call a procedure inside of it from C# (I have access to both of the codes).

It works perfectly if I don`t try to pass any parameters to the procedure.

This is the actual Clarion code, it has nothing inside, I am using it just for testing purposes.

AtualizaEstoqueNovo_Teste PROCEDURE  (string pr)           ! Declare Procedure
    CODE

The procedure MAP declaration.

50A5C8 ATUALIZAESTOQUENOVO_TESTE@Fsb

From the C# end, I am declaring an extern void function.

[DllImport("C:\\Tests\\48\\prog\\ss007.dll", EntryPoint = "ATUALIZAESTOQUENOVO_TESTE@FSB")]
    public static extern void ATUALIZAESTOQUENOVO_TESTE(string pr);   

I am calling it like any other function

ATUALIZAESTOQUENOVO_TESTE("");

It throws me the error "Unable to find an entry point named "ATUALIZAESTOQUENOVO_TESTE@FSB""

The funny thing is that if I try to do the same thing but without using any parameters, it works.

This is how I declared the function without parameters:

[DllImport("C:\\Tests\\48\\prog\\ss007.dll", EntryPoint = "ATUALIZAESTOQUENOVO_TESTE@F")]
    public static extern void ATUALIZAESTOQUENOVO_TESTE();

I really don`t know what I am missing.

Also, the C# code is inside a Windows Service, but I think that shouldn't matter


Solution

  • So, I found a way to make it work and you don't have to pass the "@Fsb".

    const UnmanagedType MYSTRING1 = UnmanagedType.BStr; // marshaled bstring
    
    [DllImport(@"C:\\Tests\\48\\prog\\ss007.dll", EntryPoint = "ATUALIZAESTOQUENOVO_TESTE")]
    public static extern void ATUALIZAESTOQUENOVO_TESTE([MarshalAs(MYSTRING1)] string MYSTRING1);