rporo...@gmail.com
unread,Jul 27, 2012, 9:33:11 AM7/27/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to cs-s...@googlegroups.com
I was first playing around with CS-Script in LinqPad (it's my scratchpad of choice) and encountered an exception that didn't make sense. So I thought I'd throw it in here to see if there's a behind-the-scenes explanation for it. :) Up front, I would have expected Simplified Hosting Model to cover the scenario the exception seems to be thrown for (hope that sentence made sense).
Using the CS-Script binaries pulled on 2012-07-26. Targeting .NET Framework v3.5 (though I have up through v4.0 installed as well). LinqPad v4.42.01 operating in C# Program mode. Code is:
void Main()
{
var addScript = CSScript.LoadCode(
@"
using System;
public class Script
{
public int Add(int a, int b)
{
return a + b;
}
}
")
.CreateInstance("Script")
.AlignToInterface<ICalc>();
addScript.Add(1, 2).Dump();
}
public interface ICalc
{
int Add(int a, int b);
}
The exception I'm getting is
Message: Error compiling proxy class:
15 CS0012 The type
'LINQPad.User.TypedDataContext' is defined in an assembly that is not
referenced. You must add a reference to assembly 'TypedDataContext_vphdoz,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
Source: CSScriptLibrary.v3.5
StackTrace:
at
CSScriptLibrary.ThirdpartyLibraries.Rubenhak.Utils.ObjectCaster`1.BuildProxyClass(Type
interfaceType, Type sourceType, String[] refAssemblies)
at
CSScriptLibrary.ThirdpartyLibraries.Rubenhak.Utils.ObjectCaster`1.CastToInterface(Type
interfaceType, Object o, String[] refAssemblies)
at
CSScriptLibrary.ThirdpartyLibraries.Rubenhak.Utils.ObjectCaster`1.As(Object o,
String[] refAssemblies)
at
CSScriptLibraryExtensionMethods.TryAlignToInterface[T](Object obj)
at
CSScriptLibraryExtensionMethods.AlignToInterface[T](Object obj)