PDA

View Full Version : Cầu cứu lỗi trong .NET Remoting



tony22
06-07-2009, 18:28
Hiện giờ mình đã tìm ra được lỗi do transServer trong .NET Remoting gây ra,khi mình start transServer trên cmd thì nó báo lỗi như thế này:

F:\Q8 Pro1 case 2\Pro1_Q8\NewTechBooks\TransServer\bin\Debug>TransServer
at System.Configuration.ClientConfigurationSystem.Ens ureInit(String configKey
)
at System.Configuration.ClientConfigurationSystem.Sys tem.Configuration.Intern
al.IInternalConfigSystem.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.GetSecti on(String sectionName)
at System.Configuration.PrivilegedConfigurationManage r.GetSection(String sect
ionName)
at System.Net.Configuration.SettingsSectionInternal.g et_Section()
at System.Net.Sockets.Socket.InitializeSockets()
at System.Net.Sockets.Socket.get_SupportsIPv4()
at System.Runtime.Remoting.Channels.Tcp.TcpServerChan nel..ctor(Int32 port)
at System.Runtime.Remoting.Channels.Tcp.TcpChannel..c tor(Int32 port)
at TransServer.Program.Main(String[] args) in F:\Q8 Pro1 case 2\Pro1_Q8\NewTe
chBooks\TransServer\Program.cs:line 18

Mình biết rằng trong file transServer.cs đã bị lỗi nhưng mình không biết phải sứa như thế nào,đây là code transServer.cs:

using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using RemoteObject;

namespace TransServer
{
class Program
{
static void Main(string[] args)
{
try
{
//Server Register Remote Object
ChannelServices.RegisterChannel(new TcpChannel(5555),false);
RemotingConfiguration.RegisterWellKnownServiceType (typeof(MyTrans), "TransMesg", WellKnownObjectMode.SingleCall);
Console.WriteLine("Remote Object Successful ! ");
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine(ex.StackTrace);
}
}
}
}

mong các bạn giúp đỡ.Mình cám ơn rất nhiều!!