c# - Limit namespace access on runtime compiled scripts -


i building sort of modding system aspect of game in unity. allows common user write c# code used give access elements of game @ times, giving host of multiplayer server ability decide map load parameters etc.

for of don't know, unity uses mono's equivalent of .net 2.0, question less specific unity , rather more towards c# , .net.

i have assembly loading working, i've come point nice if give "user" access assemblies such system , unityengine. of course include dll's in referenceassemblies property of compilerparameters, give them access possibly harmful functionality, such reflection, instantiate, destroy many others.

how limit assembly references namespaces, such system.io , system.collections, without giving access system.reflection?

now posting of possibly relevant code:

//excuse unityscript... find quicker things in //it's c# javascript syntax ;)  //create compiler parameters var params:compilerparameters = new compilerparameters(); params.generateexecutable = false; params.generateinmemory = false;  //add assembly reference params.referencedassemblies.add("system.dll"); //i wish put system.io in here instead of system.dll  //create provider , load/compile assembly var provider:codedomprovider = new codedomprovider.createprovider("csharp"); var results:compilerresults = provider.compileassemblyfromfile(params, path); 

i aware of workarounds, such creating wrapper assembly , give them that, save lot of time if able in more direct way.

edit

there library (a set of libraries actually) called nrefactory. have here indepth @ features.

basically can analyse of dll's load @ runtime using nrefactory , create wrappers simple c# program write yourself.

the idea create boilerplate invoke wrappers part of gateway class , process of libraries interested in , populate gateway class.

now have gateway able call every method in question. cut invoke wrappers don't need.

it sounds complicated in reality it's not. i've used approach produce similar on project. nrefactory powerful tool gives amazing possibilities when comes analysing , emitting c# code.

original

from know (which not lot :) ) can't this. simple reason being domain dll , of it's publicly accessible members.

blocking invokes on members not possible without sort of gateway.

implementation of such gateway different story altogether. said take time , effort this.

i don't think limiting use of unityengine idea. cutting relevant unity functionality.

perhaps shouldn't restrict modders in such 'strict' way.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -