Start a new topic

Method overload mismatch - method with 1 parameter of Exception, and other method with 1 string parameter

In C#

public class Log{

  public static void Error(Exception ex){ }

  public static void Error(string msg, Exception ex){ }


Running from Javascript:


will run Error(Exception ex)....

I know i can try guessing which of the Error$1..2 it is, but i want to set the default.

How can that be done?

Since JS has no overload support, DuoCode must add $1, $2 ...

Two ways to control this:

1) Manually apply


[Js(Name="Error")] and [Js(Name="Error$1")]

   on each method.

2) use [Js(RuntimeDispatch=0)] to group methods together and handle them at runtime, for example in mscorlib Math.cs we have:


  [Js(RuntimeDispatch = 0)]
  public extern static float Abs(float value);

  [Js(RuntimeDispatch = 0)]
  public static double Abs(double value)
    return JsMath.abs(value);

  [Js(RuntimeDispatch = 0)]
  public extern static long Abs(long value);

  [Js(RuntimeDispatch = 0)]
  public extern static int Abs(int value);


Hopes this help

Thank you, 

I ended up using 1st approach.

Login or Signup to post a comment