带事件处理的.Net服务组件

时间:2016-04-13 08:39:27

标签: .net vb.net serialization out-of-process servicedcomponent

我试图制作一个流程.Net DLL;使用sample代码,我能够创建一个进程外COM DLL。但是,我在实施事件处理时遇到了一些问题。

根据代码,组件公开以下事件:

Public Event FloatPropertyChanging(ByVal NewValue As Single, ByRef Cancel As Boolean)

在VB.Net Form应用程序中处理该事件会引发异常。以下是详细信息:

Dim tempObj As New VBServicedComponent.SimpleObject()

AddHandler tempObj.FloatPropertyChanging, AddressOf FloatPropertyChangingEventHandler // **Throws Exception!!!**
tempObj.FloatProperty = 4

例外详细信息:

System.Reflection.TargetInvocationException:-
Exception has been thrown by the target of an invocation

堆栈追踪:

at System.RuntimeMethodHandle.SerializationInvoke(IRuntimeMethodInfo方法,Object target,SerializationInfo info,StreamingContext& context)    在System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj,SerializationInfo info,StreamingContext context)    在System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)    在System.Runtime.Serialization.ObjectManager.DoFixups()    在System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler,__BinaryParser serParser,Boolean fCheck,Boolean isCrossAppDomain,IMethodCallMessage methodCallMessage)    在System.EnterpriseServices.ComponentSerializer.UnmarshalFromBuffer(Byte [] b,Object tp)    在System.EnterpriseServices.ComponentServices.ConvertToMessage(String s,Object tp)    在System.EnterpriseServices.ServicedComponent.RemoteDispatchHelper(String s,Boolean& failed)    在System.EnterpriseServices.ServicedComponent.System.EnterpriseServices.IRemoteDispatch.RemoteDispatchNotAutoDone(String s)    在System.EnterpriseServices.IRemoteDispatch.RemoteDispatchNotAutoDone(String s)    在System.EnterpriseServices.RemoteServicedComponentProxy.Invoke(IMessage reqMsg)    在System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,Int32 type)    在VBServicedComponent.SimpleObject.add_FloatPropertyChanging(FloatPropertyChangingEventHandler obj)    在D:\ Meridia \ MeridiaAPI \ COMPlusServices \ TestApp \ Module1.vb中的TestApp.modMain.Main():第34行

内部例外:

Could not load file or assembly 'TestApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.":"TestApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

堆栈追踪:

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

在处理事件时,TestApp结束时是否有任何遗漏?如果是,那么处理此类事件的正确方法是什么?

提前致谢。

0 个答案:

没有答案