MS ScriptControlを使用して、アプリケーションにスクリプトを追加しています。配列を持つスクリプトエンジンに表示されるクラスがある場合を除いて、すべてが正常に機能します。スクリプトから配列要素にアクセスできません。
C#クラスの例:
using System.Runtime.InteropServices;
namespace my_app
{
[ComVisible(true)]
public class test
{
public string this_works = "Hello";
public string[] no_workey = new string[4];
public test()
{
no_workey[0] = "I";
no_workey[1] = "can't";
no_workey[2] = "see";
no_workey[3] = "you!";
}
}
}
クラスをスクリプトエンジンに追加します。
script.AddObject("test", new test(), true);
オブジェクトを印刷するためのいくつかの機能を組み込みました。これが私の結果です:
test.this_works -> "Hello"
test.no_workey -> System.String[]
test.no_workey[0] -> 'test.no_workey.0' is null or not an object.
誰かが私がこれを行う方法を知っていますか?ありがとう!