13

I tried to convert a project that relies on the vjs runtime to vs2010, but it errors out when trying to run.

It's giving the error that "Could not load file or assembly 'vjslib' or one of its dependencies. An attempt was made to load a program with an incorrect format."

I reinstalled the vjs runtime, but it didn't seem to help.

Is there any way to get get .net 4 to work with this?

2
  • 1
    I don't think there's any J# support in .NET 4.0. J# references worked in 3.5 because it was the same version of the CLR. .NET 4.0 introduces a new version of the CLR without J# support (or so I thought). Apr 13, 2010 at 18:16
  • So another words, I'm out of luck... the libraries I use that reference the j# library aren't going to be able to be used in .net 4? Apr 13, 2010 at 18:28

5 Answers 5

19

Very simple solution - Calling J# code from .NET 4.0

You take control and load it first supplying an explicit path. Then next time it's needed, it already knows the path (or it's already loaded in the AppDomain).

You will need to use LoadLibrary function, so import the pinvoke reference:

[DllImport("kernel32", SetLastError = true)]
static extern IntPtr LoadLibrary(string lpFileName);

The on load (either Main function in Console/WinForms or in Global.asax Application_Start):

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"));
}
1
  • 1
    It appears that MS stripped all J# support from any new .NET downloads of older libraries so this won't work without the J# libs. You can find them here at MS I couldn't figure out why the solution wasn't working until I realized all the DLLs were missing from v2.0.50727 This package installs all the J# support back. Jul 24, 2013 at 17:37
6

I have downloaded Microsoft Visual J# Version 2.0 Redistributable Package from http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=4712 and installed it.The issue is resolved.

1
4

I got this to work by copying C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\vjsnativ.dll (for 64 bit Microsoft.NET\Framework64\v2.0.50727\vjsnativ.dll) to my application's debug/release directory.

I suspect Microsoft will need to release another j# redistributable package to work with .net 4.0. Meanwhile, this work-around does a fine job.

3
  • Please could you clarify what folder you copied the file into? I have this problem but I don't see a debug/release directory. I have a .net 4 web site (not web application). I tried copying into the /bin but that hasnt worked: {"Unable to load DLL 'vjsnativ': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"} Thank you.
    – bgs264
    Jun 18, 2010 at 14:15
  • @bgs264: I needed this for a .net app. My guess for a web site would indeed have been to put it in the bin directory, together with the other dll's. If that doesn't work, then I'm not sure what else to suggest.
    – Jimmy
    Jun 19, 2010 at 2:53
  • thanks. No dice - I just found another component that didn't use J# (it was a 3rd party PDF XSL FO processor) - Now using something else - not a fix but I'm back on track. Thanks.
    – bgs264
    Jun 22, 2010 at 8:21
1

The only way I could get it to work was to copy the C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\vjsnativ.dll to the C:\Windows\Microsoft.NET\Framework\v4.0.30319 folder. See http://community.microfocus.com/borland/managetrack/starteam/w/knowledge_base/17108.error-unable-to-load-dll-vjsnativ-the-specified-module-could-not-be-found-exception-from-hresult-0x8007007e.aspx

1
  • That worked for me but I also had to recycle the application pool.
    – jcs
    Jul 30, 2019 at 18:47
0

To add to the existing answers, I found that the solutions didn't work for me.

First thing I did was to repair the Microsoft Visual J# 2.0 Redistributable Package -SE (x64) using Windows Control Panel (Just right click and click repair). This was in case I did any damage in my previous attempts to fix the problem.

I had already implemented the solution provided by David Thielen.

1 Extra step closed the deal for me (solved the problem): Copy "vjscor.dll", "vjslib.dll" and "vjsnativ.dll" from C:\Windows\Microsoft.NET\Framework64\v2.0.50727 To C:\Windows\Microsoft.NET\Framework\v2.0.50727

So basically the Microsoft package placed the correct dlls into the 64-bit .NET framework and I had to manually move them into the 32-bit folder which is then copy-pasted into my solution folder by David Thielen's solution (above).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.