views:

17

answers:

1

I have a C# script executor, which execute an arbitary chunk of c#, by wrapping it, and executing it in its own appdomain. To compile it correctly, I need to know what assemblies it needs.

Is it the case that I need to extract the namespaces for the script and iterate through every assembly I can find, to find a match, or is their a simpler way to do it?

Thanks. Bob.

+1  A: 

If you need to do this then that is pretty much what you will have to do. Also, remember that namespaces can span assemblies so make sure you grab all assemblies that have types with that namespace, not just the first one you find.

Andrew Hare
But as a possible optimization, you might look for matches in assembly names with the namespace you're looking for (including substrings) and search those assemblies first. While there's no requirement that assembly names and namespaces have any relationship, it's very common for an assembly name (or a portino of the assembly name) to be used as a portion of the namespace names for classes contained in the assembly.
Michael Burr