0

I have Created Simple DLL Which Includes Simple test() Function it returns "Hello India" string.

I am Getting Below Error

"Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object"

enter image description here php.ini Settings

  1. Added this at the end of php.ini:

    [PHP_COM_DOTNET]
    extension=php_com_dotnet.dll
    
  2. enable_dl = On

C# code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DLLExample
{
    public class Calc
    {
        public String test() {
            return "Hello India";   
        }
    }
}

Then Simply Run above Application which Generates "DLLExample.dll" Then I am Just Copy Above Generated "DLLExample.dll" to my PHP Project

My PHP Project Directory

DLLExample
   -DLLExample.dll
   -index.php

I am trying to Call test() Function from PHP.

PHP Code:

<?php
    $obj = new COM("DLLExample.Calc") or Die ("Something Wrong");
    echo $obj->test();
?>
Juned Ansari
  • 5,035
  • 7
  • 56
  • 89

0 Answers0