Null Reference Exception when StreamResourceInfo attempts to get a ResourceStream?

Dileep 1

New member
Nov 18, 2012
8
0
0
Visit site
Hi

I am getting Null Reference Exception when StreamResourceInfo attempts to get a ResourceStream in Windows phone 8 emulator. When i tried the same in Windows phone 7 emulator, the stream is getting correctly. But its not working on Windows phone 8 emulator. Please find the below code.

StreamResourceInfo streamInfo = App.GetResourceStream(new Uri("/Image;component/Images/123.png", UriKind.Relative));

Please help me out if any?
 

elyl

New member
Oct 30, 2012
25
0
0
Visit site
I'm not a WP developer (yet), but I am a .NET developer...
I always try to avoid referring to resources by their URI, as you never know exactly what it's going to be called, nor does it tell you in a debugger if the URI doesn't exist.
I don't know if this will work in WP, but in .NET I'd normally use:
Code:
System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("123.png")
to get the actual stream.

Hope you figure it out!
 

elyl

New member
Oct 30, 2012
25
0
0
Visit site
Is your png file set as Resource or Embedded Resource? Perhaps it's not being added to the build if one of these options isn't set.
 

Christian Amado

New member
Nov 20, 2012
1
0
0
Visit site
Hi

I am getting Null Reference Exception when StreamResourceInfo attempts to get a ResourceStream in Windows phone 8 emulator. When i tried the same in Windows phone 7 emulator, the stream is getting correctly. But its not working on Windows phone 8 emulator. Please find the below code.

StreamResourceInfo streamInfo = App.GetResourceStream(new Uri("/Image;component/Images/123.png", UriKind.Relative));

Please help me out if any?

Have you set your png image as Resource on your properties? Have you got the Images folder in your root?

Regards.
 

Members online

Forum statistics

Threads
323,312
Messages
2,243,619
Members
428,056
Latest member
Carnes