Click here to Skip to main content
15,894,291 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I created dll, the name is "MyDll.dll". The dll consist the below code,
C#
namespace MyDll
{
    public class TestIndex
    {

        public string Sathish(string a)
        {
            a += "..This is .Net";
            return a;
        }
    }
}
<pre>
and then i registered the dll in assembly

 My php file name is Test.php and it should Contain below coding, 
<pre lang="PHP">
<?php
$test = new DOTNET("MyDll,Version=1.0.0.0,Culture=neutral,PublicKeyToken=0baa6d3271b1f300","MyDll.TestIndex");

echo($test->Sathish("From Php.."));

?>


my expected result is "From Php....This is .Net", but i got below error

Fatal error: Uncaught exception 'com_exception' with message 'Failed to instantiate .Net object [Unwrapped, QI for IDispatch] [0x80004002] No such interface supported ' in C:\xampp\htdocs\Test.php:2 Stack trace: #0 C:\xampp\htdocs\Test.php(2): dotnet->dotnet('MyDll,Version=...', 'MyDll.TestInde...') #1 {main} thrown in C:\xampp\htdocs\Test.php on line 2


Please help me...
thank you....
Posted

1 solution

C#
using System.Runtime.InteropServices; // Name Space

namespace MyDll
{
    [ComVisible(true)]     // using ComVisible only we can access the dll
    public class TestIndex
    {
 
        public string Sathish(string a)
        {
            a += "..This is .Net";
            return a;
        }
    }
}

The result is "From Php....This is .Net".
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900