proxygen with dll dependencies issues

943 views
Skip to first unread message

Steven Kauffmann

unread,
May 13, 2015, 5:33:35 AM5/13/15
to jni...@googlegroups.com
Hi all,

We have a legacy application written in .net that provides a public API. A small dll is written using this public API. With the proxygen tool we are now trying to generate the proxies so we can afterwards use this dll in java. But because our own dll depends on a lot of dll's of the legacy application, we are encountering some problems when generating the proxy.


proxygen.exe application.dll -wd work -dp C:\test\firstlegacylib.dll

System.IO.FileNotFoundException: Could not load file or assembly ' firstlegacylib.dll' or one of its dependencies. The specified module could not be found. File name: ' firstlegacylib.dll'

When adding all the dependencies of the firstlegacylib.dll we get the following error:

System.BadImageFormatException: Could not load file or assembly 'file:///C:\test\depFirstlegacylib.dll' or one of its dependencies. The module was expected to contain
 an assembly manifest. File name: 'file:///C:\test\depFirstlegacylib.dll'

So it seems something is wrong with one of the dependencies. Question is do we have to specify all dependencies of all libraries that we are using? Or only putting the direct dependencies of our code? How can we find out which dependency is wrong?

Best regards,
Steven


Pavel Šavara

unread,
May 13, 2015, 5:39:52 AM5/13/15
to jni...@googlegroups.com
Most likely one of the dependencies is native 64 bit or native 32 bits. Search this email group to find out how to switch proxygen to run as 64bit with "corflags".
Also, you may need to use proxygen config xml instead of this simplified proxygen commandline, see samples in jni4net distribution zip.

--
--
You received this message because you are subscribed to jni...@googlegroups.com
http://groups.google.com/group/jni4net?hl=en-GB?hl=en-GB
http://jni4net.sf.net/

---
You received this message because you are subscribed to the Google Groups "jni4net" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jni4net+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Steven Kauffmann

unread,
May 13, 2015, 6:09:12 AM5/13/15
to jni...@googlegroups.com
Hi Pavel,

Thanks a lot for your fast feedback.

I think my proxygen is already configured as 64bit see output corflags:
Version   : v2.0.50727
CLR Header: 2.5
PE        : PE32
CorFlags  : 0x9
ILONLY    : 1
32BITREQ  : 0
32BITPREF : 0
Signed    : 1

The libraries of the dependency tool are also 64 bit:
Version   : v4.0.30319
CLR Header: 2.5
PE        : PE32+
CorFlags  : 0x18
ILONLY    : 0
32BITREQ  : 0
32BITPREF : 0
Signed    : 1

My default java is also configured as 64 bit:
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

Does the output seems to be ok for a 64bit configuration or do we still overlook something?

Steven

Pavel Šavara

unread,
May 13, 2015, 6:37:15 AM5/13/15
to jni...@googlegroups.com
it could be other way around, that your libraries are 32 bit and therefore proxygen should be 32bit.
But I could see that the your lib is .NET 4.0, so you have to run proxygen in .NET 4.0 runtime in order to allow him to load the lib.

Steven Kauffmann

unread,
May 13, 2015, 7:34:46 AM5/13/15
to jni...@googlegroups.com
Hi Pavel,

I tried it with configuring the proxygen as 32 bit but then I get the incorrect format error. So it seems like we have to configure it as 64 bit.

In order to run proxygen in .NET 4.0 runtime I have modified the proxygen.exe.config file and replaced it content with this:

 <?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0.30319"/>
  </startup>
</configuration>

I don't know if this is the correct way but when now running proxygen I still get the same error as before.

Steven

Pavel Šavara

unread,
May 13, 2015, 8:17:01 AM5/13/15
to jni...@googlegroups.com
yep, the config seems correct.
Try to turn on Fusion logging for .NET

Steven Kauffmann

unread,
May 13, 2015, 8:52:10 AM5/13/15
to jni...@googlegroups.com
This is the assembly binding log:

*** Assembly Binder Log Entry  (13/05/2015 @ 14:36:55) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable  C:\test\jni4net\lib\bin\proxygen.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = jni4net.n-0.8.8.0, Version=0.8.8.0, Culture=neutral, PublicKeyToken=134a23405600bab4
 (Fully-specified)
LOG: Appbase = file:///C:/test/jni4net/lib/bin/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = proxygen.exe
Calling assembly : proxygen, Version=0.8.8.0, Culture=neutral, PublicKeyToken=134a23405600bab4.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\test\jni4net\lib\bin\proxygen.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: jni4net.n-0.8.8.0, Version=0.8.8.0, Culture=neutral, PublicKeyToken=134a23405600bab4
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/test/jni4net/lib/bin/jni4net.n-0.8.8.0.DLL.
LOG: Attempting download of new URL file:///C:/test/jni4net/lib/bin/jni4net.n-0.8.8.0/jni4net.n-0.8.8.0.DLL.
LOG: Attempting download of new URL file:///C:/test/jni4net/lib/bin/jni4net.n-0.8.8.0.EXE.
LOG: Attempting download of new URL file:///C:/test/jni4net/lib/bin/jni4net.n-0.8.8.0/jni4net.n-0.8.8.0.EXE.
LOG: All probing URLs attempted and failed.

Never looked into these kind of log files but the path C:/test/jni4net/lib/bin exists but the dll is not in there (only proxygen.exe and proxygen.exe.config ) I copied the dll into the bin but this gave me the same assembly log. Any idea what can be wrong?

Pavel Šavara

unread,
May 13, 2015, 9:22:19 AM5/13/15
to jni...@googlegroups.com
put jni4net.n-0.8.8.0.DLL and rest of the libraries into same directory as proxygen exe

Steven Kauffmann

unread,
May 13, 2015, 10:41:27 AM5/13/15
to jni...@googlegroups.com
I was a little bit too fast with posting the assembly binding log.
When I run proxygen.exe application.dll -wd work
I do get the previous log file, however the proxygen command returns without no error (strange that I get the log file but anyway the command does not return an error).

If I add the -dp flag pointing to the dependency libraries and thus getting the BadImageFormatException I get this log file:

*** Assembly Binder Log Entry  (13/05/2015 @ 16:19:24) ***

The operation failed.
Bind result: hr = 0x80131018. No description available.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable  C:\test\jni4net\lib\bin\proxygen.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: Where-ref bind. Location = C:\test\DbCompressu.dll
LOG: Appbase = file:///C:/test/jni4net/lib/bin/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = proxygen.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\test\jni4net\lib\bin\proxygen.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Attempting download of new URL file:///C:/test/DbCompressu.dll.
LOG: Assembly download was successful. Attempting setup of file: C:\test\DbCompressu.dll
LOG: Entering run-from-source setup phase.
ERR: Error extracting manifest import from file (hr = 0x80131018).
ERR: Run-from-source setup phase failed with hr = 0x80131018.
ERR: Failed to complete setup of assembly (hr = 0x80131018). Probing terminated.

Pavel Šavara

unread,
May 13, 2015, 10:52:38 AM5/13/15
to jni...@googlegroups.com

Steven Kauffmann

unread,
May 19, 2015, 10:48:50 AM5/19/15
to jni...@googlegroups.com
Hi Pavel,

Thanks for the links but after some time spending on debugging, the real issue seems to be that some dll's dependencies were still missing. Some dll's have nested dependencies and with some help with dependency walker I could identify the missing ones.

But I still have 2 questions:
* When running the proxygen tool with the -dp flag (pointing to the dll's) I still get the error messages. When I run the proxygen tool without dp flag everything seems to be working. Is this -dp flag optional or is something still going wrong on our system?
* Now we are putting all the dll's (together with the dependencies) in the root folder of our java project. Is it possible to put all the dependencies it in a separate folder in order to have a clean root project folder?

Pavel Šavara

unread,
May 19, 2015, 10:52:12 AM5/19/15
to jni...@googlegroups.com
-dp is just shorthand notation for very simple DLLs. Not your case, please use full fonfiguration via config xml files. See samples.
- JVM has to be able to load them as native DLLs. Perhaps PATH environment variable may help ?
Reply all
Reply to author
Forward
0 new messages