EDIT: I found the answer (using Tejs); see below.
I am developing a Metro application using HTML / Javascript, as well as some helper libraries in C #. Generally speaking, I have a lot of success calling C # methods from Javascript, but I can't get the transfer arrays (in my particular case, string arrays) to work. Passing single lines without problems.
My code looks something like this:
// in javascript project var string1 = ...; var string2 = ...; var string3 = ...; var result = MyLibrary.MyNamespace.MyClass.foo([string1, string2, string3]);
Then in C #:
// in C
The problem is that the "Foo" method gets an array with the correct length (therefore, in the above example, 3), but all the elements are empty. I also tried this:
public static string Foo(object[] strings) { ...
That didn't work either - the array was correct, but all elements were null.
I tried passing string literals, string variables using "new Array (...)" in javascript, changing the signature of "Foo" to "params string []" and "params object []", all to no avail.
Since passing single lines works fine, I can probably get around this with some hackers ... but it looks like this should work. It seems strange to me that the array is passed as the correct size (i.e., everything that marshaling does knows SOMETHING about the structure of the javascript array), and yet the contents are not populated.
javascript c # windows-8 windows-runtime
atkretsch
source share