Bug #29800 [Opn->Ver]: new DOTNET fails for assemblys other than mscorlib

From: Date: Mon, 21 Oct 2019 07:34:53 +0000
Subject: Bug #29800 [Opn->Ver]: new DOTNET fails for assemblys other than mscorlib
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-223335@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=29800&edit=1 ID: 29800 Updated by: cmb@php.net Reported by: christian at wenz dot org Summary: new DOTNET fails for assemblys other than mscorlib -Status: Open +Status: Verified Type: Bug Package: COM related Operating System: WinXP PHP Version: 5.0.1 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Indeed it is like kevin dot kenny said: .NET classes have to be visible to COM. Changing to documentation issue. Previous Comments: ------------------------------------------------------------------------ [2013-10-21 01:28:04] kevin dot kenny at zygonia dot net I think the problem here is that you can only instantiate .NET classes where they're decorated with the ComVisible(true) attribute. For example in the documentation sample code here: http://www.php.net/manual/en/class.dotnet.php The System.Collections.Stack class is decorated with this attribute: http://msdn.microsoft.com/en-us/library/system.collections.stack.aspx As is the System.Windows.Forms.Form class example earlier in this bug report. However if one tries to instantiate a .NET class without this attribute such as System.Xml.XmlDocument: http://msdn.microsoft.com/en-us/library/system.xml.xmldocument Then an exception is thrown: $xml = new DOTNET('System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089', 'System.Xml.XmlDocument'); Produces: PHP Fatal error: Uncaught exception 'com_exception' with message 'Failed to instantiate .Net object [Unwrapped, QI for IDispatch] [0x80004002] No such interface supported These are my findings from working with .NET 2.0. There seems to be additional problems with instantiating .NET 4 classes because of changes in the way the GAC is used (or not). ------------------------------------------------------------------------ [2012-01-30 11:10:17] bszabolcs at gmail dot com Strange... the first works, the second gives that exception: $fm = new DOTNET('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089', 'System.Windows.Forms.Form'); $sp = new DOTNET('System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089', 'System.IO.Ports.SerialPort'); Both are with fully qualifie assembly name... Is there any way to activate more detailed debugging informations to see what is happening in background? ------------------------------------------------------------------------ [2012-01-30 11:05:08] aharvey@php.net Reopening per the last two comments, although I suspect this is firmly in the "patches welcome" category. ------------------------------------------------------------------------ [2012-01-30 10:48:03] bszabolcs at gmail dot com This bug is still present in PHP 5.3.8. Here is the code I tried to use: $sp = new DOTNET('System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089', 'System.IO.Ports.SerialPort'); The error message: Fatal error: Uncaught exception 'com_exception' with message 'Failed to instantiate .Net object [Unwrapped, QI for IDispatch] [0x80004002] No such interface supported ' ------------------------------------------------------------------------ [2008-12-10 19:42:11] vince at siol dot net Description: --------------- As far as I can tell this bug is still present in 5.2.6. Using a fully qualified assembly name reproduces a different error, so it might be a step closer to working. Reproduce code: --------------- $object = new DOTNET( 'System,Version=2.0.0.0,Culture=neutral,PublicKeyToken=B77A5C561934E089', 'System.Diagnostics.Process' ); Expected result: ---------------- - no output -- Actual result: --------------- PHP Fatal error: Uncaught exception 'com_exception' with message 'Failed to instantiate .Net object [Unwrapped, QI for IDispatch] [0x80004002] No such interface supported ' ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=29800 -- Edit this bug report at https://bugs.php.net/bug.php?id=29800&edit=1

« previous php.bugs (#223335) next »