1
现在我正在解决Web服务器性能测试任务并出现一些小问题。在JavaScript代码和控制台应用程序之间实现通信C#
有一种方法来communication between DHTML and C# code。它在Win应用程序中完美工作,但我需要Console应用程序。 所以我创建简单的测试
的Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CometTest
{
class Program
{
[STAThread]
static void Main(string[] args)
{
Client c = new Client(@"URL");
Console.ReadLine();
Console.WriteLine(c.ToString());
}
}
}
Client.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Security.Permissions;
namespace CometTest
{
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
[System.Runtime.InteropServices.ComVisibleAttribute(true)]
public class Client
{
public WebBrowser browser;
public Client(string host)
{
browser = new WebBrowser();
browser.ObjectForScripting = this;
browser.Navigate(host);
}
public void Notify(String message)
{
Console.WriteLine(message);
}
}
}
在我的JavaScript代码执行我 window.external.Notify( '测试'); ? ,但没有成功:-(
任何建议