Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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.

share|improve this answer
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. – Deukalion Apr 14 '13 at 14:04
Thanks! I'll look into this- if it pans out I'll accept the answer and delete this comment. – Richard Rast Apr 14 '13 at 18:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.