I’m sure someone that has done this will jump in …
The name is case sensitive so you need “@Fsb” not upper “@FSB”. That is not your only problem…
A Clarion STRING is not the same as a C# String. You will want to use a CSTRING in Clarion and in C# Marshall it as an ANSI Null Terminated String.
Your Clarion type will change to below. You must pass by Address hence the * Asterisk. You need RAW or Clarion expects the CString Size as another parameter (hidden in Clarion code):
The mangled export symbol name should be ATUALIZAESTOQUENOVO_TESTE
but check the MAP or EXP file to be certain. Remember it’s Case Sensitive.
A better alternative would be to use a BSTRING in Clarion and Marshal it as a Unicode BSTR from C#. RAW is not required on a BSTRING it only passes the address and no length (the length is built into the BSTR type).
and the mangled export symbol name should be ATUALIZAESTOQUENOVO_TESTE
but check the MAP or EXP file to be certain.
Edit 2:00 pm
Added PASCAL per Oggy to correct these examples which removes @Fxxx from the mangled name. Also PASCAL is important for proper stack cleanup otherwise you’ll probably GPF on return to the caller.
Been that way couple of weeks ago. So, first of all, if you are using clarion composed dll in c# application, you MUST add pascal attribute to your exported dlls, procedures…
So, your procedure looks like: ```
AtualizaEstoqueNovo_Teste PROCEDURE (bstring pr),pascal. In that case you avoid to use exported flags: @FSB.
One more thing. If this is hand-coded project that you try to use in c# application? I also try this and neve succeeded. So better use application generator to create your procedures.
[DllImport("C:\\Tests\\48\\prog\\ss007.dll"
but, it is much better, or mandatory, to use like [DllImport(@"C:\\Tests\\48\\prog\\ss007.dll" because you must point to the path where your dll is
… and third, as Carl wrote, if you are using string parameter, on clarion side that MUST be bstring.
On C# side you are declaring you clarion proc as:
const UnmanagedType MYSTRING1 = UnmanagedType.BStr; // marshaled bstring
[DllImport(V, EntryPoint = " ATUALIZAESTOQUENOVO_TESTE ")] // importing your dll with pascal entry point
static extern void ATUALIZAESTOQUENOVO_TESTE([MarshalAs(MYSTRING1)] string MYSTRING1);
and now, calling looks like:
public void TestClarion()
{
string passedstring = "Test to pass to clarion "; // string with value that you will pass to clarion
ATUALIZAESTOQUENOVO_TESTE(passedstring);
}
There are a lot of resources here on ClarionHub about working with C#/.net.
Search these out and review the topics. https://clarionhub.com/search?q=.net
… also, if you wish to return value from clarion to c#, use:
[DllImport(@"C:\\Test\\48\\prog\\ss007.dll", EntryPoint = "ATUALIZAESTOQUENOVO_TESTE")]
[return: MarshalAs(MYSTRING1)] // mandatory
public static extern string ATUALIZAESTOQUENOVO_TESTE([MarshalAs(MYSTRING1)] string MYSTRING1); // this is function (string), not void anymore
and in code, like in clarion:
somestring = ATUALIZAESTOQUENOVO_TESTE(yourstringparameter);
Of course, return parameter in clarion is bstring, so your declaration of clarion function would looks like;
AtualizaEstoqueNovo_Teste PROCEDURE (bstring pr),bstring,pascal
Olá
Estou procurando muito algo parecido para executar um porcedimento do Clarion pelo C#.
Fiz varios testes porem sem nenhum resultado.
Vc teria algum exemplo para compartilhar ?
Desde já agradeço!
Google Translate - Portuguese detected
Hello
I’m really looking for something similar to run a Clarion procedure from C#.
I did several tests but without any result.
Do you have any examples to share?
If I understood well, you need some help with clarion and c#?
Here is one small example, in zip file, the password for zip is: 1234.
In zip is clarion sample, and c# s clarionandcsharp.zip (9.1 MB)
ample.