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

  • Home
  • SEARCH
  • 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 5847361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:42:28+00:00 2026-05-22T12:42:28+00:00

I’m using VS2010 express to create a game built with xna . I’m trying

  • 0

I’m using VS2010 express to create a game built with xna. I’m trying to use t4 templates (to produce strongly-typed classes of content locations, thus using Level1Location = Content.Levels.Level1 instead of Level1Location = @"Content\Levels\Level1".

I’ve read that T4 templates aren’t properly set up in the express editions, but that if i create a file with extension .tt it should work. However when i create a .tt file in my XNA class library i get the following warning (and no code file):

The custom tool 'TextTemplatingFileGenerator' failed. Could not load file or assembly 'Microsoft.VisualStudio.ServicesProxy, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

I’ve searched and searched and can’t find anything useful. Has anyone encountered this problem before? Anyone know if a solution?

I’ve also tried changing the custom tool to TextTemplatingFilePreprocessor as suggested, however i get the same error.

EDIT: I’ve discovered that the issue is that it’s in an XNA project / library. It works fine in a normal class so my work around is to add a project to the solution just for the template. The question is still open though, can you get it to work within a XNA project?

  • 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-05-22T12:42:29+00:00Added an answer on May 22, 2026 at 12:42 pm

    Although i’ve posted this answer, i’m still looking for a simpler way of doing this (i.e. tt file in the XNA project its self)

    In case anyone finds this page, here’s my work around:

    Create a new (non-XNA) class library project.

    Add a text file, renamed with the .tt extension.

    Write your T4 code (see below).

    In your XNA project, add an existing item, navigate to the created .cs file, and add as link.

    Then, to ensure we always have the updated cs file, rightclick the XNA project and click project dependencies, then tick your class library project containing the .tt file.

    Using the template code below, you can do things like Content.Load(Content.MyGameContent.Graphics.Textures.AwesomeTexture); You can also get folder names as strings with Content.MyGameContent.Graphics.Textures for example, thanks to a funky implicit string conversion operator.

    <#@ template language="c#" hostspecific="true" #>
    <#@ assembly name="EnvDTE100" #>
    <#@ assembly name="EnvDTE" #>
    <#@ assembly name="System" #>
    <#@ assembly name="System.Core" #>
    <#@ import namespace="EnvDTE100" #>
    <#@ import namespace="EnvDTE" #>
    <#@ import namespace="System" #>
    <#@ import namespace="System.IO" #>
    <#@ import namespace="System.Linq" #>
    <#@ import namespace="System.Collections.Generic" #>
    namespace Content
    {
    <#
    var serviceProvider = this.Host as IServiceProvider;
    var dte = serviceProvider.GetService(typeof(DTE)) as DTE;
    
    foreach (Project Proj in dte.Solution.Projects)
    {
        bool IsContentProj = false;
        foreach(Property Prop in Proj.Properties)
        {
            if(Prop.Name == "Microsoft.Xna.GameStudio.ContentProject.ContentRootDirectoryExtender.ContentRootDirectory")
            {
                IsContentProj = true;
            }
        }
        if (IsContentProj)
        {
    #>
        public static class <#=Proj.Name #>
        {
    <#
            foreach(ProjectItem PI in Proj.ProjectItems)
            {
    GenerateProjectItemClass(PI, true, "        ");
            }
    #>
        }
    <#
        }
    }
    #>
    }
    <#+
        void GenerateProjectItemClass(ProjectItem Item, bool Static, string Indent)
        {
            const string FolderItemKind = "{6BB5F8EF-4483-11D3-8BCF-00C04F8EC28C}";
            const string FileItemKind = "{6BB5F8EE-4483-11D3-8BCF-00C04F8EC28C}";
            string ClassName = Path.GetDirectoryName(Item.FileNames[0]).Substring(Path.GetDirectoryName(Item.FileNames[0]).LastIndexOf(Path.DirectorySeparatorChar) + 1);
            int ContentRootLength = Path.GetDirectoryName(Item.ContainingProject.FileName).Length;
    
            string RelativeLocation = Path.ChangeExtension(Path.GetFullPath(Item.FileNames[0]).Substring(ContentRootLength + 1), null);
    
            switch(Item.Kind)
            {
                case FolderItemKind:
    #>
    <#=Indent#>public class <#=ClassName #>Class
    <#=Indent#>{
    <#=Indent#>    private const string Location = @"<#= RelativeLocation #>";
    <#=Indent#>    public static implicit operator string(<#=ClassName #>Class MyClass)
    <#=Indent#>    {
    <#=Indent#>        return Location;
    <#=Indent#>    }
    <#+
                foreach(ProjectItem ChildItem in Item.ProjectItems)
                    GenerateProjectItemClass(ChildItem, false, Indent + "    ");
    #>
    <#=Indent#>}
    <#=Indent#>
    <#=Indent#>public <#= Static ? "static " : " " #><#=ClassName#>Class <#=ClassName#> = new <#=ClassName#>Class();
    <#=Indent#>
    <#+
                break;
                case FileItemKind:
    #>
    <#=Indent#>public <#= Static ? "static " : " " #>string <#= Path.GetFileNameWithoutExtension(Item.FileNames[0]) #> = @"<#=RelativeLocation #>";
    <#+
                break;
            }
        }
    #>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want use html5's new tag to play a wav file (currently only supported
I'm making a simple page using Google Maps API 3. My first. One marker
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am trying to loop through a bunch of documents I have to put
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
In order to apply a triggered animation to all ToolTip s in my app,

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.