Making a Game library with XNA, and I'd like to bundle it with some stock effects, if possible. But I'm having no luck attaching a Content project to the Library, so is it possible to use the Content Processor to load effects this way?

If not, how should the bundling be done? I would like the "user" (that is, someone building something with the library) not to have to deal with loading the effect, other than calling some library function with no arguments.


1 Answer 1


I just developed a similiar thing for my project and it works, but it's bad for debugging so I skipped it. What I did was implement this:


I have an Engine DLL Library and in it I just created a resource file, called "Effects.resx" and added some simple effect files that aren't compiled then later with the code above implemented I just created a method for generating an effect.

public class DynamicContent
    public static Effect CreateEffect(GraphicsDevice graphicsDevice, string effectCode)
        EffectContent input = new EffectContent() {  EffectCode = effectCode };
        EffectProcessor processor = new EffectProcessor();
        CompiledEffectContent content = processor.Process(input, new MyProcessorContext());

        return new Effect(graphicsDevice, content.GetEffectCode());

then with my Resource file I just accessed it like this:

// "multitexture.fx" for example in the Resources.resx / Effects.resx
Effect effect = DynamicContent.CreateEffect(GraphicsDevice, Effects.multitexture);

Some things that aren't ideal about using the Pipeline is that it needs the full .NET Framework, so to be able to use the tutorial above you need to change the Target Framework by going into your Game Library Properties / Application.

This way, no files are loaded from the content directory but compiled during runtime and bundled with the Game Library as a Resource.

  • \$\begingroup\$ Just a note, I did something similiar to this to be able have effects in the Engine (stock effects) but I deleted it because I wasn't to happy with debuging the HLSL code. So it's perhaps not the exact way I did it, but it worked and perhaps I forgotten something. But it's a start. \$\endgroup\$
    – Deukalion
    Commented Apr 14, 2013 at 14:04
  • \$\begingroup\$ Thanks! I'll look into this- if it pans out I'll accept the answer and delete this comment. \$\endgroup\$ Commented Apr 14, 2013 at 18:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .