Jump to content

[SOLVED] Trying to call .NET function (have vb example)


tcarnes

Recommended Posts

I am trying to call a .NET module from a php5 script. My code is:

 

<?php
$response = new DOTNET("Paymentech", "Response");
$transaction = new DOTNET("Paymentech", "Transaction");
?>

 

My script dies on the first line with the error:

 

PHP Fatal error: Uncaught exception 'com_exception' with message 'Failed to instantiate .Net object [CreateInstance] [0x80070002] The system cannot find the file specified. ' in C:\Terry\OrdCen\PHPTEST.php:3 Stack trace: #0 C:\Terry\OrdCen\PHPTEST.php(3): dotnet->dotnet('Paymentech', 'Response') #1 {main} thrown in C:\Terry\OrdCen\PHPTEST.php on line 3

 

The sample VB code that came with the module states:

 

Dim response AS Paymentech.Response
Dim transaction As New Paymentech.Transaction(RequestType.CC_AUTHORIZE)

 

This is my first real foray into .NET with PHP. Hopefully someone can help me.

 

I believe my server is set up properly as the sample code given in the PHP manual does work:

 

<?php
  $stack = new DOTNET("mscorlib", "System.Collections.Stack");
  $stack->Push(".Net");
  $stack->Push("Hello ");
  echo $stack->Pop() . $stack->Pop();
?> 

 

And the sample compiled paymentech vb app also works. The sample vb app is in the same directory (on the server) as several paymentech dll's. Could that have something to do with this? How does my PHP script know where to get the information on the paymentech object?

 

Thank you for any help anyone can offer!

 

Terry

Link to comment
Share on other sites

Im not sure what your DOTNET object looks like (its not standard), but I should imagine a call would look more like.

[code=php:0]$response = new DOTNET("Paymentech.Response");

 

I'm not a .NET programmer but I used to do a bit of com stuff. the response object is in the Paymentech namespace. So unless your DOTNET __construct asks for the namespace and then object seperately, the above may work.

Link to comment
Share on other sites

How can the PHP manual at phpfreaks not be the official PHP manual?  :D

 

Perhaps I should go back and try doing it the old COM way.

 

Any idea how to translate the vb passing of a construction parameter into PHP using COM?

 

Dim transaction As New Paymentech.Transaction(RequestType.CC_AUTHORIZE)

 

Should this look like:

 

<?php
$transaction = new COM("Paymentech.Transaction(RequestType.CC_AUTHORIZE)");
?>

 

Thanks again for your help!  :)

Link to comment
Share on other sites

Turns out the PHP couldn't find the dll because it wasn't in the Global Assembly Cache, and I couldn't use gacutil to put it there because it didn't have a strong name.

 

So I got around that by placing the dll in the PHP directory on the web server.

 

My next problem is trying to pass parameters using DOTNET, but that is a subject for another post. The problem of not being able to locate the file is solved.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.