Error loading dll

Hi

 

I'm integrating ProjectWise with Lotus Notes - so far so good.  My code is running well on my machine, however when testing my code on a user's machine and I get the following error "error in loading .dll". 

 

The ProjectWise path is in the "Path" in environment variables (same as on my machine). I'm calling the aaApi_Initialize Lib "DMSCLI.dll" in my code.   Does anyone have any clues? 

 

Many thanks

Parents
  • Not sure if this would help but I use the following code when doing Web applications ( as ASP.Net in IIS copies and runs the application from another location) calling the method when the application is started.

    [DllImport("kernel32.dll", EntryPoint = "SetDllDirectory", CharSet = CharSet.Unicode, SetLastError = true)]
    [return: MarshalAs(UnmanagedType.Bool)]
    static extern bool SetDllDirectory(string lpPathName);

    [DllImport("kernel32.dll", EntryPoint = "SetDllDirectoryW", CharSet = CharSet.Unicode, SetLastError = true)]
    [return: MarshalAs(UnmanagedType.Bool)]
    public static extern bool SetDllDirectoryW([In] [MarshalAs(UnmanagedType.LPTStr)] string lpPathName);

    [DllImport("kernel32.dll", EntryPoint = "LoadLibrary", CharSet = CharSet.Unicode, SetLastError = true)]
    static extern IntPtr LoadLibrary(string lpFileName);

    /// <summary>
    /// Loads the required ProjectWise DLL's into memory.
    /// </summary>
    /// <param name="binDir">The path to the ProjectWise Bin Directory</param>
    /// <returns>True if libraries were successfully loaded</returns>
    public static bool LoadPWLibraries(string binDir) {
    bool b = true;
    System.Diagnostics.Debug.Print("Loading required libraries");

    IntPtr ptr = LoadLibrary("kernel32.dll");
    if (ptr == IntPtr.Zero) {
    System.Diagnostics.Debug.Print("Failed to load kernel32.dll with ERROR CODE:-{0}", Marshal.GetLastWin32Error());
    b = false;
    }

    if (!SetDllDirectory(binDir)) {
    System.Diagnostics.Debug.Print("Failed to add ProjectWise Bin directory to DLL search path with ERROR CODE:-{0}", Marshal.GetLastWin32Error());
    b = false;
    }

    ptr = LoadLibrary(string.Format(@"{0}\dmsgen.dll", binDir));
    if (ptr == IntPtr.Zero) {
    System.Diagnostics.Debug.Print("Failed to load dmsgen.dll with ERROR CODE:-{0}", Marshal.GetLastWin32Error());
    b = false;
    }

    ptr = LoadLibrary(string.Format(@"{0}\dmscli.dll", binDir));
    if (ptr == IntPtr.Zero) {
    System.Diagnostics.Debug.Print("Failed to load dmscli.dll with ERROR CODE:-{0}", Marshal.GetLastWin32Error());
    b = false;
    }

    return b;
    }
Reply
  • Not sure if this would help but I use the following code when doing Web applications ( as ASP.Net in IIS copies and runs the application from another location) calling the method when the application is started.

    [DllImport("kernel32.dll", EntryPoint = "SetDllDirectory", CharSet = CharSet.Unicode, SetLastError = true)]
    [return: MarshalAs(UnmanagedType.Bool)]
    static extern bool SetDllDirectory(string lpPathName);

    [DllImport("kernel32.dll", EntryPoint = "SetDllDirectoryW", CharSet = CharSet.Unicode, SetLastError = true)]
    [return: MarshalAs(UnmanagedType.Bool)]
    public static extern bool SetDllDirectoryW([In] [MarshalAs(UnmanagedType.LPTStr)] string lpPathName);

    [DllImport("kernel32.dll", EntryPoint = "LoadLibrary", CharSet = CharSet.Unicode, SetLastError = true)]
    static extern IntPtr LoadLibrary(string lpFileName);

    /// <summary>
    /// Loads the required ProjectWise DLL's into memory.
    /// </summary>
    /// <param name="binDir">The path to the ProjectWise Bin Directory</param>
    /// <returns>True if libraries were successfully loaded</returns>
    public static bool LoadPWLibraries(string binDir) {
    bool b = true;
    System.Diagnostics.Debug.Print("Loading required libraries");

    IntPtr ptr = LoadLibrary("kernel32.dll");
    if (ptr == IntPtr.Zero) {
    System.Diagnostics.Debug.Print("Failed to load kernel32.dll with ERROR CODE:-{0}", Marshal.GetLastWin32Error());
    b = false;
    }

    if (!SetDllDirectory(binDir)) {
    System.Diagnostics.Debug.Print("Failed to add ProjectWise Bin directory to DLL search path with ERROR CODE:-{0}", Marshal.GetLastWin32Error());
    b = false;
    }

    ptr = LoadLibrary(string.Format(@"{0}\dmsgen.dll", binDir));
    if (ptr == IntPtr.Zero) {
    System.Diagnostics.Debug.Print("Failed to load dmsgen.dll with ERROR CODE:-{0}", Marshal.GetLastWin32Error());
    b = false;
    }

    ptr = LoadLibrary(string.Format(@"{0}\dmscli.dll", binDir));
    if (ptr == IntPtr.Zero) {
    System.Diagnostics.Debug.Print("Failed to load dmscli.dll with ERROR CODE:-{0}", Marshal.GetLastWin32Error());
    b = false;
    }

    return b;
    }
Children
No Data