IpcClientChannel的ArgumentNullException - 参数名称:URI

时间:2011-01-05 19:02:23

标签: c# .net ipc

当我尝试运行任何方法或读取对象的参数时,我得到ArgumentNullException。该对象有一个来自IpcServerChannel的实例。我该如何处理?

客户端

IDictionary prop = new Hashtable();
prop["name"] = "remote";
prop["portName"] = "connector";
prop["tokenImpersonationLevel"] = TokenImpersonationLevel.Impersonation;
prop["secure"] = true;

IpcClientChannel clientChannel = new IpcClientChannel(prop, null);
ChannelServices.RegisterChannel(clientChannel, true);

RemotingConfiguration.RegisterWellKnownClientType(typeof(Connector), "ipc://connector");

Connector c = new Connector();
c.Connect(); /* ArgumentNullException - Value cannot be null. Parameter name: URI */

服务器

BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

IDictionary prop = new Hashtable();
prop["name"] = "remote";
prop["portName"] = "connector";
prop["tokenImpersonationLevel"] = TokenImpersonationLevel.Impersonation;
prop["secure"] = true;
prop["authorizedGroup"] = new SecurityIdentifier("S-1-1-0").Translate(typeof(NTAccount)).ToString(); /* Everyone or Todos =p */

// Create and register an IPC channel
IpcServerChannel serverChannel = new IpcServerChannel(prop, serverProvider);
ChannelServices.RegisterChannel(serverChannel, true);

// Expose an object
RemotingConfiguration.RegisterWellKnownServiceType(typeof(Connector), "connector", WellKnownObjectMode.Singleton);

调用堆栈

  

Test.exe!Test.Program.Main()第39行C#       [外部代码]

System.ArgumentNullException was unhandled
  Message=Value cannot be null.
Parameter name: URI
  Source=mscorlib
  ParamName=URI
  StackTrace:
    Server stack trace: 
       at System.Runtime.Remoting.IdentityHolder.ResolveIdentity(String URI)
       at System.Runtime.Remoting.Messaging.InternalSink.GetServerIdentity(IMessage reqMsg)
       at System.Runtime.Remoting.Channels.ChannelServices.CheckDisconnectedOrCreateWellKnownObject(IMessage msg)
       at System.Runtime.Remoting.Channels.ChannelServices.DispatchMessage(IServerChannelSinkStack sinkStack, IMessage msg, IMessage& replyMsg)
    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at Vex_Connector_Service.Connector.Connect()
       at Vex_Connector_Client.Program.Main() in C:\Users\Vex\Desktop\Final Vex Connector\Vex Connector\Vex Connector Client\Program.cs:line 39
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

1 个答案:

答案 0 :(得分:1)