|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-05-30 18:57 UTC] sean at iplus dot plus dot com
Description: ------------ When trying to instantiate a DOTNET object in Version 5.0.4 I get a 'com_exception'. I have Microsoft.NET 1.1 installed. The bug appears similar to a previous bug: BUG #29490 'Failed to instantiate .Net object' using PHP.NET docu example BUG #30461 "Failed to Instantiate .Net Object" error (again) Bug #29490 was fixed in version 5.0.1. I tried version 5.0.1, 5.0.2, 5.03 and could not instantiate a DOTNET object. However the error message was different for different versions. Version Error message ---------------------------------- 5.0.4 Failed to instantiate .Net object [CreateInstance] [0x80070057] The parameter is incorrect 5.0.3 Failed to instantiate .Net object [CreateInstance] [0x80070057] The parameter is incorrect 5.0.2 Failed to initialize .Net runtime 5.0.1 Failed to initialize .Net runtime The full results of my tests are shown below. ################################################################## Tests run on previous PHP versions - all with same reproduce code ################################################################## ################################################################## PHP VERSION = 5.04 ################################################################## C:\PHP>php-5.0.4-Win32\php.exe -v PHP 5.0.4 (cli) (built: Mar 31 2005 02:45:48) Copyright (c) 1997-2004 The PHP Group Zend Engine v2.0.4-dev, Copyright (c) 1998-2004 Zend Technologies C:\PHP>php-5.0.4-Win32\php.exe dotnet-example.php Fatal error: Uncaught exception 'com_exception' with message 'Failed to instantiate .Net object [CreateInstance] [0x80070057] The parameter is incorrect. ' in C:\PHP\dotnet-example.php:2 Stack trace: #0 C:\PHP\dotnet-example.php(2): dotnet->dotnet('mscorlib', 'System.Collecti...') #1 {main} thrown in C:\PHP\dotnet-example.php on line 2 ################################################################## PHP VERSION = 5.03 ################################################################## C:\PHP>php-5.0.3-Win32\php.exe -v PHP 5.0.3 (cli) (built: Dec 15 2004 08:07:57) Copyright (c) 1997-2004 The PHP Group Zend Engine v2.0.3, Copyright (c) 1998-2004 Zend Technologies C:\PHP>php-5.0.3-Win32\php.exe dotnet-example.php Fatal error: Uncaught exception 'com_exception' with message 'Failed to instantiate .Net object [CreateInstance] [0x80070057] The parameter is incorrect. ' in C:\PHP\dotnet-example.php:2 Stack trace: #0 C:\PHP\dotnet-example.php(2): dotnet->dotnet('mscorlib', 'System.Collecti...') #1 {main} thrown in C:\PHP\dotnet-example.php on line 2 ################################################################## PHP VERSION = 5.02 ################################################################## C:\PHP>php-5.0.2-Win32\php.exe -v PHP 5.0.2 (cli) (built: Sep 24 2004 01:25:41) Copyright (c) 1997-2004 The PHP Group Zend Engine v2.0.2, Copyright (c) 1998-2004 Zend Technologies C:\PHP>php-5.0.2-Win32\php.exe dotnet-example.php Fatal error: Uncaught exception 'com_exception' with message 'Failed to initialize .Net runtime' in C:\PHP\dotnet-example.php:2 Stack trace: #0 {main} thrown in C:\PHP\dotnet-example.php on line 2 ################################################################## PHP VERSION = 5.01 ################################################################## C:\PHP>php-5.0.1-Win32\php.exe -v PHP 5.0.1 (cli) (built: Aug 12 2004 23:30:46) Copyright (c) 1997-2004 The PHP Group Zend Engine v2.0.1, Copyright (c) 1998-2004 Zend Technologies C:\PHP>php-5.0.1-Win32\php.exe dotnet-example.php Fatal error: Uncaught exception 'com_exception' with message 'Failed to initialize .Net runtime' in C:\PHP\dotnet-example.php:2 Stack trace: #0 {main} thrown in C:\PHP\dotnet-example.php on line 2 ################################################################## ################################################################## Reproduce code: --------------- <?php $stack = new DOTNET("mscorlib", "System.Collections.Stack"); $stack->Push(".Net"); $stack->Push("Hello "); echo $stack->Pop() . $stack->Pop(); ?> Expected result: ---------------- Hello .Net Actual result: -------------- Fatal error: Uncaught exception 'com_exception' with message 'Failed to instantiate .Net object [CreateInstance] [0x80070057] The parameter is incorrect. in C:\PHP\dotnet-example.php:2 Stack trace: #0 C:\PHP\dotnet-example.php(2): dotnet->dotnet('mscorlib', 'System.Collecti...') #1 {main} thrown in C:\PHP\dotnet-example.php on line 2 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 02:00:01 2025 UTC |
Tried the latest snapshot but still get same result as shown below: C:\PHP\BUGS>php5-win32-latest\php.exe -v PHP 5.1.0-dev (cli) (built: May 30 2005 20:22:11) Copyright (c) 1997-2005 The PHP Group Zend Engine v2.1.0-dev, Copyright (c) 1998-2004 Zend Technologies C:\PHP\BUGS>php5-win32-latest\php.exe dotnet-example.php Fatal error: Uncaught exception 'com_exception' with message 'Failed to instantiate .Net object [CreateInstance] [0x80070057] The parameter is incorrect. ' in C:\PHP\BUGS\dotnet-example.php:2 Stack trace: #0 {main} thrown in C:\PHP\BUGS\dotnet-example.php on line 2 #I have spent the last two days on trying to get the DOTNET-class working. I have tried PHP 5.1, 5.2 and 6.0, which all outputted the same error-message. I am running Windows XP SP2 with the .NET Framework 2.0 (I have also tried 1.0). I have both tried the downloadable version of PHP 5.1 and the snapshot. Both 5.2 and 6.0 was from snapshot (31-07-2006). Same script as test-script as Sean (the one from the manual): <?php $stack = new DOTNET("mscorlib", "System.Collections.Stack"); $stack->Push(".Net"); $stack->Push("Hello "); echo $stack->Pop() . $stack->Pop(); ?> Expected result: Hello .Net Actual result: Fatal error: Uncaught exception 'com_exception' with message 'Failed to instantiate .Net object [CreateInstance] [0x80131522] ' in D:\phpprogs\PW-uploader\filedialog.php:2 Stack trace: #0 D:\phpprogs\PW-uploader\filedialog.php(2): dotnet->dotnet('mscorlib', 'System.Collecti...') #1 {main} thrown in D:\phpprogs\PW-uploader\filedialog.php on line 2I've been banging my head on this one for a while as well... I was looking to instantiate some .NET stuff from PHP, so at first I tried the standard example on the DOTNET man page Windows XP SP2 IIS 5 PHP 5.1.6 .NET Framework 1.1.4322 <?php $stack = new DOTNET("mscorlib", "System.Collections.Stack"); ?> Throws: Failed to instantiate .Net object [CreateInstance] [0x80070057] The parameter is incorrect. I was able to find a workaround, I compiled the functionality I wanted to be able to use into a DLL (be sure to enable COM interop, and strong namespace) with VS 6, registered it with regasm: RegAsm.exe C:\path\to\your\<dllname>.dll /tlb:<dllname>.tlb Then added it to the global assembly cache: gacutil.exe /i C:\path\to\your\<dllname>.dll (Side note, if you want to unregister/remove it from the GAC, you must cycle the IIS application pool first.) From there you can: <?php $obj=new COM('your.strong.name'); $returnValue=$obj->yourMethod(); ?>