DEFINE CLASS myVFPServer1 AS SESSION OLEPUBLIC DATASESSION = 2 && set private datasession PROCEDURE INIT() SYS(2335,0) && set unattended mode ENDPROC PROCEDURE myDoCmd(tcCmd) &tcCmd && execute whatever VFP command is passed ENDPROC PROCEDURE ERROR LPARAMETERS nError, cMethod, nLine #DEFINE CRLF CHR(13) + CHR(10) LOCAL lcErrorMessage * Append to error log file lcErrorMessage = TRANSFORM(DATETIME()) + CRLF + ; THIS.NAME + CRLF + ; "Error Number : " + TRANSFORM(nError) + CRLF + ; "Method : " + cMethod + CRLF + ; "Line : " + TRANSFORM(nLine) + CRLF + ; "Message : " + MESSAGE()+ CRLF STRTOFILE(lcErrorMessage, "error.txt", .T.) * Notify the client COMRETURNERROR(THIS.NAME, lcErrorMessage) ENDPROC PROCEDURE myEval(tcExpr) RETURN EVAL(tcExpr) && evaluate the parameter, assuming it is a valid VFP expression ENDPROC ENDDEFINEThen, from the Command window:
BUILD PROJECT VFPserver FROM VFPServer BUILD EXE VFPserver FROM VFPserver oVFP = CREATEOBJECT("VFPserver.myVFPserver1") && create the VFP automation server object oVFP.myDoCmd("use c:\temp\sometable") && use a sample table somewhere ?oVFP.myEval("'Table contains ' + TRANSFORM(RECCOUNT())") && get the record count *This sample intended for VFP test. For C# you just use the appropriate syntax to instantiate this VFPServer and call its functions.Note, that EXE COM server starts in the directory where VFP runtime is, so you have to set path to your directory where DBF is or use full path filename.