Importing DLL file compiled with 64-bit only option

Hi all,
I have been facing an issue where I have created a nupkg for certain DLL files which I want to use in our project. Out of these DLLs one is built for 64-bit only targeted CPU. However, UiPath studio is built on 32-bit platform. So, when I run the code using this DLL, it throws error for compatibility issue and does not run.

How can I use this DLL file in the project and run the code? The same code if I write in the C#.net/VB.net runs smoothly.

1 Like

What is the error? Is it a DLL created by you or available publicly?

The DLL is publically available for a program called as “Autodesk Vault 2020”.

The Error is like this: “The type initializer for ‘Autodesk.Connectivity.WebServicesTools.WebServiceManager’ threw an exception.”

This error in visiual studio is generated when the targated CPU is other than 64-bit. I have checked.

@rkmatieda

Hello Rajdeepsinh,
as far as I know it is not possible to use libraries, which are compiled exclusively for x64, with UiPath. As you wrote correctly, UiPath is an x86 application.
Create an x64 executable which contains your code. If you have different methods, make it possible to call them via parameterization. With the Start Process activity you can call x64 executables too.
On this way you can realize an integration.
Best regards
Stefan

Hi @StefanSchnell,
Thanks for the reply.
Could you please provide me a demo code for this x64 executable?

@rkmatieda

Hello Rajdeepsinh,
sure. At first a test library, in your case the Autodesk library. In my case only an example for demonstration.

//-Begin----------------------------------------------------------------

public class ExeWrapperLibrary {

  public string MethodOne(string ArgumentOne) {
    return "Hello World from " + ArgumentOne;
  }

}

//-End------------------------------------------------------------------

Now the executable to call this library.

//-Begin----------------------------------------------------------------

using System;

public class ExeWrapper {

  public static void Main(string[] args) {

    string ret = string.Empty;

    ExeWrapperLibrary lib = new ExeWrapperLibrary();
    if(args.Length == 0) {
      return;
    }
    ret = lib.MethodOne(args[0]);
    Console.WriteLine(ret);
    Console.ReadKey();

  }

}

//-End------------------------------------------------------------------

Both are compiled for the x64 platform with this batch.

c:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /target:library /platform:x64 /out:ExeWrapperLibrary.dll ExeWrapperLibrary.cs
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /target:exe /platform:x64 /out:ExeWrapper.exe /reference:ExeWrapperLibrary.dll ExeWrapper.cs

And with the activity Start Process you can execute the method in the library.

image

image

However asynchronous, but that can be easily controlled.

Best regards
Stefan

Hi @StefanSchnell,
Thanks very much for the reply and the code suggestion. But here I need more help. My requirement is little bit complex. Basic idea was to have custom activities, so the programmer can choose any one or more in the program. Now That possibility is ruled out because of 64-bit Architecture.

In the executable code there needs more than one function to do various actions. Now depending upon programmer’s need multiple functions needs to be called.

Are there only arguments which can be used to pass instructions to the Main() method, or we can call functions from outside of the code also like from the Uipath program?

@rkmatieda

Hello Rajdeepsinh,
here an example to call methods. At first the library with two different methods:

//-Begin----------------------------------------------------------------

using System;

public class ExeWrapperLibrary {

  public string MethodOne(string ArgumentOne) {
    return "Hello World from " + ArgumentOne;
  }

  public int MethodTwo(string ArgumentOne, int ArgumentTwo) {
    return Convert.ToInt32(ArgumentOne) + ArgumentTwo;
  }

}

//-End------------------------------------------------------------------

And here now the executable to use this library:

//-Begin----------------------------------------------------------------

using System;

public class ExeWrapper {

  public static void Main(string[] args) {

    string strRet = string.Empty;
    int intRet = 0;

    ExeWrapperLibrary lib = new ExeWrapperLibrary();
    if(args.Length == 0) {
      return;
    }

    switch(args[0]) {

      case "MethodOne" :
        strRet = lib.MethodOne(args[1]);
        Console.WriteLine(strRet);
        break;

      case "MethodTwo" :
        intRet = lib.MethodTwo(args[1], Convert.ToInt32(args[2]));
        Console.WriteLine(intRet.ToString());
        break;

      default:
        Console.WriteLine("No known method invoked");
        break;

    }

    Console.ReadKey();

  }

}

//-End------------------------------------------------------------------

In this example is the first parameter of the executable the name of the method you want to invoke. On this way you can code an executable wrapper for the x64 library and use it with x86 applications.

image

Maybe you should try the program CorFlags. It might be possible to use the library with x86 applications.

Best regards
Stefan