OYIon / LiveSharp

Public repository for the LiveSharp project
96 stars 4 forks source link

System.ArgumentException: Expression of type 'System.Object' cannot be #80

Closed wocar closed 4 years ago

wocar commented 4 years ago

Im getting this error on the latest version

System.ArgumentException: Expression of type 'System.Object' cannot be used for parameter of type 'System.String' of method 'Void AddContent(Int32, System.String)' (Parameter 'arg1')
   at System.Dynamic.Utils.ExpressionUtils.ValidateOneArgument(MethodBase method, ExpressionType nodeKind, Expression arguments, ParameterInfo pi, String methodParamName, String argumentParamName, Int32 index)
   at System.Linq.Expressions.Expression.Call(Expression instance, MethodInfo method, Expression arg0, Expression arg1)
   at System.Linq.Expressions.InstanceMethodCallExpression2.Rewrite(Expression instance, IReadOnlyList`1 args)
   at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node)
   at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
   at LiveSharp.Runtime.IL.StackSlotSubstituteVisitor.Visit(Expression node)
   at LiveSharp.Runtime.IL.CompilerContext.Substitut
wocar commented 4 years ago

Managed to detect the offending code, removing it from my .razor makes livesharp work

@if (_connection?.State != HubConnectionState.Connected)
{
    <p>
        Status:
        <label data-toggle="tooltip" data-placement="top" title="@ConnectionId">
            @(_connection?.State.ToString() ?? "Connecting")
        </label>

    </p>
}