The dotnet class

(PHP 4 >= 4.1.0, PHP 5, PHP 7, PHP 8)

Introduction

The dotnet class allows you to instantiate a class from a .Net assembly and call its methods and access its properties, if the class and the methods and properties are » visible to COM.

Neither instantiating static classes nor calling static methods is supported. Instantiating generic classes such as System.Collections.Generic.List is not supported either.

Some .Net classes do not implement IDispatch, so while they can be instantiated, calling methods or accessing properties on these classes is not supported.

Note:

You need to install the .Net runtime on your web server to take advantage of this feature.

Note:

Prior to PHP 8.0.0, .Net framework 4.0 and later were not supported by the dotnet class. If assemblies had been registered with regasm.exe, the classes could be instantiated as com objects, though. As of PHP 8.0.0, .Net framework 4.0 and later are supported via the php.ini directive com.dotnet_version.

Class synopsis

class dotnet extends variant {
/* Methods */
public __construct(string $assembly_name, string $datatype_name, int $codepage = CP_ACP)
}

Overloaded Methods

The returned object is an overloaded object, which means that PHP does not see any fixed methods as it does with regular classes; instead, any property or method accesses are passed through to COM and from there to DOTNET. In other words, the .Net object is mapped through the COM interoperability layer provided by the .Net runtime.

Once you have created a dotnet object, PHP treats it identically to any other COM object; all the same rules apply.

dotnet examples

Example #1 dotnet example

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

Table of Contents

Here you can write a comment


Please enter at least 10 characters.
Loading... Please wait.
* Pflichtangabe
There are no comments available yet.

Midjourney Tutorial - Instructions for beginners

There is an informative video about Midjourney, the tool for creating digital images using artificial intelligence, entitled "Midjourney tutorial in German - instructions for beginners" ...

Mike94

Autor : Mike94
Category: KI Tutorials

Basics of views in MySQL

Views in a MySQL database offer the option of creating a virtual table based on the result of an SQL query. This virtual table can be queried like a normal table without changing the underlying data. ...

admin

Autor : admin
Category: mySQL-Tutorials

Definition of stored procedures - an introduction

Stored procedures are predefined SQL code blocks that are stored in a database and can be called up as required. ...

Bernie

Autor : ebiz-consult GmbH & Co. KG
Category: mySQL-Tutorials

Publish a tutorial

Share your knowledge with other developers worldwide

Share your knowledge with other developers worldwide

You are a professional in your field and want to share your knowledge, then sign up now and share it with our PHP community

learn more

Publish a tutorial