Using JNI4Net to call C# dll

0

I am working on integrating a third party DLL with our software(in Java platform). Followed the steps mentioned in https://www.youtube.com/watch?v=8OoSK_RWUe4 and encountered an error during running proxygen.exe. I tried searching for resolutions for 2 days and couldn't find any useful. (http://www.codinghouse.org/calling-net-dll-from-java/#comment-395512) (https://groups.google.com/forum/#!topic/jni4net/43HbWrRvZRA)

Below is the stacktrace

D:\jni4net-0.8.8.0-bin\bin>.\proxygen.exe "D:\VBProjects\FirstCsharp\helloworld\helloworld\bin\Debug\helloworld.dll" -wd "C:\workspace\CSharpJavaProject"
jni4net.proxygen - Copyright (C) 2009 Pavel Savara - licensed under GPLv3

Proxygen must be run as trusted assembly! (shared drive could cause the problem)

System.TypeInitializationException: The type initializer for 'net.sf.jni4net.proxygen.model.Repository' threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'jni4net.n-0.8.8.0, Version=0.8.8.0, Culture=neutral, PublicKeyToken=134a23405600bab4' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) ---> System.IO.FileLoadException: Could not load file or assembly 'file:///D:\jni4net-0.8.8.0-bin\lib\jni4net.n-0.8.8.0.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) ---> System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information. --- End of inner exception stack trace --- at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark) at System.Reflection.Assembly.LoadFrom(String assemblyFile) at net.sf.jni4net.proxygen.Program.AssemblyResolve(Object sender, ResolveEventArgs args) at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName) --- End of inner exception stack trace --- at net.sf.jni4net.proxygen.model.Repository..cctor() --- End of inner exception stack trace --- at net.sf.jni4net.proxygen.Program.Work(String[] args) at net.sf.jni4net.proxygen.Program.Main(String[] args)

As per your suggestion configured Path and %JAVA_HOME%\bin 2 env variables still din't work. Its an EC2 windows server 2016 instance(64-bit)

Can you help me with this stuff to get it working?

java
.net
jni4net
asked on Stack Overflow Sep 4, 2018 by Hema Latha • edited Sep 4, 2018 by Armali

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0