【发布时间】:2016-06-06 12:41:19
【问题描述】:
我正在为 Cordova 项目开发插件。我有一个项目来构建我的 Windows 运行时组件。我正在尝试将字典传递给我的 javascript 代码。如果我使用 bool 或 int,这可以正常工作,但如果我使用更复杂的对象类型,则会出现错误。这是我在 c# 中的插件的代码。
public static IAsyncOperation<IDictionary<string, int>> doTestFunction()
{
return TestFunction().AsAsyncOperation();
}
private static async Task<IDictionary<string, int>> TestFunction()
{
IDictionary<string, int> testDictionary = new Dictionary<string, int>();
testDictionary.Add("value1", 1);
testDictionary.Add("value2", 1);
return testDictionary;
}
这是我的 javascript 调用。
BLEComm.doTestFunction(
function (res) {
if (res) {
console.log("it didn't completely fail");
} else {
alertOpen("it kind of failed");
}
},
function (err) {
console.log("failure" + err);
}
);
我的错误记录到我的控制台:
failureWinRTError:找不到与此错误代码关联的文本。
ComTypeMarshalling_MissingInteropData index.js (225,17)
同样,如果我只返回一个 int 或 bool,我没有任何问题。我已经搜索和搜索,无法弄清楚出了什么问题。
【问题讨论】:
标签: javascript c# cordova plugins