Using the power of COM interop, you can write code in VB.Net or C# and use it in PHP, VB6, or any other language that can access COM. In this article Jayesh shows us how.
Examining the Code Firstly, we create a COM object for the object that we just installed and registered. COM interop makes the .NET assembly look like COM objects, and we can use the same syntax as we use to create typical COM objects in PHP:
$MyObj = new COM ("phpclass.HealthRecord.patient");
Next, we set the lmp property to a valid date, which will then be used to calculate the edd:
$MyObj->lmp = "05/08/2002";
Now we output the LMP property in a human-readable date format. We also output the calculated EDD property to the browser:
Running the Code Open your favorite browser and surf to http://localhost/phpnet.php to see the PHP file in action:
Using COM Interop in VB6 You could use the same steps as shown above to create a COM wrapper around the .NET assembly and use it in VB6. Here's the VB6 code for your reference:
Removing the Assembly from Global Assembly Cache To remove the assembly from the GAC, run gacutil with the /u switch and specify the assembly name, like this:
gacutil /u phpclass
Don't specify the path to the assembly and also don't add the .dll extension to the assembly name.