Hi!
I'm trying to load into the evaluator an Assembly produced by CompileAssemblyFromFile, but I can't use the referenced type inside the script. Maybe I'm using a wrong syntaxis?
I put together a simpe example to explain what I'm trying to achieve.
Summer.cs:
using System;
class Summer
{
public int Sum(int a, int b)
{
return a + b;
}
}
Script.cs:
using System;
class Script
{
public int Execute()
{
Summer s = new Summer();
return s.Sum(10, 5);
}
}
Program.cs:
using CSScriptLib;
using System;
namespace CsScript
{
class Program
{
static void Main(string[] _)
{
CSScript.Evaluator.Reset(false); //clear all referenced assemblies
//compile dll
string referencedAssemblyName = CSScript.Evaluator.CompileAssemblyFromFile(@".\Summer.cs", @".\Summer.dll");
//load dll
CSScript.Evaluator.ReferenceAssembly(referencedAssemblyName);
//execute
dynamic script = CSScript.Evaluator.LoadFile(@".\Script.cs");
int result = script.Execute();
Console.WriteLine(result);
}
}
}
Thank you!
Hi!
I'm trying to load into the evaluator an
Assemblyproduced byCompileAssemblyFromFile, but I can't use the referenced type inside the script. Maybe I'm using a wrong syntaxis?I put together a simpe example to explain what I'm trying to achieve.
Summer.cs:
Script.cs:
Program.cs:
Thank you!