Using .Net assemblies with PHP

Using .Net assemblies with PHP

am 17.05.2011 19:42:08 von Trevor

Just in case anyone else needs to do this, I just spent a frustrating
week figuring out how to make an assembly I created with
PowerBuilder.Net work with PHP. The dotnet class in PHP doesn't work
very well, and has apparently been abandoned. I ended up using this
instead: http://universalccw.sourceforge.net/

It's finally working great, and I am very happy. (The library also, of
course, works with the regular Microsoft assemblies.)

- Trevor

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Using .Net assemblies with PHP

am 17.05.2011 21:44:50 von Richard Quadling

On 17 May 2011 18:42, Trevor wrote:
> Just in case anyone else needs to do this, I just spent a frustrating week
> figuring out how to make an assembly I created with PowerBuilder.Net work
> with PHP. The dotnet class in PHP doesn't work very well, and has apparently
> been abandoned. I ended up using this instead:
> http://universalccw.sourceforge.net/
>
> It's finally working great, and I am very happy. (The library also, of
> course, works with the regular Microsoft assemblies.)
>
> - Trevor

Hello Trevor.


It would be really useful to know what isn't working? I don't use any
..NET stuff, but I do use COM to talk to MS Word and Excel as well as
Crystal Reports (I generate reports into these different document
types all day - well, a process does).

From memory, there is an issue if the .NET assembly has not
provided/exposed a COM layer/interface - I don't know the correct
terms, but I think this is the issue.


Regards,

Richard.

--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Using .Net assemblies with PHP

am 17.05.2011 22:26:44 von Trevor

On 5/17/2011 1:44 PM, Richard Quadling wrote:

> It would be really useful to know what isn't working? I don't use any
> .NET stuff, but I do use COM to talk to MS Word and Excel as well as
> Crystal Reports (I generate reports into these different document
> types all day - well, a process does).
>
> From memory, there is an issue if the .NET assembly has not
> provided/exposed a COM layer/interface - I don't know the correct
> terms, but I think this is the issue.

In researching to make this work, I found several bug reports filed at
php.net where things within mscorlib didn't even work (whereas other
things within the same assembly - such as the example given on the
dotnet man page - work fine), which I was able to replicate. That's what
led to my loss of confidence in the dotnet class, and to looking for
another way of doing it. (That, and a web page I found where one of the
dotnet class developers said he had completely given up on it.)

After getting my custom assembly working with the UniversalCCW library
(which provides a COM wrapper around any assembly), I tried it again
with the dotnet class. I get pretty inconsistent results - sometimes it
will return immediately, and sometimes it will sit for several minutes
before returning - if it returns at all before timing out. When I tried
the examples in the bug reports I referred to above, I got some generic
error messages back (the same ones that are in the bug reports).

- Trevor


--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Using .Net assemblies with PHP

am 17.05.2011 23:59:35 von Pierre Joye

hi,

Interesting but it is somehow poor in term of performance (not very
important in most cases).

As a somehow cleaner alternative (COM is such a pain), I use C++/CLI.
For example I wrote (early stage but works) an extension for the MS
Chart module, you can see it here
https://github.com/pierrejoye/php_mschart

Cheers,

On Tue, May 17, 2011 at 7:42 PM, Trevor wrote:
> Just in case anyone else needs to do this, I just spent a frustrating week
> figuring out how to make an assembly I created with PowerBuilder.Net work
> with PHP. The dotnet class in PHP doesn't work very well, and has apparently
> been abandoned. I ended up using this instead:
> http://universalccw.sourceforge.net/
>
> It's finally working great, and I am very happy. (The library also, of
> course, works with the regular Microsoft assemblies.)
>
> - Trevor
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



--
Pierre

@pierrejoye | http://blog.thepimp.net | http://www.libgd.org

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Using .Net assemblies with PHP

am 18.05.2011 00:34:57 von Trevor

In my testing, I can load a browser page with 1,000
encryption/decryption operations in less than 2 seconds. Since I really
only need to do at most a couple at a time (which comes back instantly),
I can't really complain about the performance. And it certainly beats my
testing of dotnet (when it actually works).

I do see the advantage of how you did it, but I was looking for a more
generic solution that could be used for multiple assemblies, rather than
having to write a custom interface for each one. And, just to be clear,
I did not write the universalccw library. I actually stumbled upon it
when I was trying to figure out how to make the dotnet stuff work.
Apparently the author had similar frustrations and decided to do his own.

Anyway, I just thought I'd pass the info on in case it helps someone
else avoid the frustration that I've been going through for the last few
days. :)

- Trevor

On 5/17/2011 3:59 PM, Pierre Joye wrote:
> hi,
>
> Interesting but it is somehow poor in term of performance (not very
> important in most cases).
>
> As a somehow cleaner alternative (COM is such a pain), I use C++/CLI.
> For example I wrote (early stage but works) an extension for the MS
> Chart module, you can see it here
> https://github.com/pierrejoye/php_mschart
>
> Cheers,
>
> On Tue, May 17, 2011 at 7:42 PM, Trevor wrote:
>> Just in case anyone else needs to do this, I just spent a frustrating week
>> figuring out how to make an assembly I created with PowerBuilder.Net work
>> with PHP. The dotnet class in PHP doesn't work very well, and has apparently
>> been abandoned. I ended up using this instead:
>> http://universalccw.sourceforge.net/
>>
>> It's finally working great, and I am very happy. (The library also, of
>> course, works with the regular Microsoft assemblies.)
>>
>> - Trevor
>>
>> --
>> PHP Windows Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
>


--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Using .Net assemblies with PHP

am 18.05.2011 10:00:59 von Pierre Joye

On Wed, May 18, 2011 at 12:34 AM, Trevor wrote:
> In my testing, I can load a browser page with 1,000 encryption/decryption
> operations in less than 2 seconds. Since I really only need to do at most a
> couple at a time (which comes back instantly), I can't really complain about
> the performance. And it certainly beats my testing of dotnet (when it
> actually works).

Btw, which encryption algorithms were you looking for? Using the
native PHP versions would be even faster and easier :)


Cheers,
--
Pierre

@pierrejoye | http://blog.thepimp.net | http://www.libgd.org

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Using .Net assemblies with PHP

am 18.05.2011 17:42:19 von Trevor

On 5/18/2011 2:00 AM, Pierre Joye wrote:
> On Wed, May 18, 2011 at 12:34 AM, Trevor wrote:
>> In my testing, I can load a browser page with 1,000 encryption/decryption
>> operations in less than 2 seconds. Since I really only need to do at most a
>> couple at a time (which comes back instantly), I can't really complain about
>> the performance. And it certainly beats my testing of dotnet (when it
>> actually works).
>
> Btw, which encryption algorithms were you looking for? Using the
> native PHP versions would be even faster and easier :)

True. Unfortunately, the native ones don't meet my needs. I needed
something that was compatible with existing encrypted data that we use
with a Windows desktop application, so I ended up encapsulating the same
encryption code from the Windows app in the assembly.

- Trevor


--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Using .Net assemblies with PHP

am 18.05.2011 18:39:06 von Trevor

On 5/18/2011 9:42 AM, Trevor wrote:

>> Btw, which encryption algorithms were you looking for? Using the
>> native PHP versions would be even faster and easier :)
>
> True. Unfortunately, the native ones don't meet my needs. I needed
> something that was compatible with existing encrypted data that we use
> with a Windows desktop application, so I ended up encapsulating the same
> encryption code from the Windows app in the assembly.

The nice thing about this little adventure is that I now know how to
encapsulate any of the business logic from our desktop application
(PowerBuilder makes it very easy) to use on our website with just a few
lines of PHP code. :)

- Trevor

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Using .Net assemblies with PHP

am 19.05.2011 01:51:07 von Richard Quadling

On 18 May 2011 17:39, Trevor wrote:
> On 5/18/2011 9:42 AM, Trevor wrote:
>
>>> Btw, which encryption algorithms were you looking for? Using the
>>> native PHP versions would be even faster and easier :)
>>
>> True. Unfortunately, the native ones don't meet my needs. I needed
>> something that was compatible with existing encrypted data that we use
>> with a Windows desktop application, so I ended up encapsulating the same
>> encryption code from the Windows app in the assembly.
>
> The nice thing about this little adventure is that I now know how to
> encapsulate any of the business logic from our desktop application
> (PowerBuilder makes it very easy) to use on our website with just a few
> lines of PHP code. :)
>
> - Trevor

Interesting. As I said earlier, I use PHP+COM to talk to Crystal
Reports. One of the issues I have is that the COM interface is no
longer part of the current version of Crystal. The last one was CR XI
Release 2. Newer versions are only supporting .NET and Java.

If UniversalCCW can provide me with access to the latest .NET
libraries, then that seems like a really useful addition.

--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Using .Net assemblies with PHP

am 21.05.2011 00:48:05 von Trevor

On 5/18/2011 5:51 PM, Richard Quadling wrote:

> Interesting. As I said earlier, I use PHP+COM to talk to Crystal
> Reports. One of the issues I have is that the COM interface is no
> longer part of the current version of Crystal. The last one was CR XI
> Release 2. Newer versions are only supporting .NET and Java.
>
> If UniversalCCW can provide me with access to the latest .NET
> libraries, then that seems like a really useful addition.
>

It sounds like you'll want to give it a try. Once I had the library
installed, this is all it took to encrypt a CC number:

$COM = new COM("Universal_CCW.Universal_CCW_Factory");
$asmb_full_name = "assemblyname, Version=1.0.0.2, Culture=Neutral,
PublicKeyToken=d3356e74613fd6c5";
$crypto = $COM->New_Object("test", $asmb_full_name, "namespace.class");
$cc_enc = $crypto->Call_Method("ofEncryptString", $cardNumber);

- Trevor

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Using .Net assemblies with PHP

am 26.05.2011 22:27:50 von Trevor

On 5/17/2011 11:42 AM, Trevor wrote:
> Just in case anyone else needs to do this, I just spent a frustrating
> week figuring out how to make an assembly I created with
> PowerBuilder.Net work with PHP. The dotnet class in PHP doesn't work
> very well, and has apparently been abandoned. I ended up using this
> instead: http://universalccw.sourceforge.net/
>
> It's finally working great, and I am very happy. (The library also, of
> course, works with the regular Microsoft assemblies.)

OK, I've actually run into a problem. What I described above was working
fine on our test server, running Windows Server 2003 R2. I'm now trying
to get it to work on our production server, running Windows Server 2008
R2 64 bit. I'm using Apache (from Xampp) as the web server.

After a lot of trial and error, I got the UniversalCCW part working, but
I'm having a hard time with the actual assembly. I get the following error:

1 Fatal error: Uncaught exception 'com_exception' with message 'Source:
mscorlib Description: Could not load file or assembly 'uucrypto,
Version=1.0.0.2, Culture=neutral, PublicKeyToken=d3356e74613fd6c5' or
one of its dependencies. The system cannot find the file specified.' in
test.php:21 Stack trace: #0 test.php(21): com->New_Object('test',
'uucrypto, Versi...', 'uu.uucrypto') #1 {main} thrown in test.php on line 21

I tried using the assembly from the commandline, with a little program I
made using C#, and it worked as long as the assembly was in the same folder.

So what do I need to do in order to make PHP find it? I've tried putting
it in the PHP folder, as well as another folder in the system path
(which I verified with phpinfo()).

Thanks,
Trevor

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Using .Net assemblies with PHP

am 26.05.2011 22:55:00 von Trevor

On 5/26/2011 2:27 PM, Trevor wrote:
> OK, I've actually run into a problem. What I described above was working
> fine on our test server, running Windows Server 2003 R2. I'm now trying
> to get it to work on our production server, running Windows Server 2008
> R2 64 bit. I'm using Apache (from Xampp) as the web server.

I just tried using the DOTNET function just to see what would happen on
this server, and I got this error message:

1 Fatal error: Class 'DOTNET' not found in test.php on line 16

Is this perhaps another symptom of the same problem? Is there something
I need to turn on to make this all work?

- Trevor

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Using .Net assemblies with PHP

am 27.05.2011 00:46:59 von Trevor

On 5/26/2011 2:27 PM, Trevor wrote:
> After a lot of trial and error, I got the UniversalCCW part working, but
> I'm having a hard time with the actual assembly. I get the following error:
>
> 1 Fatal error: Uncaught exception 'com_exception' with message 'Source:
> mscorlib Description: Could not load file or assembly 'uucrypto,
> Version=1.0.0.2, Culture=neutral, PublicKeyToken=d3356e74613fd6c5' or
> one of its dependencies. The system cannot find the file specified.' in
> test.php:21 Stack trace: #0 test.php(21): com->New_Object('test',
> 'uucrypto, Versi...', 'uu.uucrypto') #1 {main} thrown in test.php on
> line 21

Funny thing is, this works fine from the commandline. I'm logged in as
administrator, which is the same user that the Apache service runs as,
so I'm not sure what the problem is.

- Trevor

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Using .Net assemblies with PHP

am 27.05.2011 00:52:07 von Trevor

On 5/26/2011 4:46 PM, Trevor wrote:

> Funny thing is, this works fine from the commandline. I'm logged in as
> administrator, which is the same user that the Apache service runs as,
> so I'm not sure what the problem is.

Huh. Restarting Apache fixed it. Now I have no idea which thing it was
that I did that made it work.

- Trevor

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php