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( '測試'); ? ,但沒有成功:-(
任何建議