I've been trying to call a .net assembly from PHP through com (using DOTNET()). It seems like php is finding the DLL and initializing properly, but I can't see/use the methods for some reason. Anyone know how I might be able to fix this?
Here is the php code I'm using to call the .net class. When I call it the output is "hello1 hello2". When I try to directly call the function by doing $csclass->ModelBuilder("","") I get a 500 server error specifying that it couldn't find the function.
<?php
echo "hello1";
try{
$csclass = new DOTNET("ModelBuilder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1208136d23b48dc5",
"ModelBuilder.ModelBuilder2");
$class_methods = get_class_methods($csclass);
foreach ($class_methods as $method_name) {
echo "$method_name\n";
}
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
echo "hello2";
?>
Here is the the class in the assembly I'm trying to call (built using .net 3.5, signed with a strong name, and registered with gacutil):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using OfficeOpenXml;
using System.Runtime.InteropServices;
namespace ModelBuilder
{
[ClassInterface(ClassInterfaceType.AutoDual)]
[ComVisible(true)]
public class ModelBuilder2
{
[ComVisible(true)]
public Boolean BuildModel(String outputFileLoc,String excelTemplateFile)
{
try
{
//do stuff
return true;
}
catch (Exception e)
{
return false;
}
}
}
var_dump
ing$classmethods
? – Cole Johnson Jun 3 '12 at 0:58