Isolating script

32 views
Skip to first unread message

sasik

unread,
Mar 26, 2012, 10:44:34 PM3/26/12
to CS-Script
Hi! I'm quite new to the CS-Script. Please, forgive me if the answer
is extremely obvious - i was looking for some informations for a while
and created some code but I'm not sure if I'm not doing it wrong ;)

I can load and execute scripts and everything works very well. In my
application there are many scripts which
* should have possibility to communicate with each other (they are not
parallel, I'm just launching one script, then another and another).
* will be using some methods from host application.

Actually, second point is much more important. It is simple to make it
working at all, but I would like to "isolate" the script so there
would be only some methods/classes/namespace visible, not entire host
public code. Of course I know, that this is .net and the code will be
always reachable, but I think it would be more elegant way to hide
most of the application code and let the script to access (at least in
a "proper" way) methods which are usefull for scripting.

I was trying with creating separate AppDomain but with no success yet.
Please let me know if AppDomain is the right way to achieve such a
behavior? Any tips are appreciated.

Oleg Shilo

unread,
Mar 26, 2012, 11:59:45 PM3/26/12
to cs-s...@googlegroups.com
You can group you host API into the interface and pass this interface object to the script.

Using (or avoiding) AppDomain is kind of irrelevant.

Cheers, 
Oleg Shilo
--------------------------------------------------------------------------------------------
Internet: http://www.csscript.net
E-Mail: csscript...@gmail.com

sasik

unread,
Mar 27, 2012, 8:23:12 AM3/27/12
to CS-Script
Thanks! That's a good idea with passing API object to the script, but
I wonder, why AppDomain is irrelevant? It looks for me that if I
create new AppDomain, then execute script passing API object,
everything work exactly what I would like. If I wouldn't create
AppDomain, script still can use everything in my host namespace easily
What is wrong with that AppDomain?.

On 27 Mar, 05:59, Oleg Shilo <oleg.sh...@gmail.com> wrote:
> You can group you host API into the interface and pass this interface
> object to the script.
>
> Using (or avoiding) AppDomain is kind of irrelevant.
>
> Cheers,
> Oleg Shilo
> --------------------------------------------------------------------------- -----------------
> Internet:http://www.csscript.net
> E-Mail: csscript.supp...@gmail.com

Oleg Shilo

unread,
Mar 27, 2012, 8:02:19 PM3/27/12
to cs-s...@googlegroups.com
This is because creating a separate domain does not fully protect your default AppDomain from the reflection based access anyway.
Also the remote AppDomain will create some problems for passing non-serializable objects as parameters for your host methods.

But... of course you can use it if it suits you.

Oleg
Reply all
Reply to author
Forward
0 new messages