I use the CS-Script library to execute dynamic code. Instead of using it as a script engine, I want to use it to incorporate functionality into the application on the fly. Here's the hosting code ...
using System; using CSScriptLibrary; using System.Reflection; using System.IO; namespace CSScriptTester { class Program { static void Main(string[] args) {
And here is the contents of SomeCode / MyScript.cs ...
using System; using System.Windows.Forms; namespace CSScriptTester.SomeCode { class MyScript { public void ExecuteAFunction() { MessageBox.Show("Hello, world!"); } } }
It works great. In the hosting code, I do not want the hosting code to be responsible for specifying assembly links. So I comment on CSScript.Evaluator.ReferenceAssembly(Assembly.GetAssembly(typeof(System.Windows.Forms.MessageBox))); and run it and I get an error ...
error CS0234: Type or namespace name Forms' does not exist in the namespace System.Windows'. Are you missing an assembly link?
I know, if I were doing this using the command line tools, I could add this to the top of the script to add the link ...
But this seems ignored when executed in the context of a .NET application. How can I get it to resolve links correctly?
source share