如何创建C#DLL在PHP中使用 [英] How to create C# DLL to use in PHP

查看:106
本文介绍了如何创建C#DLL在PHP中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是ASP.NET 2.0 C#.NET的DLL,它的工作现在。我想在PHP中使用同一个DLL。

I'm using a C#.NET DLL with ASP.NET 2.0 and it's working now. I want to use the same DLL in PHP.

我在PHP中的新手;会有人请告诉我如何使用它在PHP或者你可以分享一些例子吗?

I'm a newbie in PHP; would someone please tell me how to use it in PHP or could you share some example?

推荐答案

PHP有内置的Windows的唯一扩展名为DOTNET ,允许你使用.NET库中的PHP应用程序。

PHP has a built-in Windows-only extension called DOTNET that allows you to use .NET libraries in a PHP application.

请注意,你需要确保你的组件被声明为COM可见:

Note that you'll need to make sure your assemblies are declared as COM visible:

[assembly: ComVisible(true)]

下面就是两个例子。

<?php
 $stack = new DOTNET("mscorlib", "System.Collections.Stack");
 $stack->Push(".Net");
 $stack->Push("Hello ");
 echo $stack->Pop() . $stack->Pop();
?>

另一个例子证明DOTNET类的功能:

Another example demonstrating functionality of DOTNET class:

<?php

$full_assembly_string = 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=a8425bc35256e463';
$full_class_name = 'System.Windows.Forms.Form';
$form = new DOTNET($full_assembly_string, $full_class_name);

// code to add buttons, menus, text, etc

$form->Show();

$form_event = '';
while($form_event !== 'close') {

  // handle form functions and events

  }
?>

这篇关于如何创建C#DLL在PHP中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆