COM Error with PHP

Dear Sir,
I try to use Aspose Word from PHP (apache 2.2). I registered DLL with command :
regasm \bin\net2.0\Aspose.Words.dll /codebase

I checked that DLL is registered into the registry in HK class root.

this my code :
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set("com.allow_dcom","true");
ini_set("com.autoregister_typelib","true");
ini_set("com.autoregister_verbose","true");

$doc = new COM("Aspose.Words.Document");
$builder = new COM("Aspose.Words.DocumentBuilder");
$builder->Document = $doc;
$builder->Write("Hello world!");
$doc->Save("C:\\Temp\\out.doc");
?>

I get this error :
Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `Aspose.Words.Document': ' in C:\Web\ops\Aspose.php:9 Stack trace: #0 C:\Web\ops\Aspose.php(9): com->com('Aspose.Words.Do...') #1 {main} thrown in C:\Web\ops\Aspose.php on line 9

I don't see what is the root cause of this error.

Please help me, thanks in advance for your help
Regards,
Maxime



Hi Maxime,


Thanks for your inquiry. It seems Aspose.Words DLL is not registered with COM Interop at your end. We have registered Aspose.Words DLL with COM Interop and we are unable to notice any issue with shared sample code. Please double check the Aspose.Words DLL registration, it will resolve the issue.

Best Regards,

Hi,


Thanks for your answer. I created an assembly (dll with framework v4) witch encapsulates Aspose word DLL (framework v2). I registered my DLL and it’s working.

Now, I want to use aspose barecode DLL but when I register assembly (framework 4) , I get an error : "Warning RA0000 : no types were registered"
Seems to be a problem link to this :
“<span style=“color: rgb(34, 34, 34); font-family: “Segoe UI”, Tahoma, Arial, Helvetica, sans-serif; font-size: 13.008px;”>Set <strong style=“margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13.008px; vertical-align: baseline; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: rgb(34, 34, 34); font-family: “Segoe UI”, Tahoma, Arial, Helvetica, sans-serif;”>ComVisible<span style=“color: rgb(34, 34, 34); font-family: “Segoe UI”, Tahoma, Arial, Helvetica, sans-serif; font-size: 13.008px;”> property to <strong style=“margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13.008px; vertical-align: baseline; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: rgb(34, 34, 34); font-family: “Segoe UI”, Tahoma, Arial, Helvetica, sans-serif;”>“true<span style=“color: rgb(34, 34, 34); font-family: “Segoe UI”, Tahoma, Arial, Helvetica, sans-serif; font-size: 13.008px;”>” in <strong style=“margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13.008px; vertical-align: baseline; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: rgb(34, 34, 34); font-family: “Segoe UI”, Tahoma, Arial, Helvetica, sans-serif;”>assemblyInfo.cs<span style=“color: rgb(34, 34, 34); font-family: “Segoe UI”, Tahoma, Arial, Helvetica, sans-serif; font-size: 13.008px;”> file.”
<span style=“color: rgb(34, 34, 34); font-family: “Segoe UI”, Tahoma, Arial, Helvetica, sans-serif; font-size: 13.008px;”>
<span style=“color: rgb(34, 34, 34); font-family: “Segoe UI”, Tahoma, Arial, Helvetica, sans-serif; font-size: 13.008px;”>Can you check, please?
<span style=“color: rgb(34, 34, 34); font-family: “Segoe UI”, Tahoma, Arial, Helvetica, sans-serif; font-size: 13.008px;”>Thanks
<span style=“color: rgb(34, 34, 34); font-family: “Segoe UI”, Tahoma, Arial, Helvetica, sans-serif; font-size: 13.008px;”>Maxime
<span style=“color: rgb(34, 34, 34); font-family: “Segoe UI”, Tahoma, Arial, Helvetica, sans-serif; font-size: 13.008px;”>
Hi Maxime,

Thank you for writing us back.

This is to update you that we are unable to reproduce the Aspose.BarCode issue. We are able to successfully register the DLL. Command and success message is given below for your reference. It is recommended to use Aspose.Barcode DLL from folder “.net2.0”. Please try it again at your end and update us with your feedback.


C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727> .\RegAsm.exe "C:\Users\evgen\Downloads\aspose.barcode_17.03.0_(dlls_only)\net2.0\Aspose.BarCode.dll" /codebase
Microsoft (R) .NET Framework Assembly Registration Utility 2.0.50727.8745
Copyright ( C) Microsoft Corporation 1998-2004. All rights reserved.
Types registered successfully
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>

Thanks for your answer.

If I register aspose DLL from V2.0 folder, I can’t call OLE component.
Using OleViewer tool, I see Aspose component registred but when I try to createInstance, I get the error message : CoGetClassObject failed.
the system cannot find the file specified.
Severity: SEVERITY_ERROR, facility: FACILITY_WIN32 ($80070002)

Thanks
Maxime

Hi Maxime,

We are working on the mentioned issue. Code 80070002 shows that file is not found that means your assembly is not in the client path. Please try installing the assembly into the GAC and share your feedback. We will update you further with our findings once we will complete the investigation.

Hi Maxime,

We are unable to reproduce the issue. While testing we are able to generate a test barcode image successfully. Sample code snippet is given below for your reference. The only extra thing we did was addition of following text into php.ini file:

[COM_DOT_NET]
extension=php_com_dotnet.dll

Please share your code snippet and environment details like OS, php version, installed .NET version etc. This will help us to further drill down the issue.

CODE:

<?php
$builder = new COM("Aspose.BarCode.BarCodeBuilder");
$builder->Save("C:\\temp\\testCom.png")
?>

Hi,


An the server machin, there was only Framework 4.0. I have installed Framework 3.5. And now it’s working.

Thanks for your support
Maxime

Hi,


I need to specify EncodeType, CodeLocation and ImageFormat. For that, I need to access to enum type and EncodeTypes class.
This types are not exposed in OLE/COM catalog.

So, I developed a wrapper DLL to call Save method and specifying these properties.

Maxime

Hi Maxime,

Thank you for update. It is good to know that issue has been resolved and things are now working at your end.