I have to write an add-in for an existing application. Client will use the application and add-in. Both application and add-in are black boxes for the user. My add-in is a .Net C# dll and User Can Code in C#.
Now I have to provide a mechanism through which user can write some C# code. That code will be loaded and executed by my add-in at runtime in order to get data required in add-in.
What is the best practise to achieve this
Edit
Just to clear a bit more…
In my add-in, during execution, I get a string
Now I want to call some user function
string resultString = UserFunction("SomeString");
Now I want to know how to allow user to write this UserFunction so that I can call it at runtime and get resultString back based on SomeString
Er..this gets a bit tricksy…especially if it has to happen exactly the way you phrased the question.
You can allow the user to pass text c# code to a function in your dll, then basically compile that code into an in-memory assembly, but this seems like a lot of work to allow someone to pass code into an already compiled DLL, in order to be recompiled and ran again.
You can look at the post here for more information on this topic :
http://www.dotnetthoughts.net/2011/01/09/how-to-compile-c-code-snippet-in-runtime/
A better practice would be to only pass DATA into the DLL if you could somehow refactor your application to support that.