# How do I dynamically reload content files?

Is there a relatively simple way to dynamically reload content files, such as effect files?

I know I can do the following:

1. Detect change of file
2. Run content pipeline to rebuild that specific file

And use double references to reference content files.

The problem is with step 3 (and step 2 isn't that nice either). I need to unload everything because if I have model Hero.x which references Model.fx effect, and I change the Model.fx file, I need to reload the Hero.x file which will then call LoadExternalReference on Model.fx.

Has someone managed to make this work without rewriting the whole ContentManager (and every ContentReader) and tracking calls to LoadExternalReference?

I don't think this is a very common approach since the content build system is not redistributable (although some projects appear to be working around this limitation: Effect generator and XNA content compiler).

Also, here's another project that you might find interesting/useful: Content tracker. I'm not 100%, but believe it may help address some of your concerns regarding limitation 3.

• I would use it only for development, and it could be separated to two programs, one checking and rebuiling content and other checking and reloading content. I use this in every project that is not in xna, it really simplifies shader development. – Kikaimaru Apr 12 '12 at 8:09

So current solution that i use is following:

I have two projects:

Continuous Pipeline

1. Checks for changes in content pipeline project
2. Rebuilds changed item
3. Moves produced .xnb files to game content directory

(this approach won't work for things like .fxh and other stuff that links file in non standard way)

Game

1. Checks for changes in game content directory
2. Unloads all loaded assets (this is nescessary because I have my model reference effect files)