PHP Doku:: Lädt ein DOTNET-Modul - function.dotnet-load.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzWindowsbasierte Erweiterungen.NET.NET-Funktionendotnet_load

Ein Service von Reinhard Neidl - Webprogrammierung.

.NET-Funktionen

<<.NET-Funktionen

COM and .Net (Windows)>>

dotnet_load

(PHP 4)

dotnet_loadLädt ein DOTNET-Modul

Beschreibung

int dotnet_load ( string $assembly_name [, string $datatype_name [, int $codepage ]] )
Warnung

Diese Funktion ist EXPERIMENTELL. Das Verhalten, der Funktionsname und alles Andere, was hier dokumentiert ist, kann sich in zukünftigen PHP-Versionen ohne Ankündigung ändern. Seien Sie gewarnt und verwenden Sie diese Funktion auf eigenes Risiko.

Warnung

Diese Funktion ist bis jetzt nicht dokumentiert. Es steht nur die Liste der Argumente zur Verfügung.

Changelog

Version Beschreibung
4.1.0 Der codepage-Parameter wurde hinzugefügt.


5 BenutzerBeiträge:
- Beiträge aktualisieren...
Rudi Lippert
25.10.2010 11:50
If you got here looking for the standard way to load DOTNET modules, you might be better off looking here:
http://php.net/manual/en/class.dotnet.php
sunside
1.07.2007 4:46
The

  if (parameters[0].GetType().ToString() == "System.Int32")

below can be compacted to

  if (parameters[0] is System.Int32)

as well as

  if (parameters[0] is int)

(if you are on a 32bit platform, that is)
thomas dot weidner at voxtronic dot com
23.07.2002 12:54
To realise functions within Microsoft.NET which can use with every type of parameter as boolean, integer, string or any other type you want to use do the following.

Write your function in .NET :
CSharp Example :
MyFunction (params object[] parameters)
{
    if (parameters[0].GetType().ToString() == "System.Int32")
        return "Parameter 0 is an Integer";
    return "Parameter 0 is no Integer";
}

Within PHP do the following :

$parameter[0] = 12345;
$parameter[1] = "My String";
$parameter[2] = false;
$obj = new COM ("NameSpace.Class");
$value = $obj -> MyFunction($parameter)
print($value);

How to work with params and object you could read within the .NET Documentation.

If you have any further question dont be afraid and write me...

Bye
Thomas
Thomas dot Weidner at voxtronic dot com
22.07.2002 11:12
I`ve found an workaround to use the Microsoft.NET within PHP but without the need of compiling the DOTNET.DLL of PHP.

At first write the functions you want to need within PHP in the Microsoft.NET Languages (I`m working in CSharp).

Then make your FunctionsLibrary StrongNamed. Read about how to do this in the SDK-Help. (Key, Version...)

Then you have to register your DLL in GAC.
For this you have to do REGASM /tlb:your.tlb your.dll
Then you have to do GACUTIL /if your.dll

After this your DLL will be recognised with in the whole .NET.

Now... to use your DLL within PHP you just have to use an ordinary COM Object.

$MyObj = new COM ("NameSpace.Class");
$ReturnValue = $MyObj -> MyFunction($MyParams);
$MyObj = NULL;

$MyParams could be any type. For example an Array.

I tested this with PHP 4.2.1, RDK-Framework, SDK-Frwamework, Visual Studio and SharpDevelop. You have not to recompile PHP because you don´t need the DOTNET.DLL .

The only negative aspect within this way due to COMRestrictions is, that REF or OUT Values are not returned. So you have only one return value.
But for an good written function this should be no great restriction.

If you have any further question dont be afraid and write to me...

Bye
Thomas
mb at netminers dot dk
29.04.2002 20:34
Now we are working!
Well that means that if you want to use the .NET modules, from PHP, you'll have to build a new php_dotnet.dll file.
The problem with the existing code is the interface versions of the COM object needed to mix unmanaged code with managed code.

To fix this minor issue, replace
#include "mscorlib.h", in the extensions project of the PHP4.2 source, with the following type library binary file import.
#import "mscorlib.tlb" raw_interfaces_only high_property_prefixes("_get","_put","_putref")

The type library file is converted to a type library header file which is then automatically included by Visual Studio, presuming you are using that. :o)
Have fun! (Mail me if this description was too bad, I can mail the new php_dotnet.dll)

By the way the tlbexp.exe SDK tool can generate the .tlb file.

I'll check with the PHP group to verify they are aware of the issue, so it's nicely fixed in a future release of PHP.

Great stuff,
Michael



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)