Home > Backend Development > PHP Tutorial > PHP5.5 调用C#写的dll

PHP5.5 调用C#写的dll

WBOY
Release: 2016-06-06 20:44:42
Original
1071 people have browsed it

dll

<code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;

namespace Toledo
{
    [ComVisible(true)]
    public class Scale
    {
        public string write()
        {
            return "hello world!";

        }

    }
}
</code>
Copy after login
Copy after login

已经强制签名、已经注册:

<code>regasm  Toledo.dll 

gacutil /I Toledo.dll  
</code>
Copy after login
Copy after login

PHP.ini

<code>[PHP_COM_DOTNET]
extension=php_com_dotnet.dll
</code>
Copy after login
Copy after login

index.php

<code><?php $j = new COM("Toledo.Scale") or die("调用COM失败!");
    $s = $j->write();
    echo $s;
</code>
Copy after login
Copy after login

报错

Fatal error: in D:\xampp\htdocs\com\index.php on line 2

非常费解,求指点! -_-||

回复内容:

dll

<code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;

namespace Toledo
{
    [ComVisible(true)]
    public class Scale
    {
        public string write()
        {
            return "hello world!";

        }

    }
}
</code>
Copy after login
Copy after login

已经强制签名、已经注册:

<code>regasm  Toledo.dll 

gacutil /I Toledo.dll  
</code>
Copy after login
Copy after login

PHP.ini

<code>[PHP_COM_DOTNET]
extension=php_com_dotnet.dll
</code>
Copy after login
Copy after login

index.php

<code><?php $j = new COM("Toledo.Scale") or die("调用COM失败!");
    $s = $j->write();
    echo $s;
</code>
Copy after login
Copy after login

报错

Fatal error: in D:\xampp\htdocs\com\index.php on line 2

非常费解,求指点! -_-||

建议封装到WCF中调用

http://www.cnblogs.com/tianbang/archive/2012/05/10/2494147.html

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template