PHP and COM objects (Using a 3rd-party .DLL)

Hey all,

I’m pretty new here, but from the looks of it, this seems like a pretty lively community! Anyway, to my question… I have recently undergone days of stress and headache trying to get a .dll assembly file, originally written in C#, to register and become “COM-ready”. Below are the steps I’ve taken to do this. My main issue is (given I’ve done all the necessary steps for the third-party .dll) how do I use the PHP COM class to use the .dll’s class methods?

Steps I’ve Taken:

  1. I heard I needed to give the third-party .dll assembly file a strong name key. In order to do this, I had to dissemble and reassemble (using the command-line tool ildasm.exe) the .dll (“3party.dll”) and add the strong name key using the command-line tool (sn.exe) – “sn –k mykey.snk”

  2. After that, I had to register the assembly using the Assembly Registration Tool (regasm.exe). After using this tool, it created a .tlb file (“3party.tlb”).

  3. Following the registration, I found that needed to add the assembly to the GAC (Global Assembly Cache) using the gacutil.exe. This added the file to the assembly folder on my computer (C:\Windows\Microsoft.NET\assembly).

What Do I Do Now?

Assuming I’ve performed all the necessary preliminary steps to using a third-party C# .dll assembly file as a COM object in PHP, what do I need to do to call this .dll file and use it within my PHP code? I’ve tried commands like:

[php]$myDllObj = new COM(“3party.dll”);[/php]

to no avail…

Also, with it being a third-party .dll… and the COM class object requiring parameters: COM(Application.ID)… given just the .dll assembly name (“3party”) and the methods associated with the .dll file, how do I find the “Application.ID”? I also read it takes either a ProdID, CLSID (classID), or a Moniker… If that’s the case, how do I find these values as well so I can use this in the PHP code and call the methods in the .dll file.

Anyway, with my lack in both PHP knowledge and all-things-assemblies, I’ve been having an extremely hard time trying to get even this far. Hopefully, someone can help me resolve this issue.

Thanks in advance.

http://us.php.net/manual/en/class.com.php

Wish I could help you but I am not accustomed to doing what you are doing, but I found an article which you may or may not have come across which might be of some use to you!:
http://dev.juokaz.com/winphp-2009/using-php-with-c-written-libraries
hope this help you out!

Ahh yes… I’ve come across this one. Difference with his is that he wrote the C# project file (.dll) so, (assuming my problem is just how I’m calling the .dll in my PHP code) so he has the project name & class name available to use in the PHP COM Class call (below is the call he used): "[php]$obj = new COM(“phpclass.classname”);[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service