An exception is the type initializer for java.lang.System. Internal exception: Unable to load DLL 'vjsnativ':

I am currently undergoing a project developed in 2008/2010. Work with ASP.NET Frame 3.5 / 4 until 2012. ASP.NET with Frame 4.5. My project has 2 DLLs supporting J #. When loading WSDL, its error is not displayed. But the runtime of his throwing error
type initializer for "java.lang.System" made an exception. Internal exception: Unable to load DLL 'vjsnativ': the specified module was not found. (Exception from HRESULT: 0x8007007E) Internal exception: Unable to load DLL "vjsnativ": the specified module was not found. (Exception from HRESULT: 0x8007007E)

I tried replacing the dll, but did not use it. It was understood from online updates since ASP.net 2012 no longer has J # support. Please help me if anyone can shed some light on this.

thank

+4
source share
2 answers

I ran into the same problem. I came across a small blog post with a solution to a problem that I will cover in my answer. Here is a blog post that I mean: http://blogs.windwardreports.com/davidt/2011/02/calling-j-code-from-net-40.html .

Please note that I can not take credit for this decision. This is a solution that I personally used in my projects.

J # DLL .NET 4.0 vjsnativ.dll . , , . , :

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

: - . , .

+3

: DLL bin\debug

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 https://social.msdn.microsoft.com/Forums/vstudio/en-US/027fbfbe-2564-42cf-8b49-4cbac8c45f92/javalangsystem-exception-for-vjslib-in-c?forum=netfxsetup

0

All Articles