Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3988428
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:15:02+00:00 2026-05-20T06:15:02+00:00

I am using the DLR within a small part of a larger C# project,

  • 0

I am using the DLR within a small part of a larger C# project, IronPython being the language in question.

For some parts of the system the user is able to enter a small script to customise behaviour for them. What I would like to do is to be able to restrict them to using side-effect free pure functions or in some sort of sandbox so that their function cannot touch anything outside.

Also, the user only can enter a function body, the function header and argument specification is automatically pre-pended in code before being passed to the Python DLR engine so that the C# side of the system that calls it knows exactly the args to pass and what is coming back. The users will only ever require to do simple operations and tests based purely on values supplied as arguments.

e.g.

this is ok: return (a * 100) > b;

this is not ok: delete_file_system(); return (a * 100) > b;

How might this be achieved? Is there a more appropriate language or technology choice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T06:15:03+00:00Added an answer on May 20, 2026 at 6:15 am

    The way to do this is to create a sandboxed app domain and then run the script in the that app domain. You can find directions on creating the sandboxed domain here: http://msdn.microsoft.com/en-us/library/bb763046.aspx

    To run the code in the app domain you can use the Python.CreateEngine overload which accepts an AppDomain. Then all of the code executed in that engine will run in that app domain.

    If you want to have user code call back into your host you can create a class which derives from MarshalByRefObject and put it in the scope for them to access and call back. The calls will go through to your normal app domain and you can do everything you’d normally be able to do.

    There’s also a bunch of APIs on the ObjectOperations and ScriptScope the classes which work with ObjectHandles for performing operations on objects in the remote domain.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Ironpython site exists references to a language called VBx using DLR. But i
I am implementing a language interpreter in C# using the DLR, and I'm having
I'v been looking into using DLR for my toy language, and I'm a bit
I'm working on a small programming language for the Microsoft DLR, and having a
Using the http://www.ifans.com/forums/showthread.php?t=132024 post from another question i am allowing the user to enter
Using online interfaces to a version control system is a nice way to have
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
Using JDeveloper , I started developing a set of web pages for a project
Using C#, I need a class called User that has a username, password, active

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.