Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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:

options.ReferencedAssemblies.Add(Assembly.GetExecutingAssembly().Location);

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())
        cp.ReferencedAssemblies.Add(Assembly.Load(assemblyName).Location);

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

share|improve this question
    
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? –  Joe Swindell Apr 28 at 15:38
    
I guess that's what I'm asking. When I distribute my game, where are the assemblies going to be located? –  mklingen Apr 28 at 16:03
    
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! –  Joe Swindell Apr 28 at 16:20
    
I see, the assemblies are included in the redistributable, and the user doesn't have to download XNA 4.0? –  mklingen Apr 28 at 16:21
    
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. –  Joe Swindell Apr 28 at 16:33

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
    
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. –  mklingen Apr 28 at 17:57
    
That's a cool concept. I wish more AAA titles would go back to being friends with modders. –  Joe Swindell Apr 29 at 12:05

Your Answer

 
discard

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.