Showing results 1 to 3 of 3

Thread: AddIn build fails using SQLite DLLs

  1. #1
    Join Date
    22.02.2013
    Posts
    3

    Default AddIn build fails using SQLite DLLs

    Hi to all,

    maybe this problem is a bit special, but here we go:

    We have several AddIns using additional libraries, such as SAP  (sapnco connector using sapnco.dll) and everything is working great.

    But when I try to use the SQLite Package, there is always a DLL [SQLite.Interop.dll] missing. Instead of putting it into the ScadaAddIn - Package it is gonna be stored in the plain folder x64 (or x86, no difference).

    Where are the files specified, that are gonne be packed in that package? 

    Howto reproduce:

    • Create New ScadaAddIn Project as Project Service Extension
    • Add NuGet Packet SQLite and SQLite Core
    • Build your Project
    • Take a look in the myProject.scadaAddIn (open it with zip)
    • than look into Binary.zip
    • there should be the SQLite.Interop.dll --> but isn't.

    Can anybody help?

    Thanks in advance,
    Olli!


  2. #2
    Join Date
    15.07.2008
    Posts
    8

    Default Re: AddIn build fails using SQLite DLLs

    You have to put the native libraries inside File->Additional with the same directory structure (x86 x64) and inside the addin create something like this...

    private void PreloadSQLite(IProject context)
    {
    sqlitepath = Path.Combine(context.GetFolderPath(FolderPath.Othe rs), "Native");
    if (IntPtr.Size == 8) // or: if(Environment.Is64BitProcess) // .NET 4.0
    {
    sqlitepath = Path.Combine(sqlitepath, "X64");
    }
    else
    {
    // X32
    sqlitepath = Path.Combine(sqlitepath, "X86");
    }
    System.Environment.SetEnvironmentVariable("PreLoadSQLite_BaseDirectory", sqlitepath);


    // If we have a new path, try to force load the mixed-mode assembly for the current architecture
    // This can be avoided if the preload in SQLite works, but it is easy to do it here as well

    {
    try
    {
    PInvoke.LoadLibraryEx(Path.Combine(sqlitepath, "SQLite.Interop.dll"), IntPtr.Zero, 0);
    }
    catch (Exception ex)
    {
    Trace.WriteLine($"Failed to load interop SQLITE");
    }
    }
    }internal class PInvoke
    {
    [DllImport("kernel32.dll", SetLastError = true)]
    public static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hReservedNull, LoadLibraryFlags dwFlags);

    [System.Flags]
    public enum LoadLibraryFlags : uint
    {
    None = 0,
    DONT_RESOLVE_DLL_REFERENCES = 0x00000001,
    LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010,
    LOAD_LIBRARY_AS_DATAFILE = 0x00000002,
    LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x00000040,
    LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x00000020,
    LOAD_LIBRARY_SEARCH_APPLICATION_DIR = 0x00000200,
    LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = 0x00001000,
    LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR = 0x00000100,
    LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800,
    LOAD_LIBRARY_SEARCH_USER_DIRS = 0x00000400,
    LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008
    }
    }

  3. #3
    Join Date
    22.07.2019
    Posts
    2

    Default Re: AddIn build fails using SQLite DLLs

    I faced the same issue and i tried others way to succeed and they are showing the right path.i hope you found the thread helpful.i wish this community contribute to my issue.

Similar Threads

  1. Zenon 7.20 SP0 build 17678 vs build 20554
    By sdolnyy in forum zenon Supervisor
    Replies: 0
    Last Post: 18th December 2017, 21:50
  2. Replies: 2
    Last Post: 18th December 2017, 13:06
  3. Replies: 0
    Last Post: 18th August 2010, 14:52
  4. Version 6.21; SQL Server installation fails
    By stefan_m in forum Editor and Runtime Setup
    Replies: 0
    Last Post: 12th September 2007, 07:40

Tags for this Thread

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •