<div>I'm not so sure that the current setup includes the System namespace. The only assembly, other than the OpenSim specific ones, that is loaded is System.Collections.Generic. I had to add System before I could even use Exceptions, which seems to indicate that only parts of System that are pulled in are the parts used by the other assemblies that are loaded.</div>
<div> </div>
<div>Melanie's response (which I mostly agree with) is why I didn't post it on the Wiki. This isn't something the average user (specifically OpenGrid users) should probably be doing. But rather than saying "absolutely not", I have to wonder if there's some reasonable middle ground that can do the job of both 1) protecting the average installation from arbitrary library code inclusion/execution, and 2) allowing an easier way to include that facility, for users that -do- need it, as a way for others to make OpenSim more flexible. </div>
<div> </div>
<div>Compile-time isn't a show-stopper, but something that makes the process easier, like a module, or something in the build system/environment like an "scriptengine_additional_libraries" variable might be handy. Basically, narrowing down a potential point of failure to one place, instead of three.<br>
</div>
<div>Thanks again though, my team here really appreciates all the hard work you all put into this.</div>
<div> </div>
<div>--Jeremy Lothian<br><br></div>
<div class="gmail_quote">On Thu, May 27, 2010 at 8:11 PM, Justin Clark-Casey <span dir="ltr"><<a href="mailto:jjustincc@googlemail.com">jjustincc@googlemail.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div class="im">Melanie wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">A generic means to add extra libs would be highly DANGEROUS. It<br>definitely needs to be compile-time. Probably has to be, anyway,<br>
from the way the scripts work.<br></blockquote><br></div>C# scripts are insecure anyway since anybody who can create them has access to the System namespaces. They are still useful in contexts where script creation and editing are restricted or all parties are highly trusted.
<div>
<div></div>
<div class="h5"><br><br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote"><br>Melanie<br><br>Justin Clark-Casey wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">J Lothian wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Justin,<br> Thanks for pointing me in a direction, this was -very- helpful. It wasn't nearly as straightforward as I was expecting, but it did give me the opportunity/excuse to get my hands dirty and dig into the projects and code a bit. I'm going to document the process a bit here, so it gets archived for future reference. I'm pretty sure I've narrowed down the steps needed.<br>
The actual project that needs the assembly reference added to it is OpenSim.Region.ScriptEngine.Shared.CodeTools, but this is just the start. This gets the assembly detectable by the compiler. The next step is adding the reference to the script being compiled. In OpenSim.Region.ScriptEngine.Shared.CodeTools.Compiler (Compiler.cs), in the function CompileFromDotNetText, there is a section where ReferencedAssemblies are added to the compiler as parameters, and the assembly needs to be added here as well. For example, to add a standard library, the following line would be used:<br>
parameters.ReferencedAssemblies.Add("System.dll");<br> Which, it turns out, I needed to do, as System.dll isn't added by default, and our test script included a try/catch where Exception was not detected as a type. To add something like the MySql dll that comes with OpenSim, it would look like this:<br>
<br>parameters.ReferencedAssemblies.Add(<br><br>Path.Combine(rootPath,"MySql.Data.dll"));The script engine automatically wraps scripts in boilerplate code to put them inside a class and make them compilable. This has the side-effect of making "using" or "import" statements inside scripts impossible, so these also need to be added to the code. For example, if your script is C#, then the function to alter is CreateCSCompilerScript (in the same Compile.cs), adding the using statement to the list inside this function.<br>
If I get the chance later this summer, I may try to develop a more robust system that attempts to (at the very least) detect the default mono/.net libraries and automatically adjust this boilerplate to include them...<br>
Again, thanks for the help!<br></blockquote>Glad that was of some use! Would very much look forward to a boilerplate adjuster - being able to include extra libraries from OpenSim C# 'scripts' would be really useful.<br>
<br>Also, it would be great if you could copy the above into a new wiki page off <a href="http://opensimulator.org/wiki/Developer_Documentation#Scripting" target="_blank">http://opensimulator.org/wiki/Developer_Documentation#Scripting</a>. Things tend to stay a little bit more visible there. Thanks!<br>
<br></blockquote>_______________________________________________<br>Opensim-dev mailing list<br><a href="mailto:Opensim-dev@lists.berlios.de" target="_blank">Opensim-dev@lists.berlios.de</a><br><a href="https://lists.berlios.de/mailman/listinfo/opensim-dev" target="_blank">https://lists.berlios.de/mailman/listinfo/opensim-dev</a><br>
<br></blockquote><br><br></div></div>
<div class="im">-- <br>Justin Clark-Casey (justincc)<br><a href="http://justincc.org/" target="_blank">http://justincc.org</a><br><a href="http://twitter.com/justincc" target="_blank">http://twitter.com/justincc</a><br>_______________________________________________<br>
</div>
<div>
<div></div>
<div class="h5">Opensim-dev mailing list<br><a href="mailto:Opensim-dev@lists.berlios.de" target="_blank">Opensim-dev@lists.berlios.de</a><br><a href="https://lists.berlios.de/mailman/listinfo/opensim-dev" target="_blank">https://lists.berlios.de/mailman/listinfo/opensim-dev</a><br>
</div></div></blockquote></div><br>