dongxing4643 2012-10-11 17:49
浏览 40
已采纳

用于.net的Phalanger和php库

I have three php classes Im trying to use in my .net application. I used Phalanger to take those three classes and make a .dll file using this command:

phpc /target:dll Client.php Crypt.php Exception.php

Which of course outputted Client.dll as well as a Client.pdb files.

From there I went to VS2012 and created a new asp.net application and added the Client.dll as a reference. However I do not see the public methods from any of the classes and the object browser window shows:

Client>Client>Base Types>Object (so that I only have the methods of type Object)

I have tried this method/tutorial to get it to work which involves casting a custom interface onto your object however I get the error:

the type or namespace name ScriptContext could not be found

Which of course means that it doesnt know what or where ScriptContext. However this tutorial is from 2007 so I dont know if its just to far out of date or where I should get that class from?

The other tutorial I found is just as old. It says:

If you want to use existing PHP source (developed for standard interpreter) without modifications you have to use legacy mode, but when you want to develop new PHP project you can consider using pure mode

But I cannot find the step for legacy mode within the document and would prefer that over trying the "pure" mode (so that I dont have to change/edit my existing php code). I did try (pure mode) however it wouldn't compile (phalanger compile) with the command above (adding the DynamicObject.php class to the command).

How can I get to my public methods within the php class?

  • 写回答

1条回答 默认 最新

  • dongxia2030 2012-10-12 15:39
    关注
    phpc /target:dll Client.php Crypt.php Exception.php
    

    creates DLL in legacy (standard) mode. This DLL contains 'weird' namespaces, needed for compatibility with PHP semantics. (these namespaces separate code from different script files). .NET interoperability overview of Phalanger 3.0 blog post describes how to use scripts compiled in standard mode.

    Command line option /pure+ tells compiler to create so-called pure mode assembly. In this mode, compiler concatenates all the source files and compiles them as one (as C# does), without any weird namespaces. If you specify [\Export] attribute above the PHP class declaration, resulting DLL will look as it would be compiled from C# code, and you will be able to reference it and use its classes normally.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路