1

I get the Error Unable to load DLL 'sqlite3' while I have the XAML Designer of my WP8.1 Universal project open and a Data Context set like this:

DataContext="{Binding IntakeReasonListViewModel, Source={StaticResource Locator}}"

The Locator is designed like the recommended MVVM Light View Model Locator and uses the ServiceLocator. The error message appears only in design time and it works withouth any problems while executing. Also I have 3 apps. 2 of them have this issue, one does not. But I can't find any difference between them regarding to the SQLite.

I found different threads with the similar message, but all these problems appeard to runtime and caused some errors on saving items, while mine problem doesn't.

EDIT: I found out that the problem is that I inject my data access via a repository class to the view model. This way the designer tries to load the data access, inclusive the sqlite modul..

Does anyone know a way to avoid this for design time?

Thanks

Regards NPadrutt

NPadrutt
  • 3,619
  • 5
  • 24
  • 60

1 Answers1

2

You can always use a separate ViewModel for design time. I find it a good practice to have 3 files for each View (eg. for MainPage):

  • IMainPageViewModel (contains bindable properties, commands etc...)
  • MainPageViewModel (child of ViewModelBase, implements IMainPageViewModel)
  • MainPageDesignViewModel (child of ViewModelBase, implements IMainPageViewModel)

This way you can avoid loading the other services, and just display some demo data that'll help you in design mode. This answer to an other question details how to use a separate service or a separate ViewModel for design time: https://stackoverflow.com/a/14154088/4788286 (With MVVMLight the key is to use the ViewModelBase.IsInDesignMode and ViewModelBase.IsInDesignModeStatic properties.)

Community
  • 1
  • 1
Tamás Deme
  • 2,194
  • 2
  • 13
  • 31