0

I am trying to connect to a Sqlite database with Windows phone 7.

But in DBHelper file I'm getting a NullReferenceException in Application.GetResourceStream():

System.IO.Stream src = Application.GetResourceStream(new Uri("/" + assemblyName + ";component/" + dbName, UriKind.Relative)).Stream;

How to solve it?

dtb
  • 198,715
  • 31
  • 379
  • 417
meetme
  • 43
  • 6
  • Possible duplicate of [What is a NullReferenceException and how do I fix it?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Nasreddine Oct 04 '15 at 09:06

2 Answers2

0

is your uri correct ? it seems that this method can't find the resource you are asking for and strangely returns a null reference instead of throwing an exception.

Beatles1692
  • 4,814
  • 27
  • 60
0

Just break the statement out into separate stages and you'll see which part is missing. So concatenate the string into a variable. Separately construct the uri. Then create the stream.

Chances are its failing to create the Uri so when you try to use the Stream property it's failing. But it's more important to understand how to diagnose the problem.

kaj
  • 4,633
  • 1
  • 19
  • 18