downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

VARIANT> <COM
Last updated: Fri, 14 Aug 2009

view this page in

DOTNET

(PHP 4 >= 4.1.0, PHP 5)

DOTNETLa classe DOTNET

$obj = new DOTNET("assembly", "classname")

Description

La classe DOTNET vous autorise à instancier une classe depuis un ensemble .NET et à appeler ces propriétés ainsi qu'à accéder à ces propriétés.

Méthodes

string DOTNET::DOTNET ( string $assembly_name , string $class_name [, int $codepage ] )

Le construction de la classe DOTNET. assembly_name spécifie quel ensemble doit être chargé, et class_name spécifie quelle classe de l'ensemble doit être instanciée. Vous pouvez spécifier optionnellement un codepage à utiliser pour les transformations des chaînes Unicode ; voir COM la classe pour plus de détails sur les codepage .

L'objet retourné est un objet surchargé, ce qui signifie que PHP ne voit aucune méthode fixe comme il le fait avec les classes habituelles ; au lieu de cela, chaque accès à une propriété ou une méthode est effectué à travers COM et depuis DOTNET. En d'autres mots, l'objet .NET est tracé à travers la couche d'interopérabilité de COM fournie par le moteur .NET.

Dès que vous avez créé l'objet DOTNET, PHP l'utilise comme n'importe quel autre objet COM ; Toutes les mêmes règles y sont appliquées.

Exemple #1 Exemple DOTNET

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

Note: Vous devez installer le moteur .NET sur votre serveur Web pour tirer avantage de ces fonctionnalités.



VARIANT> <COM
Last updated: Fri, 14 Aug 2009
 
add a note add a note User Contributed Notes
DOTNET
m holmes at windowlogic dot com dot au
22-Sep-2009 04:31
For strongly-named NET assemblies that are registered in the GAC, you can just use the assembly name
e.g: $x = new DOTNET ("myAssembly", "myClass");

For strongly-named NET assemblies that aren't registered in the GAC, you need to use the full assembly string
e.g. $x = new DOTNET('myAssembly, Version=X.X.X.X, Culture=neutral, PublicKeyToken=ZZZZZZZZZZZZ', 'myClass');

You can't instantiate assemblies that haven't been strongly named.

"Strongly named" means that the assembly has a public key. To strongly name your own classes in Visual Studio, go to the Signing tab in the project properties and click the 'sign the assembly' box and choose a key file name.

To register an assembly in the GAC, there are various tools around to do that, but the easiest method is to drag-and-drop the compiled assembly into c:\windows\assembly using windows explorer (a shell extension is installed by default that handles registering dragged files).
kschroeder at mirageworks dot com
08-Apr-2009 06:55
In order to find out what the PublicKeyToken value is, open up Explorer and go to c:\windows\assembly.  In that directory you will see all of the registered assemblies along with their PublicKeyToken value.
Kai Sellgren
26-Mar-2009 05:14
My HTTPD crashed everytime I used this feature. To fix it, I had to switch to CGI and now everything works fine.
G dot B dot Yahav at Gmail dot com
05-Mar-2009 08:30
Here is a simple example using .NET Framework in PHP

<?php
$console
= new DOTNET("mscorlib", "System.Console");
$varible = $console->ReadLine();
$console->WriteLine( "Varible: " . $varible );
$console->WriteLine();

unset(
$varible );
unset(
$console );
exit();
?>
sam at bitopia dot co dot uk
02-May-2008 03:54
If you want to load any other assembly apart from mscorlib, you'll need to include it like the following

$x = new DOTNET('The.Assembly.Name, Version=X.X.X.X, Culture=neutral, PublicKeyToken=ZZZZZZZZZZZZ', 'The.Class.Name');

Replace all relevant details.

VARIANT> <COM
Last updated: Fri, 14 Aug 2009
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites