C# 事件和IPCServerChannel引发TargetInvocationException

C# 事件和IPCServerChannel引发TargetInvocationException,c#,events,remoting,ipc,C#,Events,Remoting,Ipc,对于一些奇怪的问题,当我尝试使用事件和IPC远程处理时,我得到了这些异常,这将是重点?有人有这个问题吗 客户 服务器 例外 无法加载文件或程序集“Vex连接器客户端,…” 对于远程应用程序来说,这是一种非常标准的错误,它只是找不到程序集。确保它在那里,最好是在与exe相同的目录中。如果无法诊断找不到程序集的原因,请使用Fuslogvw.exe fuslogvw痕迹清楚地显示了问题。服务器正在其自己的目录Final vex connector/vex connector/vex connector

对于一些奇怪的问题,当我尝试使用事件和IPC远程处理时,我得到了这些异常,这将是重点?有人有这个问题吗

客户 服务器 例外 无法加载文件或程序集“Vex连接器客户端,…”

对于远程应用程序来说,这是一种非常标准的错误,它只是找不到程序集。确保它在那里,最好是在与exe相同的目录中。如果无法诊断找不到程序集的原因,请使用Fuslogvw.exe

fuslogvw痕迹清楚地显示了问题。服务器正在其自己的目录Final vex connector/vex connector/vex connector Service中查找vex connector client.exe/ bin/Debug/。但是文件不在那里,它存储在Final Vex Connector/Vex Connector/Vex Connector Client/bin/Debug中/

复制该文件以修复该问题


如果您觉得服务器需要client.exe令人不快,请将它们共享的类放在单独的项目中。

除非您停留在.NET 2.0或更低版本,否则不应使用远程处理。它已经被弃用,取而代之的是WCF。我在这个程序中找不到任何问题。我有两个不同的应用程序:客户端和服务器。服务器编译是否也依赖于客户端?我是否需要处理事件的循环依赖项?如何为此配置Visual Studio?这是一个部署问题。任何包含连接器类的程序集都需要同时存在于服务器和客户端目录中。因为该类在这两种情况下都使用。你可能想把它放在它自己的程序集中。为什么我在调用事件时会遇到这个问题?方法正常运行。我同意,这是一个部署问题,但是你在连接器类中吗?如果你不能解决它,请发布fuslogvw.exe跟踪。没有失败的绑定记录在该类中。没有任何服务器绑定的迹象。
BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();

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

IpcClientChannel clientChannel = new IpcClientChannel(prop, clientProvider);
ChannelServices.RegisterChannel(clientChannel, true);
RemotingConfiguration.RegisterWellKnownClientType(typeof(Connector), "ipc://connector/connector");

Connector c = new Connector();
c.OnX += new Connector.X(c_OnX);
c.Connect();
BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

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

// 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);
System.Reflection.TargetInvocationException was unhandled
  Message=Exception has been thrown by the target of an invocation.
  Source=mscorlib
  StackTrace:
    Server stack trace: 
       at System.RuntimeMethodHandle._SerializationInvoke(IRuntimeMethodInfo method, Object target, SignatureStruct& declaringTypeSig, SerializationInfo info, StreamingContext context)
       at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)
       at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)
       at System.Runtime.Serialization.ObjectManager.DoFixups()
       at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
       at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
       at System.Runtime.Remoting.Channels.CoreChannel.DeserializeBinaryRequestMessage(String objectUri, Stream inputStream, Boolean bStrictBinding, TypeFilterLevel securityLevel)
       at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)
    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.add_OnX(X value)
       at Vex_Connector_Client.Program.Main() in C:\Users\Vex\Desktop\Final Vex Connector\Vex Connector\Vex Connector Client\Program.cs:line 37
       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: System.IO.FileNotFoundException
       Message=Could not load file or assembly 'Vex Connector Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. O sistema não pode encontrar o arquivo especificado.
       Source=mscorlib
       FileName=Vex Connector Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
       FusionLog=WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

       StackTrace:
            at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
            at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
            at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
            at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
            at System.Reflection.Assembly.Load(String assemblyString)
            at System.Runtime.Serialization.FormatterServices.LoadAssemblyFromString(String assemblyName)
            at System.Reflection.MemberInfoSerializationHolder..ctor(SerializationInfo info, StreamingContext context)
       InnerException: