0

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

4
  • Did you mean to write DependencyService.Get<ISQLite>()? Also do you happen to have an ISQLite.GetConnection property, similar to this issue? Commented Oct 12, 2017 at 17:39
  • 1
    DependencyService.Get<ISQLite>().GetConnection(); it works. Commented Oct 12, 2017 at 17:41
  • Bundle of Thanks :( Commented Oct 12, 2017 at 17:42
  • 1
    yeah . Actually i am new to Xamarin . Shifting from Android Studio To Xamarin Commented Oct 12, 2017 at 17:48

1 Answer 1

2

Use the following instead:

public RandomThoughtDatabase () { _connection = DependencyService.Get<ISQLite>().GetConnection(); }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.