php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46224 Cannot instantiate .Net object (ABCpdf 6.1 .Net)
Submitted: 2008-10-03 13:07 UTC Modified: 2021-08-15 04:22 UTC
Votes:7
Avg. Score:3.9 ± 1.4
Reproduced:5 of 5 (100.0%)
Same Version:2 (40.0%)
Same OS:1 (20.0%)
From: mark at koalit dot dk Assigned: cmb (profile)
Status: No Feedback Package: COM related
PHP Version: 5.2.6 OS: Vista Business SP1 (da)
Private report: No CVE-ID: None
 [2008-10-03 13:07 UTC] mark at koalit dot dk
Description:
------------
.Net framework version 3.5 (latest) is installed.

Installed a specific .Net component, but PHP fails to instantiate the object. 

The script is runnning from command line.


The standard example:
$stack = new DOTNET("mscorlib", "System.Collections.Stack"); 
$stack->Push(".Net"); 
$stack->Push("Hello "); 
echo $stack->Pop() . $stack->Pop();

Works fine - returns "Hello .Net"
Seems like lot's of users have problems using .Net objects from PHP - can you confirm this as a bug or is a local problem ?

Reproduce code:
---------------
$pdf = new DOTNET("Assembly=ABCpdf, Version=6.1.1.5, Culture=neutral, PublicKeyToken=a7a0b3f5184f2169", "Websupergoo.ABCpdf6.Doc");

(needs to install ABCpdf 6.1 .Net from www.websupergoo.com)

Expected result:
----------------
nothing

Actual result:
--------------
PHP Fatal error : Uncaught exception 'com_exception' with message 'Failed to instantiate .Net object [CreateInstance] [0x80131047]' in D:\dotnet\dotnet.php
Stack trace:
#0 (snip) dotnet->dotnet('Assembly=ABCpdf...', 'Websupergoo.ABCpdf6.Doc')
#1 {main}
thrown in D:\dotnet\dotnet.php

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-03 13:08 UTC] mark at koalit dot dk
Forgot to include PHP version (5.2.6)
 [2008-10-24 10:39 UTC] bjori@php.net
reclassified.
 [2009-07-08 11:53 UTC] p dot stankowski at transcomp dot pl
.Net framework 3.5 installed. PHP version 2.3.0.
I have created class library in C# called TestLibrary.dll.
It has only one class:

namespace TestLibrary
{
    public class Test
    {
        public string GetString() { return "Test passed"; }
    }
}

Then signed it and added it to GAC. In C:\Windows\assembly I have found all values needed:
Version: 1.0.0.0
Culture: Neutral
Public Key Token: c42df41937303b82

Script:

<?php
$test = new DOTNET("TestLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c42df41937303b82'", "TestLibrary.Test");
print($test->GetString());
?>

Expected result:
Test passed


Actual result:

PHP Fatal error:  Uncaught exception 'com_exception' with message 'Failed to instantiate .Net object [CreateInstance] [0x80131047] ' in C:\home\Projects\hi_1289_IT-ZEB-SERVER\trunk\src\PHPWithNETTest\index.php:10
Stack trace:
#0 C:\home\Projects\hi_1289_IT-ZEB-SERVER\trunk\src\PHPWithNETTest\index.php(10): dotnet->dotnet('TestLibrary, Ve...', 'TestLibrary.Tes...')
#1 {main}
  thrown in C:\home\Projects\hi_1289_IT-ZEB-SERVER\trunk\src\PHPWithNETTest\index.php on line 10
 [2009-07-08 12:09 UTC] p dot stankowski at transcomp dot pl
Just had to replace:

"TestLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c42df41937303b82'"

with:

"TestLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c42df41937303b82"

Sorry for spam, one sign "'" caused this error. Now the result is "Test passed".
 [2021-08-05 12:22 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-08-05 12:22 UTC] cmb@php.net
Is this still an issue with any of the actively supported PHP
versions[1]?  Note that as of PHP 8.0.0, you can (and likely have)
to set com.dotnet_version[2] for this to work.  Prior to PHP 8.0.0,
you may be out of luck, and need to workaround.

[1] <https://www.php.net/supported-versions.php>
[2] <https://www.php.net/manual/en/com.configuration.php#ini.com.dotnet-version>
 [2021-08-15 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC