php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #47569 DOTNET cannot instantiate generic classes
Submitted: 2009-03-05 09:23 UTC Modified: 2020-06-25 15:04 UTC
Votes:4
Avg. Score:5.0 ± 0.0
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:2 (50.0%)
From: Sekai dot yu at gmail dot com Assigned:
Status: Closed Package: COM related
PHP Version: 5.2.9 OS: Windows Server
Private report: No CVE-ID: None
 [2009-03-05 09:23 UTC] Sekai dot yu at gmail dot com
Description:
------------
When i've tried to use DOTNET lib's i got an Excpetion errors in 90% of my classes

Tried: System.Console, System.Windows.Forms.MessageBox, System.Collection.Generic.List, System.Windows.Drawing.Graphics (and moch more...)

Reproduce code:
---------------
<?php
/*
$console = new DOTNET("mscorlib", "System.Console");
$var = $console->ReadLine();
$console->WriteLine( "Hello world from PHP - " . $var );

unset( $var );
unset( $console );
exit();
*/
$list = new DOTNET("mscorlib", "System.Collections.Generic.List");

print $list->ToString();
?> 

Expected result:
----------------
Veiwing the Console Commander like in Console APP In c# or use the list generic, grafics etc...

Actual result:
--------------
Fatal error: Uncaught exception 'com_exception' with message 'Failed to instantiate .Net object [CreateInstance] [0x80131522] ' in C:\wamp\www\folder\index.php:2 Stack trace: #0 C:\wamp\www\folder\index.php(2): dotnet->dotnet('mscorlib', 'System.Collecti...') #1 {main} thrown in C:\wamp\www\folder\index.php on line 2


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-06-25 15:04 UTC] cmb@php.net
-Summary: DOTNET Excpection error +Summary: DOTNET cannot instantiate generic classes -Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem
 [2020-06-25 15:04 UTC] cmb@php.net
You can't instantiate System.Console, because that is a static
class, and that limitation is already documented[1].

You can't instantiate System.Collections.Generic.List, because
that is a generic class; that limitation has to be documented.

[1] <https://www.php.net/dotnet>
 [2021-12-02 18:17 UTC] git@php.net
Automatic comment on behalf of cmb69
Revision: https://github.com/php/doc-en/commit/6bc82c07c29f49ad200bd5e40e8da3eb89e54337
Log: Fix #47569: DOTNET cannot instantiate generic classes
 [2021-12-02 18:17 UTC] git@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 16:01:31 2024 UTC