3

The problem (and some unnecessary information): I am creating a chat bot in C# (not chatterbot), and want users to be able to run custom code on the bot. Basically, you send a string message over the network, and the bot runs the code contained in it.

I have looked into and actually implemented/used CSharpCodeProvider, however, this has the problem of every time custom code is compiled, it adds another Assembly to the AppDomain (which is impossible to remove). When you take into account that tens or hundreds of separate custom code invokes may occur in a single lifetime, this becomes a problem.

My idea is that there might be a interpreted language or some such thing that is able to be invoked from C#.

0

1 Answer 1

2

You can remove an assembly if you remove the entire appdomain. So you could create a fresh appdomain, load the assembly there (or compile it from there) and dispose of it after use.

You could recycle the appdomain every 100 statements or so in order to amortize the (small) time it takes to cycle one.

Sign up to request clarification or add additional context in comments.

2 Comments

Could you link me a tutorial to create an appdomain and compile code into it? I don't know what to google for, all my previous searches have turned up nothing.
Googling for ".net create appdomain assembly compile" turns up stackoverflow.com/questions/3512931/… among others which might be helpful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.