php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33188 Cannot instantiate a DOTNET object
Submitted: 2005-05-30 18:57 UTC Modified: 2007-02-21 01:14 UTC
Votes:22
Avg. Score:4.7 ± 0.5
Reproduced:21 of 21 (100.0%)
Same Version:9 (42.9%)
Same OS:15 (71.4%)
From: sean at iplus dot plus dot com Assigned: wez (profile)
Status: Closed Package: COM related
PHP Version: 5CVS-2005-05-31 OS: Windows 2000
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sean at iplus dot plus dot com
New email:
PHP Version: OS:

 

 [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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-30 23:00 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-05-30 23:43 UTC] sean at iplus dot plus dot com
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
#
 [2005-05-30 23:56 UTC] sniper@php.net
Did you reboot..? :)

 [2005-05-31 23:04 UTC] sean at iplus dot plus dot com
I have tested again after a reboot but still get the same result. 

Whats the significance of a reboot ? What gets installed/modified ? I though I just had to unzip the binaries and run PHP.EXE with a .PHP script. Im not using PHP with a webserver - just using PHP.EXE on the command line. I didnt think I had to install anything extra for PHP (and the DOTNET extension) to work. Maybe I've missed something here ?

Thanks
 [2005-08-29 18:06 UTC] hobbit at lantic dot net
php 5.0.4 (cli) still has this issue
 [2005-08-29 18:28 UTC] hobbit at lantic dot net
5.1.0-dev (cli) - bug still present
 [2006-05-06 17:41 UTC] bvanderweb at gmail dot com
I am unable to make the simple stack example work in my environment, either (same error message). I am using .NET 1.1 in Windows XP SP2. It would be really great for PHP to get this working as it does in Perl, Python, etc.
 [2006-07-31 14:18 UTC] kaspernj at gmail dot com
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 2
 [2006-09-21 20:52 UTC] arockwell at eatonvance dot com
I'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();
?>
 [2007-02-21 01:14 UTC] stas@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

I think I fixed it in CVS (at least it works for me :)
 [2011-07-29 08:01 UTC] ramosbs at hotmail dot com
I've got the same problem. And that is supposed to have been fixed in the newest version. But i'm using php 5.3.6 and I still got the same error message.
Can someone tell me exactly what version of php has to be installed? (I already have the .NET framework of course)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 23:01:27 2024 UTC