0

I'm trying to convert a particular .NET dll (System.DirectoryServices) to a Java stub using ikvmstub.exe. I get the following error:

ikvmstub.exe System.DirectoryServices.dll
Error: unable to load assembly 'System.DirectoryServices.dll' as it depends on a higher version of mscorlib than the one currently loaded

I believe the DLL depends on v4.0.30319, which I have. So I ran this command and got the following output:

ikvmstub.exe -nostdlib -r:/c/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll System.DirectoryServices.dll
Error: unable to find mscorlib.dll

The path I gave to mscorlib is definitely correct. For the record, I'm in Git Bash in Windows 7. What can I do to resolve this error?

bkaiser
  • 647
  • 8
  • 22
  • Writing a java stub of DirectoryServices seems... Odd. You may want to write a dll that just exposes what you need and have that user made dll call into DirectoryServices instead. (Or even better, [find a Active Directory management java library](http://stackoverflow.com/questions/8551809/how-to-connect-with-java-into-active-directory)) – Scott Chamberlain Sep 09 '15 at 20:50
  • Yes, it's odd. I'm trying to allow users to authenticate to and query AD without entering their passwords. This is possible in C# but not in any Java library I'm familiar with. I thought that by exposing the DirectoryServices library to Java I'd be able to take advantage of C#'s access to the existing AD bind. – bkaiser Sep 10 '15 at 13:03

1 Answers1

1

Still not sure why this was occurring, but I solved it by reading through the IKVM source.

internal void Init(Universe universe, bool nostdlib, IList<string> references, IList<string> userLibPaths)
    {
        this.universe = universe;
        // like the C# compiler, the references are loaded from:
        // current directory, CLR directory, -lib: option, %LIB% environment
        // (note that, unlike the C# compiler, we don't add the CLR directory if -nostdlib has been specified)
...

So I nagivated to the directory where mscorlib and my target dll were located, called ikvmstub.exe from there, and it worked fine.

bkaiser
  • 647
  • 8
  • 22