.NET IE BHO 远程处理

发布于 2024-08-11 08:08:53 字数 1729 浏览 6 评论 0原文

我有一个 IE 浏览器帮助程序对象,它是 IE 8 的工具栏插件。 我有另一个 .NET .EXE 应用程序(远程客户端),它通过通用接口使用远程处理连接到此 BHO(远程服务器)。 当我使用服务器组件中使用的相同代码测试 .EXE 应用程序和 TEMP Console 应用程序之间的通信时,它通信良好,并运行远程方法。

但是,当我尝试在 TCP 通道 ON ChannelServices.RegisterChannel(tcpClientChannel, true); 上安全地与 BHO 服务器进行通信时; ,我收到“FileNotFoundException”无法加载文件或程序集“xxxx”,其中“xxxx”是包含服务器方法的通用接口程序集。

当我尝试与 BHO 服务器进行通信时,TCP 通道上的安全性关闭 ChannelServices.RegisterChannel(tcpClientChannel, false); ,我收到错误“与远程对象的连接被强制关闭”。

如果我用简单的测试控制台应用程序重新测试它,它就可以工作。

我开始相信问题出在 BHO 实例内远程处理的工作方式...是否有人在 BHO .NET 实例中使用过远程处理,我使用 SPICIE 库来使用 .NET 创建 BHO。

远程接口对象的 COMMON 接口组件 命名空间 WWie.CommonClasses { WWieRemote 类:MarshalByRefObject、WWieClassLibrary.WWieCommonClass.IGetHtmlElement { 公共字符串 GetElementClicked() { return ("从 WWieRemote 返回"); }

    public void SetElementClicked(string str)
    {
        MessageBox.Show("SetElement " + str);
    }

}

}

客户端应用程序 静态 TcpChannel tcpClientChannel = new TcpChannel(); 公共静态 WWieClassLibrary.WWieCommonClass.IGetHtmlElement 远程对象; ChannelServices.RegisterChannel(tcpClientChannel, false); RemoteObject = (WWieClassLibrary.WWieCommonClass.IGetHtmlElement)Activator.GetObject(typeof(WWieClassLibrary.WWieCommonClass.IGetHtmlElement), "tcp://localhost:9002/TestWWie");

使用远程方法调用

    remoteObject.SetElementClicked("from Client");   

SERVER BHO 进行测试 TcpChannel tcpServerChannel = 新的 TcpChannel(9002); ChannelServices.RegisterChannel(tcpServerChannel, true); RemotingConfiguration.RegisterWellKnownServiceType(typeof(WWieClassLibrary.WWieCommonClass.IGetHtmlElement), "TestWWie", WellKnownObjectMode.Singleton);

I have a IE Browser Helper Object, which is a Toolbar addin for IE 8.
I have another .NET .EXE application (Remoting Client) that connects to this BHO (Remoting Server) using remoting via common Interface.
When I test the communication between the .EXE application and a TEMP Console application with the same code used in the Server component, it communicates fine, and runs the remote Method.

However, when i try and communicate with the BHO server with security on the TCP cahannel ON ChannelServices.RegisterChannel(tcpClientChannel, true); , I get a "FileNotFoundException" Could not load file or assembly "xxxx" which "xxxx" is the common Interface assembly that contains the Server Methods.

When i try and communicate with the BHO server with security on the TCP cahannel OFF ChannelServices.RegisterChannel(tcpClientChannel, false); , I get error "connection to the remote object was forcably closed".

If I re-test it with the simple test console app it work.

Im starting to believe the problem is with the way remoting works inside a BHO instance... Has anyone used Remoting in a BHO .NET instance, Im using the SPICIE library to create the BHO using .NET.

COMMON Interface assembly for Remoting Interface Object
namespace WWie.CommonClasses
{
class WWieRemote : MarshalByRefObject, WWieClassLibrary.WWieCommonClass.IGetHtmlElement
{
public string GetElementClicked()
{
return ("Returned from WWieRemote ");
}

    public void SetElementClicked(string str)
    {
        MessageBox.Show("SetElement " + str);
    }

}

}

CLIENT APP
static TcpChannel tcpClientChannel = new TcpChannel();
public static WWieClassLibrary.WWieCommonClass.IGetHtmlElement remoteObject;
ChannelServices.RegisterChannel(tcpClientChannel, false);
remoteObject = (WWieClassLibrary.WWieCommonClass.IGetHtmlElement)Activator.GetObject(typeof(WWieClassLibrary.WWieCommonClass.IGetHtmlElement), "tcp://localhost:9002/TestWWie");

testing with remote method call

    remoteObject.SetElementClicked("from Client");   

SERVER BHO
TcpChannel tcpServerChannel = new TcpChannel(9002);
ChannelServices.RegisterChannel(tcpServerChannel, true);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(WWieClassLibrary.WWieCommonClass.IGetHtmlElement), "TestWWie", WellKnownObjectMode.Singleton);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

顾北清歌寒 2024-08-18 08:08:53

由于 IE 默认在保护模式下运行,因此它通常无权与更高完整性的进程进行通信。如果您的 url 位于 Intranet 区域中,您可以推送禁用 Intranet 区域保护模式的策略。
否则,您可能需要寻找其他选项,例如共享内存、命名管道、隐藏工作窗口和共享内存。注册消息& Vista的UIPI等定制的消息过滤器

Since IE is running in protected mode by default, it usually doesn't have access to communicate with higher integrity processes. If your url is in the intranet zone, you can push a policy that disable protected mode for the intranet zone.
Otherwise you may want to look for other options, like shared memory, named pipe, hidden worker windows & registered messages & customized message filter for Vista's UIPI, etc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文