Currently am migrating a project developed in 2008/2010 ASP.NET Frame work 3.5 /4 to 2012 ASP.NET With Frame Work 4.5 My Project has 2 DLL's Supporting J#. While loading the WSDL , its doesn't show the error . But runtime its throwing error
The type initializer for 'java.lang.System' threw an exception. Inner Exception: Unable to load DLL 'vjsnativ': The specified module could not be found. (Exception from HRESULT: 0x8007007E) Inner Exception: Unable to load DLL 'vjsnativ': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Tried replacing the dll but no use. Its been understood from the online updates like there is no more any support for J# in ASP.net 2012. Please help me if any one can throw light /thoughts on this.
Thanks
I have encountered the same issue as well. I came across a small blog post with a solution to the problem, which I will refer to in my answer. Here is the blog post that I am referring to: http://blogs.windwardreports.com/davidt/2011/02/calling-j-code-from-net-40.html.
Please note that I cannot take credit for this solution. It is a solution I have personally used in my own projects.
When calling a J# DLL from .NET 4.0 or newer you will get the error vjsnativ.dll could not be located. The work-around linked to above explicitly loads the library. Here is an example solution, pretty much taken from said link:
using System;
using System.IO;
using System.Runtime.InteropServices;
namespace Test
{
class Program
{
[DllImport("kernel32", SetLastError = true)]
static extern IntPtr LoadLibrary(string lpFileName);
static void Main(string[] args)
{
if (Environment.Version.Major >= 4)
{
string folder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), @"..\Microsoft.NET\Framework\v2.0.50727");
folder = Path.GetFullPath(folder);
LoadLibrary(Path.Combine(folder, "vjsnativ.dll"));
}
// Now you can use J# in newer .NET versions
}
}
}
Edit: Simply linking to a solution isn't the best way to answer a question. I instead outlined the solution provided in the link.
I resolve mine and found the solution: Copy following dlls into bin\debug folder
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\vjscor.dll C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\vjslib.dll C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\vjsnativ.dll
-kudos to Shailesh https://social.msdn.microsoft.com/Forums/vstudio/en-US/027fbfbe-2564-42cf-8b49-4cbac8c45f92/javalangsystem-exception-for-vjslib-in-c?forum=netfxsetup
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With