c# で記述された私の winforms アプリケーションからいくつかの小さなコードを実行する可能性をユーザーに提供したいと考えています。php を使いたいので Phalanger を見つけました。
フォームに 2 つの richTextEdit を配置し、richTextEdit1 に php を記述し、ボタンを押して、richTextEdit2 に結果を表示したいと考えています。
PHPコードは次のとおりです。
echo "こんにちは!";
ボタンコードは次のとおりです。
ScriptContext context = ScriptContext.CurrentContext;
MemoryStream ms;
StreamWriter sw;
ms = new MemoryStream();
sw = new StreamWriter(ms);
context.Output = sw ;
//context.Output = Console.Out;
var res = DynamicCode.Eval(
richTextBox1.Text,
false,/*phalanger internal stuff*/
context,
null,/*local variables*/
null,/*reference to "$this"*/
null,/*current class context*/
"Default.aspx.cs",/*file name, used for debug and cache key*/
1, 1,/*position in the file used for debug and cache key*/
-1,/*something internal*/
null/*current namespace, used in CLR mode*/
);
richTextBox2.Text = Encoding.UTF8.GetString(ms.ToArray());
Console.Out を出力として使用すると、正常に動作しますが、役に立ちません。そうでなければ、私には結果がありません。
誰でも私を助けることができますか?