2010-07-07 4 views
1

클라이언트 쪽 개체를 .net remoting의 서버 개체에 전달하려면 어떻게해야합니까?클라이언트 생성 된 개체를 서버에 전달 .net remoting

내가 테스트를 수행하는 방법입니다. 내 클라이언트 응용 프로그램에

IChannel channel = new TcpChannel(9988); 
ChannelServices.RegisterChannel(channel,false); 
RemotingConfiguration.RegisteredWellKnownServiceType(typeof(Testing.Server) ,"testremote",WellKnownObjectMode.Singleton); 
RemotingConfiguration.RegisterActivatedServiceType(typeof(Testing.SampleClass)); 
RemotingConfiguration.ApplicationName = "TestRemote"; 

: 내 서버 응용 프로그램에

public interface IServer 
{ 
    bool SubmitMessage(ISampleClass sample); 
} 

[Serializable] 
public Server : MarshalByRefObject , IServer 
{ 
    Public Server() 
    { 
    } 
    public bool SubmitMessage(ISampleClass sample) 
    { 
    return true; 
    } 
} 


public interface ISampleClass 
{ 
    string GetName(); 
} 

[Serializable] 
public class SampleClass : MarshalByRefObject , ISampleClass 
{ 
    public SampleClass() 
    { 
    } 
    public string GetName() 
    { 
    return "test"; 
    } 
} 

: 내 클래스 라이브러리에

Type type = typeof(Testing.Server); 
Testing.IServer server = (Testing.IServer)Activator.GetOject(type,"tcp://localhost:9988/testremote"); 
RemotingConfiguration.RegisteredActivatedClientType(typeof(Testing.SampleClass), "tcp://localhost:9988/TestRemote"); 
Testing.SampleClass test = new Testing.SampleClass(); // proxy class 
server.SubmitMessage(test); // Error here 

내가 encoutered 오류 : 때문에 보안 제한의 의 System.Runtime.Remoting.ObjRef 형식에 액세스 할 수 없습니다. 내부 예외 : 요청하지 못했습니다.

내가 뭘 잘못하고 있는지 말해주십시오. 감사!

답변

0

내가 잘못하고있는 것을 이미 알아 냈습니다. SampleClass는 MarshalByRefObject를 상속하지 않아야합니다.

향후 다른 사람들에게 참조 될 수 있습니다.

관련 문제