php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #50473 static dotnet classes can't be called
Submitted: 2009-12-14 23:20 UTC Modified: 2020-03-14 15:36 UTC
Votes:13
Avg. Score:4.7 ± 0.5
Reproduced:12 of 13 (92.3%)
Same Version:2 (16.7%)
Same OS:4 (33.3%)
From: zelnaga at gmail dot com Assigned: cmb (profile)
Status: Closed Package: COM related
PHP Version: 5.3.1 OS: Windows XP
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: zelnaga at gmail dot com
New email:
PHP Version: OS:

 

 [2009-12-14 23:20 UTC] zelnaga at gmail dot com
Description:
------------
$test = new DOTNET('mscorlib', 'System.IO.File');

That yields a "Fatal error: Uncaught exception 'com_exception' with message 'Failed to instantiate .Net object [CreateInstance] [0x80131513] '" error.  Per the comments on php.net/class.dotnet, I thought this might work, instead, but it doesn't:

$test = new DOTNET('mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86', 'System.IO.File');

The example on php.net, however, does work:

$test = new DOTNET('mscorlib', 'System.Collections.Stack');

I think what the problem really is is this: System.IO.File is a static class.  It's not intended to be instantiated whereas System.Collections.Stack is.  In light of this, I think either the ability to call methods within static dotnet classes ought to be added or, failing that, a note should be added to the documentation stating that only instantiatable classes can be used with the DOTNET object.

Reproduce code:
---------------
$test = new DOTNET('mscorlib', 'System.IO.File');

Expected result:
----------------
(nothing)

Actual result:
--------------
Fatal error: Uncaught exception 'com_exception' with message 'Failed to instantiate .Net object [CreateInstance] [0x80131513] ' in C:\path\to\test.php:3
Stack trace:
#0 C:\path\to\test.php(3): dotnet->dotnet('mscorlib, Versi...
', 'System.IO.File')
#1 {main}
  thrown in C:\path\to\test.php on line 3

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-14 11:06 UTC] pawel at atisoft dot poznan dot pl
Reproduced in PHP 5.3.2
Same error while trying to instantiate other classes from mscorlib
 [2012-12-09 23:44 UTC] ben at nullcreations dot net
Reproduced in php 5.4.9 on Windows 7.
 [2020-02-08 11:32 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2020-02-08 11:32 UTC] cmb@php.net
Actually, this is a duplicate of bug #41078, but obviously the
current behavior needs to be documented, so I'm re-categorizing
this as documentation problem.
 [2020-02-23 22:38 UTC] cmb@php.net
-Type: Bug +Type: Documentation Problem
 [2020-03-14 15:36 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=349426
Log: Fix #50473: static dotnet classes can't be called
 [2020-03-14 15:36 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 [2020-03-14 15:36 UTC] cmb@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
 [2020-03-14 15:38 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=63df6ea90b04b7a1538676246737f80dd740f65c
Log: Fix #50473: static dotnet classes can't be called
 [2020-03-14 23:03 UTC] mumumu@php.net
Automatic comment from SVN on behalf of mumumu
Revision: http://svn.php.net/viewvc/?view=revision&revision=349441
Log: Fix #50473: static dotnet classes can't be called
 [2020-03-14 23:05 UTC] phpdocbot@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=c774c340cf6ac20029f5d064c63373a88a3482cc
Log: Fix #50473: static dotnet classes can't be called
 [2020-12-30 11:59 UTC] nikic@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=c19c5de85f405dc9025dce0c7eb7c2bca9d44331
Log: Fix #50473: static dotnet classes can't be called
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 16:01:31 2024 UTC