Following an example from this thread, I've made an application that dynamically loads in C# "scripts" (actually, plugins) into my game -- but I've hit a snag: how do I reference the assemblies for XNA when compiling? Can I even be sure the XNA assemblies will be around on the end-user's machine?

This line from the example:


Adds the referenced assemblies for my game only, not the XNA assemblies (for instance, for Vector3, Matrix, etc.). The only way to add the assemblies seems to be inlining an absolute URI to the necessary .dll files.

EDIT: Looking at this thread I have discovered how to load all of the required assemblies:

foreach (AssemblyName assemblyName in executingAssembly.GetReferencedAssemblies())

But apparently the XNA assemblies aren't included in this list for me :(

  • \$\begingroup\$ I'm confused. If your game is built on XNA and has the assemblies, why do you need them anywhere else? Your game will load the plugin and already have the correct assemblies ref? \$\endgroup\$ Apr 28, 2015 at 15:38
  • \$\begingroup\$ I guess that's what I'm asking. When I distribute my game, where are the assemblies going to be located? \$\endgroup\$
    – mklingen
    Apr 28, 2015 at 16:03
  • \$\begingroup\$ For an XNA game to run the user must have (which is usually included with the game distribution) whatever XNA redist you built your game off of. So you can assume, after install, that the user will have the files. I believe they go to C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86 for 4.0...look around in there! \$\endgroup\$ Apr 28, 2015 at 16:20
  • \$\begingroup\$ I see, the assemblies are included in the redistributable, and the user doesn't have to download XNA 4.0? \$\endgroup\$
    – mklingen
    Apr 28, 2015 at 16:21
  • \$\begingroup\$ That's what the redist is. Compiled versions of XNA 4.0 that contain all the code that is referenced by your game. So instead of installing the SDK of xna or anything of that nature, you just provide them with the redistributable. \$\endgroup\$ Apr 28, 2015 at 16:33

1 Answer 1


You could sum it up like such:

Pre-game install: You can't assume they are there.

Post-game install: You can assume (hope) that the XNA 4.0 Redistributable installed correctly and the assemblies reside in their respected locations.

If the scripting that the user will be doing is tested and run solely in game, then I would think that this is a safe route to go to assume the assemblies are in place or the game wouldn't even be working.

If you create some kind of "scripting editor" it's probably not going to require the same assemblies as a game. Like you stated in your question, Vector3, etc are MOST LIKELY not required to build a "text/script editor", and therefore it wouldn't be safe to assume they are.

As always with XNA Games, make sure you include the appropriate Redistributable and you will be fine.

  • \$\begingroup\$ thank you, for the record my "scripts" are just going to be in data files loaded at runtime, and exist mainly to make it really easy for me to create many many kinds of entities. The only "users" who will access these files are potentially modders. \$\endgroup\$
    – mklingen
    Apr 28, 2015 at 17:57
  • \$\begingroup\$ That's a cool concept. I wish more AAA titles would go back to being friends with modders. \$\endgroup\$ Apr 29, 2015 at 12:05

You must log in to answer this question.

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