简体   繁体   English

事件和IPCServerChannel引发TargetInvocationException

[英]Events and IPCServerChannel throws TargetInvocationException

For some bizarre problem when I try to use Events and IPC Remoting am getting these exceptions, which would be the point? 对于一些奇怪的问题,当我尝试使用“事件”和“ IPC远程处理”时,正在获取这些异常,这将是重点吗? Has anyone had this problem? 有人遇到过这个问题吗?

Client 客户

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();

Server 服务器

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);

Exception 例外

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: 

Could not load file or assembly 'Vex Connector Client,...' 无法加载文件或程序集“ Vex Connector客户端,...”

Pretty standard kind of error for a Remoting app, it just can't find the assembly. 对于Remoting应用程序,这是一种非常标准的错误,只是找不到程序集。 Make sure it's there, preferably in the same directory as the exe. 确保它在那里,最好与exe位于同一目录中。 Use Fuslogvw.exe if you have trouble diagnosing the reason it cannot find the assembly. 如果无法诊断无法找到程序集的原因,请使用Fuslogvw.exe。


The fuslogvw traces show the problem clearly. fuslogvw痕迹清楚地表明了问题。 The server is looking for "vex connector client.exe" in its own directory, Final Vex Connector/Vex Connector/Vex Connector Service/ bin/Debug/. 服务器正在其自己的目录“最终Vex连接器/ Vex连接器/ Vex连接器服务/ bin / Debug /”中查找“ vex连接器client.exe”。 But the file isn't there, it is stored in Final Vex Connector/Vex Connector/Vex Connector Client/bin/Debug/ 但是文件不存在,它存储在Final Vex Connector / Vex Connector / Vex Connector Client / bin / Debug /

Copy the file to fix the problem. 复制文件以解决问题。

If you find it distasteful that the server needs the client.exe then put the classes they share in a separate project. 如果发现服务器需要client.exe令人讨厌,则将它们共享的类放在单独的项目中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 反序列化JSON会引发TargetInvocationException - Deserializing JSON throws TargetInvocationException WPF调度程序抛出TargetInvocationException - WPF Dispatcher throws TargetInvocationException 使用 WebClient DownloadStringAsync 下载时抛出 TargetInvocationException - Throws TargetInvocationException when downloading with WebClient DownloadStringAsync XMLSerializer正确序列化,但是在反序列化时抛出TargetInvocationException - XMLSerializer serializes correctly, but throws TargetInvocationException when deserialzing 从BackgroundWorker.DoWork返回引发TargetInvocationException - Return from BackgroundWorker.DoWork throws TargetInvocationException TargetInvocationException? - TargetInvocationException? 在Mono中使用LINQ插入Sqlite数据库会引发TargetInvocationException和SqliteException - Inserting into an Sqlite database with LINQ in Mono throws TargetInvocationException and SqliteException 调试时,工作中的.net远程项目会引发System.Reflection.TargetInvocationException - Working .net remoting project throws System.Reflection.TargetInvocationException when debugging NAnt停止在Windows Server 2012上工作,并引发未处理的异常:System.Reflection.TargetInvocationException - NAnt stops working on Windows Server 2012, throws Unhandled Exception: System.Reflection.TargetInvocationException 检索ToolStripButton事件将引发异常 - Retrieval of ToolStripButton events throws an exception
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM