views:

238

answers:

1

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);

A: 

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.

Sheng Jiang 蒋晟
Appologies I forgot to mention the client and server are running on the same machine, so the url is tcp://localhost:9002/Servicename
PrimeTSS
This is the error Im gettingSystem.Net.Sockets.SocketException was unhandled Message="An existing connection was forcibly closed by the remote host" Source="mscorlib" ErrorCode=10054 NativeErrorCode=10054executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:
PrimeTSS
Netstat -a shows the port as listening, and I have turned off firewall and added local host to trusted sites
PrimeTSS
that's a network layer exception, not a security exception. Some firewalls would block your first try to give the users a choice to block you, check if you have other firewall software installed.
Sheng Jiang 蒋晟
Thanks for that, but if I run the Console test App on the same machine it works fine, if it was firewall I would have thought the test Console Application would have the same problem.Im sure its an issue running the remoting in a BHO??
PrimeTSS
Check is the server is listening to incoming connections. you can install netmon to see how the server terminates the connection. There could be a one-time exception when the server restarts.
Sheng Jiang 蒋晟