0
votes

I am following this tutorial for SQLite practice in Xamarin:

https://code.tutsplus.com/tutorials/an-introduction-to-xamarinforms-and-sqlite--cms-23020

Now I am stuck here in

public RandomThoughtDatabase () { _connection = DependencyService.Get"ISQLite" ().GetConnection (); }

ISQLite is an interface in PCL

its giving this error

Error CS0119 'DependencyService.Get(DependencyFetchTarget)' is a method, which is not valid in the given context LocalStorage

1
Did you mean to write DependencyService.Get<ISQLite>()? Also do you happen to have an ISQLite.GetConnection property, similar to this issue? - hvaughan3
DependencyService.Get<ISQLite>().GetConnection(); it works. - G Mehdi Balti
Bundle of Thanks :( - G Mehdi Balti
yeah . Actually i am new to Xamarin . Shifting from Android Studio To Xamarin - G Mehdi Balti

1 Answers

2
votes

Use the following instead:

public RandomThoughtDatabase () { _connection = DependencyService.Get<ISQLite>().GetConnection(); }