|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to raise events from a serviced component?I have the problem that when raising events on a remote server the event is not passed back to the client but somehow executed on the server. If I don't register (in GAC) the client library with the ClientObserver class on the remote server I get an exception telling me that the assembly is not found on the server. Why I have to register the client library in the servers GAC? This doesn't sound locigal, does it? However, the MsgBox is displayed on the servers screen, which is very bad. Even when I install all the components on the same machine I can verify with the Process ID that the MsgBox is executed in the dllhost.exe process instead of in the client application. Is there something wrong with my code? Here's the sample in VB .NET 2.0: (All assemblies have a strong name...) '*************************** 'Server Part '*************************** Imports System.EnterpriseServices Imports System.Runtime.InteropServices Imports System.ComponentModel 'Use a Server Application (out-of-process) --> the component runs in dllhost.exe <Assembly: ApplicationActivation(ActivationOption.Server)> <Assembly: ApplicationAccessControl([AccessChecksLevel]:=AccessChecksLevelOption.ApplicationComponent, _ [Authentication]:=AuthenticationOption.Packet, _ [ImpersonationLevel]:=ImpersonationLevelOption.Impersonate, _ [Value]:=False)> 'Turn off authentication <Transaction(TransactionOption.Required)> _ <EventTrackingEnabled(True)> _ <ObjectPooling(False)> _ <ClassInterface(ClassInterfaceType.AutoDual)> _ Public Class TestTransaction Inherits ServicedComponent Public Event TestEvent As CancelEventHandler <AutoComplete()> _ Public Sub Test() 'Do something useful... 'Ask user to Cancel the COM+ transaction Dim cancelEventArgs As New CancelEventArgs RaiseEvent TestEvent(Me, cancelEventArgs) If cancelEventArgs.Cancel Then Throw New Exception("Transaction aborted by user!") End If End Sub End Class '*************************** 'Client Part '*************************** <Serializable()> _ Public Class ClientObserver <NonSerialized()> _ Public WithEvents Server As TestTransaction Private Sub Server_TestEvent(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Server.TestEvent If MsgBox("Click [Cancel] to abort and rollback the transaction.", _ MsgBoxStyle.Question Or MsgBoxStyle.OkCancel) = MsgBoxResult.Cancel Then e.Cancel = True End If End Sub End Class '*************************** Thanks for help! Stefan x-post in microsoft.public.platformsdk.complus_mts |
|||||||||||||||||||||||