davewelsh,
Ok I just finished doing it with C# for VFP 6 or 7.
Using Visual Studio .NET create a C# Class Library project and name it "VFPMath" and I used "E:\Temp\NETDLLFORVFP6 for my location...
C# code for the Class1.cs file:
Code:
using System;
namespace VFPMATH {
public class MathFunctions : System.EnterpriseServices.ServicedComponent {
public Int32 Add(Int32 x, Int32 y) { return(x + y);}
public Int32 Subtract(Int32 x, Int32 y) { return(x - y);}
public Int32 Multiply(Int32 x, Int32 y) { return(x * y);}
public Int32 Divide(Int32 x, Int32 y) { return(x / y);}
}
}
...next in your Solution Explorer add a reference to "System.EnterpriseServices"
...then from a DOS command prompt and create a random key pair and stores it in VFPMath.snk You can use the Strong Name tool to do this:
Here is what my DOS command looked like for creating the VFPMath.snk file:
E:\Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Bin>SN -k VFPMath.SNK
..now I copied VFPMath.snk in next into the folder where my dll was going to be built (I just used the debug folder in bin, since I wasn't looking to release this)
ok, back into C# and over in your Solutions Explorer select the AssembliesInfo.cs and look for the line that reads:
[assembly: AssemblyKeyFile(""
]
...and change it to...
[assembly: AssemblyKeyFile("E:\\Temp\\NETDLLFORVFP6\\VFPMATH\\bin\\Debug\\VFPMath.SNK"
]
...as you can see I am using the fullpath, you could use something relative or in the path
ok now build your dll and then back to the DOS command prompt to register it...I used the following command to register mine (modify your's to suit):
E:\Temp\NETDLLFORVFP6\VFPMATH\bin\Debug>C:\WINNT\Microsoft.NET\Framework\v1.0.37
05\RegSvcs VFPMath.dll
...Once the assembly is installed then it's finally time to go into VFP and run the following from the command window:
oVFPMath = CreateObject("VFPMath.MathFunctions"
?oVFPMath.add(5,4)
?oVFPMath.subtract(5,4)
?oVFPMath.multiply(5,4)
?oVFPMath.divide(5,4)
Slighthaze =
NULL