WPF sqlite3 and sql-net intellisense binding error

0

I know this error has been reported before in similar (but different) scenarios:

"Error: "Unable to load DLL 'sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E"

In this case, it's an intellisense only issue I cannot seem to resolve. Everything works fine (I can execute sql queries etc) aside from the error. This seems like some kind of bug. The question, is why/where and can I resolve?

Here's what I did:

  1. Create WPF project (.NET 4.6, VS 2017 15.5.2)
  2. Change build config to x86 only
  3. Install System.Data.SQLite package
  4. Install sqlite-net package
  5. Create a simple viewmodel with an SQLite call in the constructor and bind that viewmodel as the Window.DataContext

Example:

<Window x:Class="myapp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:myapp"
        xmlns:viewModels="clr-namespace:myapp.ViewModels"
        Name="Editor"
        mc:Ignorable="d"
        Title="Package Creator" Height="600" Width="800">
    <Window.DataContext>
        <viewModels:ViewModelEditor/>
    </Window.DataContext>
        <Grid>
        </Grid>
</Window>

Where the ViewModel looks something like this:

enter code hereusing myapp.Models;

namespace myapp.ViewModels
{
    public class ViewModelEditor : ViewModelBase
    {
        public ViewModelEditor()
        {
            this.ViewYears = new Models.ModelYears();
        }
        private ModelYears viewYears;
        public ModelYears ViewYears
        {
            get { return viewYears; }
            set { viewYears = value; }
        }
    }
}

and the model looks like....

public class ModelYear
    {
        [Key]
        public int YearID { get; set; }


    }
    public class ModelYears : ObservableCollection<ModelYear>
    {
        public ModelYears()
        {
            SQLiteConnection conn = new SQLiteConnection(Properties.Settings.Default.DBPath);
            using (conn)
            {
                try
                {
                    var results = conn.Query<ModelYear>("SELECT YearID FROM YEARMODEL ym ORDER BY YearID;");
                    foreach (ModelYear r in results)
                    {
                        this.Add(r);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
    }
wpf
sqlite
mvvm
sqlite3
visual-studio-2017
asked on Stack Overflow Jan 3, 2018 by maplemale

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0