You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you run the following console application by using the latest version of Jurassic (e0d652b):
usingSystem;usingSystem.Text;usingJurassic;namespaceTestJurassicInterop{classProgram{staticvoidMain(string[]args){varfileManager=newFakeFileManager();varbase64Encoder=newBase64Encoder();varengine=newScriptEngine{EnableExposedClrTypes=true};engine.SetGlobalValue("fileManager",fileManager);engine.SetGlobalValue("base64Encoder",base64Encoder);stringresult=engine.Evaluate<string>("base64Encoder.EncodeToBase64(fileManager.ReadBinaryFile('0.gif'))");Console.WriteLine("result = {0}",result);}/// <summary>/// Fake file manager/// </summary>internalsealedclassFakeFileManager{/// <summary>/// Opens a binary file, reads all content of the file, and then closes the file/// </summary>/// <param name="path">The file to open for reading</param>/// <returns>The byte array containing all content of the file</returns>publicbyte[]ReadBinaryFile(stringpath){if(path==null){thrownewArgumentNullException("path");}varbytes=newbyte[]{71,73,70,56,57,97,1,0};returnbytes;}}/// <summary>/// Base64 encoder/// </summary>internalsealedclassBase64Encoder{/// <summary>/// Encodes a text content to Base64/// </summary>/// <param name="value">Text content</param>/// <returns>Base64 encoded content</returns>publicstringEncodeToBase64(stringvalue){if(value==null){thrownewArgumentNullException("value");}byte[]bytes=Encoding.GetEncoding(0).GetBytes(value);stringencodedValue=Convert.ToBase64String(bytes);returnencodedValue;}/// <summary>/// Encodes a binary content to Base64/// </summary>/// <param name="value">Binary content</param>/// <returns>Base64 encoded content</returns>publicstringEncodeToBase64(byte[]value){if(value==null){thrownewArgumentNullException("value");}stringencodedValue=Convert.ToBase64String(value);returnencodedValue;}}}}
Then following error occurs:
Unhandled Exception: Jurassic.JavaScriptException: TypeError: The method call is ambiguous between the following methods: System.String EncodeToBase64(System.String), System.String EncodeToBase64(Byte[])
at Jurassic.Compiler.BinderUtilities.ResolveOverloads(RuntimeMethodHandle[] methodHandles, ScriptEngine engine, Object thisValue, Object[] arguments)
at binder_for_TestJurassicInterop.Program+Base64Encoder.EncodeToBase64(ScriptEngine , Object , Object[] )
at Jurassic.Compiler.Binder.Call(ScriptEngine engine, Object thisObject, Object[] arguments)
at Jurassic.Library.ClrFunction.CallLateBound(Object thisObject, Object[] arguments)
at Jurassic.Library.FunctionInstance.CallWithStackTrace(String path, String function, Int32 line, Object thisObject, Object[] argumentValues)
at eval(ScriptEngine , Scope , Object )
at Jurassic.Compiler.EvalMethodGenerator.Execute(ScriptEngine engine)
at Jurassic.ScriptEngine.Evaluate(ScriptSource source)
at TestJurassicInterop.Program.Main(String[] args) in c:\temp\TestJurassicInterop\TestJurassicInterop\Program.cs:line 22
Similar code worked for many years until changes were made to CLR interop (5b83b3b).
The text was updated successfully, but these errors were encountered:
Hello, Paul!
If you run the following console application by using the latest version of Jurassic (e0d652b):
Then following error occurs:
Similar code worked for many years until changes were made to CLR interop (5b83b3b).
The text was updated successfully, but these errors were encountered: