Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8367813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:15:06+00:00 2026-06-09T13:15:06+00:00

I have a file within my Silverlight project, within a folder. My project is

  • 0

I have a file within my Silverlight project, within a folder.

My project is called Display

Solution Explorer structure:

/Resources
    cube.obj

My code is:

Uri u = new Uri(@"Display;component/Resources/cube.obj", UriKind.Relative);
Stream stream = Application.GetResourceStream(u).Stream;
StreamReader reader = new StreamReader(stream);

cube.obj has the build action set to Content if that’s relevant.

I’m getting a NullReferenceException that comes up in the JavaScript and doesn’t give me much help in determining the issue.

Any ideas?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:15:06+00:00Added an answer on June 9, 2026 at 1:15 pm

    Set the file’s build action to “Resource”, not “Content”.

    The NullReferenceException is coming from the Application.GetResourceStream(u).Stream. GetResourceStream returns null because the file isn’t available because it’s the wrong build action. Accessing Stream on the null reference then fires the exception.

    EDIT: Also make sure that your Uri “Display;” portion is the proper name for your assembly that is housing the obj file.

    Just to clarify. Use Content when you want the file to be placed in the XAP file alongside the various assemblies. You can then access the file without the prefix “Display;component” path. (NOTE: off the top of my head, I don’t think I’ve loaded a “Content” resource in this way with Application.GetResourceStream specifically so I don’t know for sure if it will work, but I suspect it would). I also suspect this could cause issues if you have the same file name located in different paths/projects. This method is especially useful if you want to share the same resource/file with multiple projects/assemblies.

    Using Resource will keep the file embedded within the assembly DLL. With this, you need to specify the assembly to look in (hence the “Display;component” prefix). But this is necessary if you’re packaging pre-compiled assemblies for use in your Silverlight project or want to manage the files differently.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file within a Silverlight application that contains application settings and
My website utilizes ASP. I have a link to a PowerPoint file within my
Possible Duplicate: How to use include within a function? i have two file inc.php
I have a text file that have strings enclosed within double-quotes. I want to
I have a gzipped text file that I'm trying to read within PHP (using
I have registered an enumeration type ClefType within my header file - this enum
Within my service I have an mbean which is accessed by my war file.
How do I have a PowerShell script embedded within the same file as a
I have this in my htm file <select id=SelItem> </select> Within my javascript file
Within my HTML, I have a php script that includes a file. At that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.