0
Answer

look at this problem _ the .net remoting problem,HELP ME

eric_pion

eric_pion

20y
1.4k
1
I have designed a c/s solution with .net remoting technology.Look at the codes,the solution is OK in .net framework 1.0 ,but in .net framework 1.1,the client cannot create remote object ,and the system send me a message that the exception is System.Reflection.TargetInvocationException. I only used the soapsuds.exe to create the RemoteObject.dll from RemoteServer.exe, and used it in RemoteClient. Please help me,thank you very much. The Codes: RemoteServer is a ConsoleApplication and have two files :RemoteServer.cs and RemoteObject.cs . RemoteObject.cs: using System; using System.Collections; namespace RemoteServer { [Serializable] public class RemoteObject:System.MarshalByRefObject { public string SayHello(string m_instr) { Console.WriteLine("Hello World:"+m_instr); return ("Remote:"+m_instr); } } } RemoteServer.cs using System; using System.Runtime.Remoting.Channels.Tcp; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting; namespace RemoteServer { class RemoteServer { public RemoteObject remoteObj = new RemoteObject(); [STAThread] static void Main(string[] args) { TcpChannel channel = new TcpChannel(8088); ChannelServices.RegisterChannel(channel); System.Runtime.Remoting.RemotingConfiguration.RegisterActivatedServiceType(typeof(RemoteObject)); System.Runtime.Remoting.RemotingConfiguration.ApplicationName = "Service"; Console.ReadLine(); } } } the client is a windows application and it used the RemoteObject.dll which is create by soapsuds.exe as "Soapsuds -Types:RemoteServer.RemoteObject,RemoteServer,-oa:RemoteObject.dll -gc". the client only has a form and a button.After clicked the button ,it will do: private void button1_Click(object sender, System.EventArgs e) { try { TcpChannel channel = new TcpChannel(); ChannelServices.RegisterChannel(channel); ObjectHandle handle = Activator.CreateInstance("RemoteObject","RemoteServer.RemoteObject",new object[]{new UrlAttribute("tcp://localhost:8088/Service")}); RemoteServer.RemoteObject obj = (RemoteServer.RemoteObject)handle.Unwrap(); obj.SayHello("oK"); MessageBox.Show("OK"); } catch(Exception ex) { MessageBox.Show(ex.Message + ex.GetType().ToString()); } } in .net 2002 it shows OK ,but in .net 2003 it shows the error.