Deploying with pure dll

Discussion about the open-source Phalanger [?] project.

Deploying with pure dll

Postby strfrank » June 22nd, 2012, 11:08 am

Hi,
I have a pure phalanger dll that contains classes called from a c# application.
I need to make all the application portable, in order to be able to run without installing Phalanger or anything else but I cannot deploy it...
I put on the same directory the c# exe, the pure dll and the needed phalanger files: PhpNetCore.dll, PhpNetClassLibrary.dll and all the needed extensions .mng and .dll.
There is also the .exe.config that contains the phpNet section needed to retrieve the extensions.

If I leave the .exe.config I receive an error that says the phpNet configuration section in not recognized, by leaving the .exe.config file it tells me that it cannot find the dll extensions...
The project works correctly on the development machine that has Phalanger installed.
The prerequisites on the target machine are installed (VC++ redist and .net framework), there is also a version of vs2010 express.

Many thanks
strfrank
 
Posts: 20
Joined: May 30th, 2012, 5:05 pm

Re: Deploying with pure dll

Postby Jakub Misek » June 22nd, 2012, 12:25 pm

Hi,
Phalanger installer puts additional configuration into
Code: Select all
"%WinDir%\Microsoft.NET\Framework\v4.0.30319\Config\machine.config"


The template of the machine configuration can be found at https://github.com/DEVSENSE/Phalanger/b ... ine.config.

You can include this configuration into your app.config (especially <paths> section). All the paths can be relative to the app.config file.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: Deploying with pure dll

Postby strfrank » June 25th, 2012, 9:29 am

Hi,
I tried placing the missing configuration parameters inside my app.config, but when I try to change the Extensions directory I get an error, I tried this:

Code: Select all
<set name="ExtNatives" value="php\Extensions" />


where php\Extensions is an existing subdirectory of the exe path where I put the extensions dlls.

I receive this error:

{" at PHP.ExtManager.DynamicModule..ctor(String _path, String _fileName, Boolean _earlyInit)\r\n at PHP.ExtManager.DynamicModule.LoadDynamicModule(ExtensionLibraryDescriptor descriptor)\r\n at PHP.ExtManager.RemoteDispatcher.LoadExtension(ExtensionLibraryDescriptor descriptor)"}

If I set ExtNatives to the full path of phalanger installation directory it works correctly.

UPDATE: if I copy the whole content of the Extensions folder to php\Extensions it works, at first I copied only the dlls I use in the project.


Thanks.
strfrank
 
Posts: 20
Joined: May 30th, 2012, 5:05 pm

Re: Deploying with pure dll

Postby Jakub Misek » June 25th, 2012, 10:11 am

It is possible, extension you are using has another dependency. Surely you can remove php_*.dll you are not using.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: Deploying with pure dll

Postby strfrank » June 25th, 2012, 10:31 am

Many thanks, on my developer machine it was what you suggested, missing dll.
I then tried uninstalling phalanger and now it doesn't work anymore...

First error is: could not load php_bcmath.mng ...

php_bcmath is specified in <classLibrary> section in app.config.
If I place php_bcmath.mng.dll in the same path of the exe (just to try, I would like to place it in another directory) I get this error:

Code: Select all
Value cannot be null.
Parameter name: descriptor
Stack trace:
   at PHP.Core.LocalConfiguration.GetLibraryConfig(PhpLibraryDescriptor descriptor)
   at PHP.Library.LibraryConfiguration.GetLocal(ScriptContext context)
   at PHP.Library.PhpVariables.Serialize(DTypeDesc caller, Object variable)


What can I do?
Is there a guide where I can look on how to deploy an application without installing phalanger?
thanks again
strfrank
 
Posts: 20
Joined: May 30th, 2012, 5:05 pm

Re: Deploying with pure dll

Postby Jakub Misek » June 25th, 2012, 10:43 am

.mng.dll has to be placed together with phpnetcore.dll (it is its dependency). You can try to put it in another directory, by placing following into <classLibrary>
<add url='bin/php_bcmath.mng.dll' />

Do you have more from the stack trace?
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: Deploying with pure dll

Postby strfrank » June 25th, 2012, 1:54 pm

Unfortunately I had no luck with <add url="">, the stack trace reports only those lines, the other ones are application specific.

I'm now trying with a simple app that uses ScriptContext.Call method and when I try to call for example bcadd it doesn't find bc_math.mng unless I put it in the exe dir, and if I try to call base64_decode it says 'call to undefined function base64_decode'.
This is app.config:

Code: Select all
<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="phpNet" type="PHP.Core.ConfigurationSectionHandler, PhpNetCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0a8e8c4c76728c71" />
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
  <phpNet>
    <paths>
      <!--<set name="DynamicWrappers" value="php\Dynamic" />-->
      <!--<set name="Libraries" value="php\Bin" />-->
      <set name="ExtWrappers" value="Wrappers" />
      <!--<set name="ExtTypeDefs" value="php\TypeDefs" />-->
      <!--<set name="ExtNatives" value="Extensions" />-->
    </paths>
    <classLibrary>
      <add assembly="php_bcmath.mng, Version=3.0.0.0, Culture=neutral, PublicKeyToken=4ef6ed87c53048a3" section="bcmath" />
    </classLibrary>
  </phpNet>
</configuration>


If I install phalanger it works correctly, looks like the paths section is being completely ignored (in the example I gave there are some commented parts).
Thanks.
strfrank
 
Posts: 20
Joined: May 30th, 2012, 5:05 pm

Re: Deploying with pure dll

Postby Jakub Misek » June 25th, 2012, 2:09 pm

You didn't merge your config with the base one (https://github.com/DEVSENSE/Phalanger/b ... ine.config). Especially the following is important, since it contains all the basic functionality:
Code: Select all
<add assembly="PhpNetClassLibrary, Version=3.0.0.0, Culture=neutral, PublicKeyToken=4af37afe3cde05fb" section="bcl" />
      <add assembly="PhpNetXmlDom, Version=3.0.0.0, Culture=neutral, PublicKeyToken=2771987119c16a03" section="dom"/>
     
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: Deploying with pure dll

Postby strfrank » June 25th, 2012, 3:27 pm

Thank you, I added the <add> elements you suggested and it works, I probably forgot them because I made a lot of tests...
Now the problem is that it works but only if I place all the needed files in the same directory, what should I do to use the directories specified in the <paths> section?

Thanks again
strfrank
 
Posts: 20
Joined: May 30th, 2012, 5:05 pm

Re: Deploying with pure dll

Postby Jakub Misek » June 25th, 2012, 3:42 pm

You need only ExtNatives and DynamicWrappers paths. '.mng.dll' and other .NET assemblies are loaded as standard .NET assemblies thru current .NET AppDomain. Try specifying their paths using the url='' attribute as suggested before.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Next

Return to Phalanger project

Who is online

Users browsing this forum: No registered users and 25 guests

cron

User Control Panel

Login

Who is online

In total there are 25 users online :: 0 registered, 0 hidden and 25 guests (based on users active over the past 5 minutes)
Most users ever online was 297 on March 29th, 2024, 7:06 am

Users browsing this forum: No registered users and 25 guests