【发布时间】:2011-01-14 17:27:30
【问题描述】:
现在我正在解决 Web 服务器性能测试任务,但遇到了一个小问题。
有一种方法可以communication between DHTML and C# code。它在 Win 应用程序中完美运行,但我需要控制台应用程序。 所以我创建了简单的测试
程序.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());
}
}
}
客户端.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('test'); ,但没有成功:-(
有什么建议吗?
【问题讨论】:
标签: c# javascript interop automated-tests comet