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 8532991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:50:56+00:00 2026-06-11T09:50:56+00:00

I am trying to serialize data in my XNA project. I have a Texture2D

  • 0

I am trying to serialize data in my XNA project. I have a Texture2D background property that I use during runtime, but I also have a ‘string property’ to hold my Background name. This will allow me to serialize the asset name so I can later use the info to de-serialize later and load into my game.

Problem is myTexture.Name property is suppose to hold the Asset Name but when I try to serialize into an XML file, the BackgroundName Element is empty.

Here is what the Property code looks like:

//This property is Only used for serialization, myTexture is Texture2D and is assigned in the ctor of the class
public string BGName { get { return this.myTexture.Name;} set{/*Empty on purpose*/} }

Could someone please advise, how to retrieve the asset name from a Texture2D, according to MSDN, this field holds the name of the texture.

  • 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-11T09:50:58+00:00Added an answer on June 11, 2026 at 9:50 am

    The Name property on GraphicsResource isn’t actually used by the XNA Framework; it’s up to you to populate it with whatever you feel is appropriate. You could write a helper method to do this easily enough:

    public static Texture2D LoadTexture2D(this ContentManager content, String asset)
    {
        var texture = content.Load<Texture2D>(asset);
        texture.Name = asset;
        return texture;
    }
    
    var texture = contentManager.LoadTexture2D("textures\\whatever");
    Console.WriteLine(texture.Name); // should be "textures\\whatever"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Visual Studio 2008 C++ project where I'm trying to serialize data
I have been trying to serialize a list that contains arrays and lists. I
I'm trying to serialize objects from a database that have been retrieved with Hibernate,
I have been trying to serialize some json data in Silverlight. I am using
Hey there! I'm trying to serialize data in AS3 but am running into a
I'm trying to serialize some data to xml in a way that can be
I'm trying to serialize an object that have a duplicate node name using C#,
I am trying to use NSJSONSerialization to serialize the data returned from stack overflow
I have a very simple class that I'm trying to serialize: [ProtoContract] public class
I am trying to binary serialize the data of vector. In this sample below

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.