I am currently trying C# scripting and I have error as below when Test.DoThat method is called. If I change the DoThat method to without parameter then it is o.k. Please help.
Microsoft.CodeAnalysis.Scripting.CompilationErrorException: '(1,8): error CS1503: Argument 1: cannot convert from 'Scripting.Device [Scripting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]' to 'Scripting.Device [C:\Users\sheehou\Documents\Code\Scripting\Scripting\bin\Debug\Scripting.exe]''
Here is my program:
using System;
using Microsoft.CodeAnalysis.Scripting;
using Microsoft.CodeAnalysis.CSharp.Scripting;
namespace Scripting
{
public class Device
{
public string GetMessage()
{
return "Device";
}
}
public class Test
{
public void DoThat(Device dev)
{
Console.WriteLine(dev.GetMessage());
}
}
class Program6
{
static void Main(string[] args)
{
var test = new Test();
var options = ScriptOptions.Default.AddReferences(typeof(Test).Assembly);
var state = CSharpScript.RunAsync("", options, test, typeof(Test)).Result;
state = state.ContinueWithAsync("using Scripting;").Result;
state = state.ContinueWithAsync("Device dev = new Device();").Result;
state = state.ContinueWithAsync("DoThat(dev);").Result;
Console.Read();
}
}
}