Proxygen Exception: BadImageFormatException

679 views
Skip to first unread message

Rory Gilfillan

unread,
Aug 11, 2011, 3:40:23 AM8/11/11
to jni4net
Hi,

I'm trying to load a dll with proxygen and I get the following
exception:
System.BadImageFormatException: Could not load file or assembly
'file:///c:\User
s\roryg\Documents\NetBeansProjects\Oracle PCI Churner\jni4net\work
\idrskrn_net14
.dll' or one of its dependencies. An attempt was made to load a
program with an
incorrect format.

Proxygen works with the MyCSharpDemoCalc.dll sample.

The CorFlags for the dll are:
Version : v2.0.50727
CLR Header: 2.5
PE : PE32
CorFlags : 24
ILONLY : 0
32BIT : 0
Signed : 1

Which is practically the same as MyCSharpDemoCalc.dll.

I also copied all dll's that where in idrskrn_net14
.dll directory in case any of them were dependents. I don't know what
else to do to get this to work.

Any help would be most appreciated.

Pavel Šavara

unread,
Aug 15, 2011, 1:45:46 AM8/15/11
to jni...@googlegroups.com
Hi Rory,

most probably you are running 64bit JVM and the DLL is not pure IL.
Try to find 64bit version of the driver. Or use 32bit JVM.

Cheers
Pavel

> --
> 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/
>

Rory Gilfillan

unread,
Aug 15, 2011, 5:37:17 AM8/15/11
to jni4net
Thanks Pavel,

I tried to run the proxygen with my JVM as:
java version "1.6.0_25"
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.0-b11, mixed mode)
... 64-Bit

and with :
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)
... 32-bit

But the problem persists.

Pavel Šavara

unread,
Aug 15, 2011, 5:42:12 AM8/15/11
to jni...@googlegroups.com
Sorry, I should say you are running it with 64bit CLR. The proxygen is
CLR application.
You can do it by CorFlags.exe on proxygen.exe

Rory Gilfillan

unread,
Aug 15, 2011, 6:24:55 AM8/15/11
to jni4net
I ran this "corflags bin\proxygen.exe /32BIT+ /force"

and ... it works!!

Thanks a lot :)

Rory Gilfillan

unread,
Aug 15, 2011, 8:20:34 AM8/15/11
to jni4net
Utility still doesn't help though.

Can't translate C#:
aLicenseDRS.ExtensionsToLoad[iExtensionId] =
Convert.Tobooleanean(sr.readLine());

to Java because there is only
aLicenseDRS.getExtensionsToLoad() which returns a boolean[] but there
is no setExtensionsToLoad.

Rory Gilfillan

unread,
Aug 15, 2011, 8:55:00 AM8/15/11
to jni4net
Sorry the array is passed as a pointer so changing it will change the
original.

Rory Gilfillan

unread,
Aug 15, 2011, 9:12:04 AM8/15/11
to jni4net
Static constants don't seem to come through on Java object

C#:
DRSExtensions.AvailableExtensionsCount

No static methods or constant on DRSExtensions in Java

shreyas raj

unread,
Oct 10, 2013, 8:11:06 AM10/10/13
to jni...@googlegroups.com
Hi, 
can you please help me..
I am new to the proxygen.exe use.
What i have is a helloWorld.dll (a c# dll) and now i want to create proxies of it. to do that i tried this command:
                   proxygen.exe helloWorld.dll -wd targetFolderName                         
but it didnt worked.
now again i tried running it with Corflags like this:: went to the Corflags directory and then executed this
                   Corflags proxygenFloderPath/proxygen.exe proxygen.xml



     proxygen.xml file is:

<?xml version="1.0" encoding="utf-8" ?> 
<jni4net-proxygen xmlns="http:\\jni4net.sf.net\0.8.4.0\toolConfig.xsd"> 
 <TargetDirJvm>helloWorld</TargetDirJvm>
 <TargetDirClr>helloWorld</TargetDirClr>
 <ClassPath Path="C:\Users\sg0217833\Desktop\dllTest\ex\proxygen\HelloWorld.dll"/> 
  <AssemblyReference Assembly="Interop.TDAPIOLELib.dll"/>
  <Verbose>true</Verbose>
 <ClrType TypeName="System.Reflection"/>
 <ClrType TypeName="System.Runtime.CompilerServices"/>
 <ClrType TypeName="System.Runtime.InteropServices"/>
 <ClrType TypeName="System.Linq"/>
 <ClrType TypeName="System.Text"/>
 <ClrType TypeName="System.Diagnostics"/>
 <ClrType TypeName="System.Linq.Expressions"/>
 <ClrType TypeName="System.Text.RegularExpressions"/>
 <ClrType TypeName="System.Collections"/>
</jni4net-proxygen>

i dont have any idea about the proxygen.xml file,  Please give a look to it,
and offcource it didnt work

and from:
where we ill write the c# dll file path. in class path?? i have written like this.
<ClassPath Path="C:\Users\sg0217833\Desktop\dllTest\ex\proxygen\HelloWorld.dll"/> 

rxp1...@gmail.com

unread,
Jul 7, 2017, 2:40:46 AM7/7/17
to jni4net
Hi. I am attempting to generate proxies from unmanaged (no manifest) and 32bit MilTk.dll file on Windows 7 64bit host. Current status is:

* Installed 
VisualStudio2017 IDE (32 and 64bit compatible), 
Eclipse IDE ver Oxygen4.7.0 for 32bit JavaEE, 
JDK 1.8.0_131 32bit with entry in Sys/EnvVars/Path, 
.Net4.0 (32bit and 64bit compatible) 
jni4net 0.8.8.0 (bin and src bundles).  

* In VS2017 cmd window: Set CorFlags to 32BITREQ+ /Force.

* Used dependency walker tool to list dependencies for this dll to work with proxygen.exe, as shown in attached .csv file.  Details are shown in ScrShot_DepWalker.jpg file.

* In DOS cmd window: Used SysWOW64/regsvr32.exe to register this .DLL and it's dependencies.  Some threw error saying loaded but DllRegisterServer not being found as shown in ScrShot_DllRegSrvNotFound.jpg

When I execute the proxygen.exe command with -wd option, I am getting error shown in attached ScrShot_BIFExc.jpg file.  It could be because I have to declare all dependencies listed in above .csv file while running proxygen.exe either using -dp option or using a config.xml file. 

Do you have a working config.xml file that I could modify for running proxygen.exe (because there are about ~200 dependencies and associated classpath to mention while running proxygen).  Also, do you have a comment/suggestion?  

Thanks.
ScrShot_BIFExc.bmp
Depends_MilTk_out.csv
ScrShot_DepWalker.jpg
ScrShot_DllRegSrvNotFoundError.jpg

Pavel Šavara

unread,
Jul 7, 2017, 2:46:56 AM7/7/17
to jni4net

Jni4net is not designed for unmanaged DLLs. For that you could use pure JNI, you don't need complexity of CLR in the picture. Try SWIG project.


--
---
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.
Reply all
Reply to author
Forward
0 new messages