Proxygen Error with .NET 4.0 using MyCSharpDemoCalc

442 views
Skip to first unread message

sselvia

unread,
Jul 1, 2011, 2:59:47 PM7/1/11
to jni4net
I expanded the VS project and used VS 2010 to build the project
using .NET Framework 4 as the target framework. If I use 3.5
framework the proxygen works. I need to use a 4.0 framework assembly
from within my DLL.

Is there a configuration file that I need to set 4.0 compatibility?

D:\Downloads\jni4net\samples\myCSharpDemoCalc>generateproxies
..\..\lib\jni4net-LGPL-3.0.txt
..\..\lib\jni4net.j-0.8.4.0.jar
..\..\lib\jni4net.n-0.8.4.0.dll
..\..\lib\jni4net.n.w32.v20-0.8.4.0.dll
..\..\lib\jni4net.n.w32.v40-0.8.4.0.dll
..\..\lib\jni4net.n.w64.v20-0.8.4.0.dll
..\..\lib\jni4net.n.w64.v40-0.8.4.0.dll
7 file(s) copied.
jni4net.proxygen - Copyright (C) 2009 Pavel Savara - licensed under
GPLv3

System.BadImageFormatException: Could not load file or assembly
'file:///D:\Down
loads\jni4net\samples\myCSharpDemoCalc\work\MyCSharpDemoCalc.dll' or
one of its
dependencies. This assembly is built by a runtime newer than the
currently loade
d runtime and cannot be loaded.
File name: 'file:///D:\Downloads\jni4net\samples\myCSharpDemoCalc\work
\MyCSharpD
emoCalc.dll'
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String
codeBase,
Evidence assemblySecurity, Assembly locationHint, StackCrawlMark&
stackMark, Boo
lean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName
assemblyRef, Evidence
assemblySecurity, StackCrawlMark& stackMark, Boolean
forIntrospection)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at net.sf.jni4net.proxygen.model.Repository.LoadFile(String file)
at net.sf.jni4net.proxygen.model.Repository.LoadAssemblies()
at net.sf.jni4net.proxygen.model.Repository.Register()
at net.sf.jni4net.proxygen.Program.Work(String[] args)
at net.sf.jni4net.proxygen.Program.Main(String[] args)

=== Pre-bind state information ===
LOG: User = DATAMENTORS\sselvia
LOG: Where-ref bind. Location = D:\Downloads\jni4net\samples
\myCSharpDemoCalc\wo
rk\MyCSharpDemoCalc.dll
LOG: Appbase = file:///D:/Downloads/jni4net/bin/
LOG: Initial PrivatePath = NULL
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: No application configuration file found.
LOG: Using machine configuration file from C:\Windows\Microsoft.NET
\Framework64\
v2.0.50727\config\machine.config.
LOG: Attempting download of new URL file:///D:/Downloads/jni4net/samples/myCShar
pDemoCalc/work/MyCSharpDemoCalc.dll.
ERR: Failed to complete setup of assembly (hr = 0x8013101b). Probing
terminated.

Pavel Šavara

unread,
Jul 1, 2011, 3:11:08 PM7/1/11
to jni...@googlegroups.com
Create proxygen.exe.config with the correct full supportedRuntime
version and place it next to proxygen.exe

<configuration>
<startup>
<supportedRuntime version="v4.0.30319"/>
</startup>
</configuration>


make sure your CLR build version "30319" is what you put in the config file.

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

sselvia

unread,
Jul 1, 2011, 3:14:48 PM7/1/11
to jni4net
I added the proxygen.exe.config as I found in another post, still the
same results:

<configuration>
<startup>
<supportRuntime version="4.0"/>
</startup>
</configuration>

Why would the proxygen be using this config when I told it via the
config to support the 4.0 runtime:

LOG: Using machine configuration file from C:\Windows\Microsoft.NET
\Framework64\ v2.0.50727\config\machine.config

Pavel Šavara

unread,
Jul 1, 2011, 3:18:56 PM7/1/11
to jni...@googlegroups.com
try to add build version too. I think it falls back to it's natural
version if it could not find strong match. Or maybe you could add star
like this.
<supportRuntime version="4.0.*"/>

sselvia

unread,
Jul 1, 2011, 3:24:19 PM7/1/11
to jni4net
I did make the change:

<configuration>
<startup>
<supportRuntime version="v4.0.30319"/>
</startup>
</configuration>

I do have the following folder:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319

But I'm still getting the same error and for some reason it is not
using the v4... config. Is there a registry setting that needs to be
changed that your code is looking at?

LOG: User = DATAMENTORS\sselvia
LOG: Where-ref bind. Location = D:\Downloads\jni4net\samples
\myCSharpDemoCalc\wo
rk\MyCSharpDemoCalc.dll
LOG: Appbase = file:///D:/Downloads/jni4net/bin/
LOG: Initial PrivatePath = NULL
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: D:\Downloads\jni4net\bin
\proxygen.exe
.Config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET
\Framework64\
v2.0.50727\config\machine.config.
LOG: Attempting download of new URL file:///D:/Downloads/jni4net/samples/myCShar
pDemoCalc/work/MyCSharpDemoCalc.dll.
ERR: Failed to complete setup of assembly (hr = 0x8013101b). Probing
terminated.

> > terminated.- Hide quoted text -
>
> - Show quoted text -

sselvia

unread,
Jul 1, 2011, 3:32:51 PM7/1/11
to jni4net
I tried the 4.0.* and it still did not work, anymore ideas?
> > - Show quoted text -- Hide quoted text -

Scott Selvia

unread,
Jul 2, 2011, 11:37:34 PM7/2/11
to jni4net
I was hoping you had another option or idea on the issue? Is it an
issue with proxygen or just a registry setting?

Pavel Šavara

unread,
Jul 3, 2011, 5:14:11 AM7/3/11
to jni...@googlegroups.com
it works for me, so I have no further idea. Maybe your machine config
is configured wrongly.
Or you added some dll which is 32 bit and you are running 64 bit proxygen.
Actually, did you compiled the MyCSharpDemoCalc.dll to x86 or MSIL ?

Scott Selvia

unread,
Jul 5, 2011, 9:02:30 AM7/5/11
to jni...@googlegroups.com
Thank you for you help thus far, over the weekend I did a new install
of Vista x64 with Visual Studio 2010 and I get the same results that I
have at work. The only difference between the two is the OS, at work
I'm using Windows 7 x64. The MyCSharpDemoCalc VS project in both
cases had to be converted to a VS 2010 and in both cases there was no
problem. I tried to generate the proxies with code compiled in x32,
x64, and Any CPU and in all cases I get the same results when I have
the .NET Framework 4 selected.

If this was just on one machine I would agree that there would be a
problem with the machine config, however on two different machines
with a fresh install of VS 2010, I now suspsect there really is an
issue with the proxygen application.

Is there any other logging that I can turn on? I would be glad to test
any code fixes if you would supply them to give you more information
to the problem.

Thanks again for you time on this issue.

Scott Selvia

unread,
Jul 5, 2011, 5:04:48 PM7/5/11
to jni...@googlegroups.com
Pavel, I figured it out after downloading the source and debugging the
jni4net.proxygen.10 project. When I walked through the code I found
the exception was in the LoadAssemblies() method in the
Repository.Helpers.cs. I then re-compiled the project with the
jni4net.n.10 and jni4net.proxygen.10 project both targeting the .NET
Framework 4 and it worked. I then noticed the config file that was
generated when I ran the code. Once I put in the sku entry the
myCSharpDemoCalc worked when compiled to target the 4.0 framework. I
was also able to build my test project.

<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>

Pavel Šavara

unread,
Jul 6, 2011, 6:59:52 PM7/6/11
to jni...@googlegroups.com
Hi Scott,

I'm glad to hear it :-)

I realized that I could add CLR 4.0 as preferred runtime while
preserving ability to run proxygen on CLR 2.0.

<?xml version="1.0" encoding="utf-8" ?>


<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>

<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>

I added this proxygen.exe.config into binary distribution for next version.
Preview is here:
http://www.ane-kolin.cz/zamboch/jni4net-0.8.5.0-snapshot20110707-bin.zip

I also added new sample runtimeSelection, which could help people to
learn about their runtime versions.
Finally jni4net runtime and proxygen are now dumping runtime versions
when running setup in verbose mode.

Feedback appreciated, thanks!
Pavel

Scott Selvia

unread,
Jul 8, 2011, 9:01:03 PM7/8/11
to jni...@googlegroups.com
Just got back to it, I'll work with the new code. Thanks

Pavel Šavara

unread,
Jul 11, 2011, 5:09:15 PM7/11/11
to jni...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages