Bug #50473 [Opn]: static dotnet classes can't be called

From: Date: Sat, 08 Feb 2020 11:32:49 +0000
Subject: Bug #50473 [Opn]: static dotnet classes can't be called
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225450@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=50473&edit=1 ID: 50473 Updated by: cmb@php.net Reported by: zelnaga at gmail dot com Summary: static dotnet classes can't be called Status: Open Type: Bug Package: COM related Operating System: Windows XP PHP Version: 5.3.1 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2020-02-08 11:22:52] cmb@php.net Related To: Bug #48425 ------------------------------------------------------------------------ [2012-12-09 23:44:16] ben at nullcreations dot net Reproduced in php 5.4.9 on Windows 7. ------------------------------------------------------------------------ [2010-04-14 11:06:01] pawel at atisoft dot poznan dot pl Reproduced in PHP 5.3.2 Same error while trying to instantiate other classes from mscorlib ------------------------------------------------------------------------ [2009-12-14 23:20:47] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=50473&edit=1

« previous php.bugs (#225450) next »