Callback type not supported: System.Func`1[TResult]: Interop.ExecuteJavaScript("value=$0()", (Func<TResult>)myMethod)

Please post public support tickets here. Note: for private support tickets, please send an email to support@cshtml5.com instead.
TaterJuice
Posts: 147
Joined: Thu Mar 16, 2017 5:40 am
Contact:

Callback type not supported: System.Func`1[TResult]: Interop.ExecuteJavaScript("value=$0()", (Func<TResult>)myMethod)

Postby TaterJuice » Thu Aug 24, 2017 1:33 pm

I understand I can call a C# function from JS interop by calling

Code: Select all

Interop.ExecuteJavaScript("$0()", (Action)myCSMethod)


However, I need to be able to return a string, or an array, from my CS Function, so I tried replacing "Action" with "Func<string>" as seen below, but I receive the following error.

Code: Select all

Interop.ExecuteJavaScript("alert($0())", (Func<string>)myGetStringFunction)

Image

How do I pass a Value-Function, not an Action or void, to JS Interop?

JS-Support @Userware
Site Admin
Posts: 1142
Joined: Tue Apr 08, 2014 3:42 pm

Re: Callback type not supported: System.Func`1[TResult]: Interop.ExecuteJavaScript("value=$0()", (Func<TResult>)myMethod

Postby JS-Support @Userware » Fri Aug 25, 2017 1:44 am

Hi,

Thank you. It appears to be a Simulator issue. Does it work properly in the browser? We are going to look into it and keep you updated.

Regards
JS-Support

TaterJuice
Posts: 147
Joined: Thu Mar 16, 2017 5:40 am
Contact:

Re: Callback type not supported: System.Func`1[TResult]: Interop.ExecuteJavaScript("value=$0()", (Func<TResult>)myMethod

Postby TaterJuice » Fri Aug 25, 2017 7:56 am

No, I can't get it to work in the browser, I'm not sure if that problem is related, but when I try to run my JS output, I receive the following CONSOLE errors:

Code: Select all

JSIL.Browser.js?20178250855:201 Error: The function 'System.Void Vivrant.CSHTML5.WeatherPanel.WeatherPanelControlTemplate/<>c__DisplayClass8_0::<UpdateJSParticleConfig>b__1()' could not be translated.
    at Vivrant_CSHTML5_WeatherPanel_WeatherPanelControlTemplate_$l$gc__DisplayClass8_0.UntranslatableFunctionInvoked (JSIL.Core.js?20178250855:1228)
    at Delegate_Invoke (JSIL.Core.js?20178250855:9344)
    at CSharpXamlForHtml5.js?20178250855:55975
JSIL.Browser.WarningService.write @ JSIL.Browser.js?20178250855:201
JSIL.Browser.js?20178250855:199 Error: The function 'System.Void Vivrant.CSHTML5.WeatherPanel.WeatherPanelControlTemplate/<>c__DisplayClass8_0::<UpdateJSParticleConfig>b__1()' could not be translated.
    at Vivrant_CSHTML5_WeatherPanel_WeatherPanelControlTemplate_$l$gc__DisplayClass8_0.UntranslatableFunctionInvoked (JSIL.Core.js?20178250855:1228)
    at Delegate_Invoke (JSIL.Core.js?20178250855:9344)
    at CSharpXamlForHtml5.js?20178250855:55975
JSIL.Browser.WarningService.write @ JSIL.Browser.js?20178250855:199
JSIL.Host.js?20178250855:240 Uncaught Error: The function 'System.Void Vivrant.CSHTML5.WeatherPanel.WeatherPanelControlTemplate/<>c__DisplayClass8_0::<UpdateJSParticleConfig>b__1()' could not be translated.
    at Vivrant_CSHTML5_WeatherPanel_WeatherPanelControlTemplate_$l$gc__DisplayClass8_0.UntranslatableFunctionInvoked (JSIL.Core.js?20178250855:1228)
    at Delegate_Invoke (JSIL.Core.js?20178250855:9344)
    at CSharpXamlForHtml5.js?20178250855:55975

TaterJuice
Posts: 147
Joined: Thu Mar 16, 2017 5:40 am
Contact:

Re: Callback type not supported: System.Func`1[TResult]: Interop.ExecuteJavaScript("value=$0()", (Func<TResult>)myMethod

Postby TaterJuice » Tue Aug 29, 2017 8:20 am

This seems to be very "finicky".... I think part of my problem is this line:

Code: Select all

Interop.LoadJavascriptFile(@"https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"");


This line works, but produces the "Non-Translatable Function" error when run in the browser.


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 3 guests

 

 

cron