ArgumentNullException от IpcClientChannel - Имя параметра: URI - PullRequest
0 голосов
/ 05 января 2011

Когда я пытаюсь запустить любой метод или прочитать параметр объекта, я получаю 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 Ответ

1 голос
/ 06 января 2011

Duh!Проблема в неправильном URL, отсутствует URI.

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