06-09-2010 02:01 AM
Is it even possible ? If it is, where to begin ?
For example, I heard that in order to be used with PHP COM Interop, the .NET assemblies (so here the Act dlls) must have their "ComVisible" attribute set to True. Is it the case ?
Anyway, does someone have some leads about using ACT framework with PHP ?
Solved! Go to Solution.
06-09-2010 10:26 AM
In general all public type members are exposed as visible from a .Net assembly by default to COM. the ComVisibleAttribute is meant as a means to mark a certain member as not available to COM (so you'd use it to explicitly hide something from COM rather than allow access by COM).
Are you using PHP on Windows? What's your web host for PHP? Is this all installed on the same machine as your ACT! client install? I think getting PHP/COM interop assemblies to work with .Net ACT! framework assemblies is less of a problem than understanding where all of these components will reside on your production systems.
06-10-2010 12:50 AM
Thanks a lot for your answer.
In fact, in order to do local tests, all these elements reside on my own machine for now, which is running on Windows ;
I use EasyPHP 1.7 (with PHP 4.3.3), with ACT! 2010, both installed on my own machine. I made an integral copy of the websites and their mysql databases (which my PHP application will interact with) on my machine too.
In the future this PHP application will be stored on a local server (running also on Windows) with the ACT main database and ACT .NET framework, and will interact with the real websites databases hosted on a Nuxit server.
I can handle the mysql part, but the COM interop is a little more tricky for me. I also heard of a PHP 5 class called "DOTNET", could it be more adapted to ACT framework than COM ?
Anyway, thanks for your help.
06-10-2010 10:17 AM - edited 06-10-2010 10:18 AM
Cool, I like these kinds of projects! I think you may have to register the ACT! assemblies you want to use in your project using the regasm.exe in the .Net root driectory, this will make the .Net assembly a registered COM reference. Once your assembly is registered I think...
My PHP is pretty rusty but I think you just need to do something like:
$MyObject = new COM ("ACT.Framework.NameSpace.Class");
$MyObject->Input = "Argument";
echo "Input : $MyObject->Input";
echo "<BR>OutPut : $MyObj->methodx";
I have no way to test this currently and the italicised items are referential, but hope this gives you an idea.
06-11-2010 01:22 AM - edited 06-11-2010 05:31 AM
Thanks for your lead. I couldn't manage to instanciate an "Act.Framework.ActFramework", but then I used regasm.exe and registered the Act.Framework.dll.
Now the instanciation works. But I noticed a little problem with the log-on part ;
$actFramework = new COM("Act.Framework.ActFramework"); // Now working thanks to regasm.exe Act.Framework.dll
The line above is working, I manage to log on to the database without specifying a user name nor a password (by default it logs as "Chris Huffman" and doesn't ask password). Allright!
So I came into ACT! users configuration and tried to put a password for Chris Huffman. Then of course the LogOn line doesn't work anymore, so I wanted to use an overload of this method to specify which user and password to use ;
$actFramework->LogOn("C:\\...\\ACT2010Demo.pad", "Chris Huffman", "test");
The matter is, this overload is working under Visual C# Express, but doesn't seem to in PHP. It shows me this error :
"Fatal error: Uncaught exception 'com_exception' with message 'Error [0x8002000e]...." and tells me that number of parameters is incorrect.
It seems that the COM instanciated ActFramework has imported only one definition of the LogOn method ?
If not, how could I specify which overload I want to use ? Or is there something I missed to do ?
Edit : well, I think I know why I have this error ; I found out that in PHP the overloading of method can't be done the same way that in .NET (must use something like __call() for instance).
That's good to know if you are developping you're own classes, but in my case I just import .NET classes which posess already overloaded methods...
So I deduce that during the wrapping by COM interop, only the first definition of each method is preserved. I didn't found any clear explanation on the subject, though.
Does someone know more about that ?
06-14-2010 07:07 AM
Thanks Allen, I didn't manage to find this crucial information anywhere else !
I tested it and it works pretty well. For now it's all that I need, but I'll surely come back with others questions...
In the meantime, I wish you a nice week.
06-23-2010 05:49 AM
Here I come again with another problem about using Act Framework in PHP via COM Interop. In the example :
$actFramework = new COM("Act.Framework.ActFramework");
The line above works fine, and I think the COM wrapper calls the constructor ActFramework() in order to instanciate the object.
But now I need to instanciate a class that doesn't have a default constructor (constructor without any parameter) : this class is Act.Framework.Lookups.Criteria.
I must create these objects to implement criterias, in order to search contacts by name, etc. So how am I supposed to do ?
This line :
$criteria = new COM("Act.Framework.Lookups.Criteria");
doesn't work (syntax error due, I suppose, to the lack of default constructor), and I can't find a way to give the correspondant parameters to the COM class. Should I deduce that COM can only instanciate classes that posess a default constructor ? Or is there a way to have my criterias instanciated ?
Also tell me if I shoud create another thread for this problem.
Thanks for your answers.
06-23-2010 09:16 AM
Thanks for the advice, but I just tried the line you wrote, and it doesn't work. (Also, I've already tried this DOTNET class before to instanciate an ActFramework, and couldn't manage to make it work neither)
The error is : "Failed to instantiate .Net object [CreateInstance] [0x80070002]" followed by something like "specified file cannot be found".
Same problem with :
And indeed, my problem still the default constructor of the Criteria class, which is not directly accessible, and then prevents instanciation of any Criteria.
If this can't be resolved, is there another way to get contacts by name, company or email ? Perhaps it could works with COM Interop...
Thanks for your help.