I’m working on trying to migrate a C# application to Xojo, this application has a client which connects to a 3D rendering application and passes messages and receives a reply.
Rather than try to re create the client in Xojo it seemed a lot easier to just create a DLL seeing as I’m very much a newbie with Xojo
I spend most of last night trying to get it working but failed dismally
The dll is called ClassLibrary1.dll
In C# it does the following by clicking a button on the main form:
[code]using ClassLibrary1;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
[code]namespace ClassLibrary1
{
public class Class1
{
public void Clientx(String strData, string ipadd, int portadd)
{
//All the client stuff goes here
}
}
[/code]
When I tried last night I could find the DLL but it couldn’t find Clientx
Anyway I hope my ramblings make sense lol
thanks
[quote=121544:@nige cope]'m working on trying to migrate a C# application to Xojo, this application has a client which connects to a 3D rendering application and passes messages and receives a reply.
Rather than try to re create the client in Xojo it seemed a lot easier to just create a DLL [/quote]
Declare Function Clientx lib "C:\\Users\
ige\\Desktop\\realprojects\\ClassLibrary1.dll" (strData as CString, portadd As integer, ipadd as CString, response as CString ) AS CString
In the DLL
public static int Clientx(String strData, int portadd, string ipadd, out string response)
the problem I’m having is the “out string response” this is the reply from the DLL, if I take the “out” out it does work but no response back, which I need
[quote=128827:@nige cope]out is to output the response string
strData is the message to send
portadd, is the port
ipadd Is the ip
response is the server output
I don’t usually do dll’s either so there’s probably a different way
Thanks Marcel[/quote]
From what I understand response works well to send from the dll but what you need is that Xojo sends back to the Dll, and that is where it fails ?
in its simplest form, you would click a button in Xojo to send the strData message to the dll, so say it sends “version” to the server the response back will be “v1.3.07.1130” which I need to see in Xojo
IF I don’t have the “out” in the DLL, the message is send and Thea will carry out the command however I can’t get the response back in Xojo
The response back is very useful, the client can interact with Thea , in fact you can control the whole thing remotely, the response can control timers, visually see render progress elapse time, passes,its quite cool when it works lol
Its always a difficult one, the client is only useful with Thea, I don’t have a straight C version or a VB one. as a reference
But I’m almost there I just need to think of a different way to get rid of the out statement
[quote=128835:@nige cope]in its simplest form, you would click a button in Xojo to send the strData message to the dll, so say it sends “version” to the server the response back will be “v1.3.07.1130” which I need to see in Xojo
IF I don’t have the “out” in the DLL, the message is send and Thea will carry out the command however I can’t get the response back in Xojo
The response back is very useful, the client can interact with Thea , in fact you can control the whole thing remotely, the response can control timers, visually see render progress elapse time, passes,its quite cool when it works lol
Its always a difficult one, the client is only useful with Thea, I don’t have a straight C version or a VB one. as a reference
But I’m almost there I just need to think of a different way to get rid of the out statement[/quote]
My suggestion was simply to add another parameter dedicated to give the response back to Xojo. Since you are in control of both the DLL and the calling Xojo program, it seems the easiest way.
First, your Declare doesn’t match your function. Second, to receive a string back from a dll, declare the string as Ptr and pass it a MemoryBlock. So
Declare Function Clientx lib "C:\\Users\
ige\\Desktop\\realprojects\\ClassLibrary1.dll" (strData as CString, portadd As integer, ipadd as CString, response as Ptr) AS Integer
Call it with
dim data as string
dim portadd as integer
dim ipadd as string
dim mresponse as memoryblock
dim response as string
dim ret as integer
...
ret = Clientx(data, portadd, ipadd, mresponse)
response = mresponse.CString(0)