Bug #29800 [Com]: new DOTNET fails for assemblys other than mscorlib

From: Date: Mon, 21 Oct 2013 01:28:04 +0000
Subject: Bug #29800 [Com]: new DOTNET fails for assemblys other than mscorlib
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-182351@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 Comment by: kevin dot kenny at zygonia dot net Reported by: christian at wenz dot org Summary: new DOTNET fails for assemblys other than mscorlib Status: Open Type: Bug Package: COM related Operating System: WinXP PHP Version: 5.0.1 Block user comment: N Private report: N New Comment: 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). Previous Comments: ------------------------------------------------------------------------ [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 ' ------------------------------------------------------------------------ [2004-10-17 01:00:04] php-bugs at lists dot php dot net No feedback was provided for this bug for over a week, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open". ------------------------------------------------------------------------ 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 (#182351) next »