.Net Serviced Component with Event Handling

200 Views Asked by At

I'm trying to make an out of process .Net DLL; using the sample code, I'm able to make an out of process COM DLL. However, I'm facing some issues while implementing event handling.

As per code, following event is exposed by the component:

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

Handling that event in a VB.Net Form application throws an exception. Below are the details:

Dim tempObj As New VBServicedComponent.SimpleObject()

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

Exception Details:

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

Stack Trace:

at System.RuntimeMethodHandle.SerializationInvoke(IRuntimeMethodInfo method, Object target, 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.EnterpriseServices.ComponentSerializer.UnmarshalFromBuffer(Byte[] b, Object tp) at System.EnterpriseServices.ComponentServices.ConvertToMessage(String s, Object tp) at System.EnterpriseServices.ServicedComponent.RemoteDispatchHelper(String s, Boolean& failed) at System.EnterpriseServices.ServicedComponent.System.EnterpriseServices.IRemoteDispatch.RemoteDispatchNotAutoDone(String s) at System.EnterpriseServices.IRemoteDispatch.RemoteDispatchNotAutoDone(String s) at System.EnterpriseServices.RemoteServicedComponentProxy.Invoke(IMessage reqMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at VBServicedComponent.SimpleObject.add_FloatPropertyChanging(FloatPropertyChangingEventHandler obj) at TestApp.modMain.Main() in D:\Meridia\MeridiaAPI\COMPlusServices\TestApp\Module1.vb:line 34

Inner Exception:

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

Stack Trace:

at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) 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)

Is there anything I'm missing at TestApp ends while handling event? If yes, what would be a proper way handle such event?

Thanks in advance.

0

There are 0 best solutions below