RegisterWellKnownClientType可以传入不同的参数。

解决方案 »

  1.   

    構造函數有參數的遠程對象,客戶端調用只能用Activator.CreateInstance(...)來創建本地引用副本,不能夠用new.
    這和激活類型沒有關係
      

  2.   

    From MSDN==========================================================
    ObjectHandle            hdlSample;
    IMyExtenderInterface    myExtenderInterface;
    string                  argOne = "Value of argOne";
    int                     argTwo = 7;
    object[]                args = {argOne, argTwo};
    // Uses the UrlAttribute to create a remote object.
    object[]                activationAttributes = {new UrlAttribute("http://localhost:9000/MySampleService")};
    // Activates an object for this client.
    hdlSample = Activator.CreateInstance("SampleAssembly",
                                         "samplenamespace.sampleclass", 
                                         true,
                                         BindingFlags.Instance|BindingFlags.Public,
                                         null,
                                         args,
                                         null,
                                         activationAttributes,
                                         null);
    myExtenderInterface = (IMyExtenderInterface)hdlSample.Unwrap();
    Console.WriteLine(myExtenderInterface.SampleMethod("Bill"));