home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / dotNETSDK / SETUP.EXE / netfxsd1.cab / FL_QCObj_vb________.3643236F_FC70_11D3_A536_0090278A1BB8 < prev    next >
Encoding:
Text File  |  2001-08-21  |  4.1 KB  |  90 lines

  1. '=====================================================================
  2. '  File:      QCObj.vb
  3. '
  4. '  Summary:   Demonstrates how Queued components is used in .NET
  5. '
  6. '---------------------------------------------------------------------
  7. '  This file is part of the Microsoft .NET Framework SDK Code Samples.
  8. '
  9. '  Copyright (C) Microsoft Corporation.  All rights reserved.
  10. '
  11. 'This source code is intended only as a supplement to Microsoft
  12. 'Development Tools and/or on-line documentation.  See these other
  13. 'materials for detailed information regarding Microsoft code samples.
  14. '
  15. 'THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  16. 'KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  17. 'IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  18. 'PARTICULAR PURPOSE.
  19. '=====================================================================
  20.  
  21. Imports System
  22. Imports System.Windows.Forms
  23. Imports System.Reflection
  24. Imports System.EnterpriseServices
  25.  
  26. ' The ApplicationName attribute specifies the name of the
  27. ' COM+ Application which will hold assembly components
  28. <Assembly: ApplicationName("QCDemoSvr")>
  29.  
  30. ' the ApplicationActivation.ActivationOption attribute specifies 
  31. ' where assembly components are loaded on activation
  32. ' Library : components run in the creator's process
  33. ' Server : components run in a system process, dllhost.exe
  34. <Assembly: ApplicationActivation(ActivationOption.Server)>
  35.  
  36. ' AssemblyKeyFile specifies the name of the strong key
  37. ' which will be used to sign the assembly
  38. ' sn.exe -k was used to generate the keypair file
  39. <Assembly: AssemblyKeyFile("QCDemoSvrVB.snk")>
  40.  
  41. ' ApplicationQueuing enables queuing support for the COM+ component.
  42. ' On building, a public queue will be created whose name
  43. ' is the same as the COM+ application name specified above (qcdemosvr).
  44. ' QueueListenerEnabled indicates whether the queued components listener
  45. ' is enabled for the application. Since we specifiy true, the listener
  46. ' will be launched on application startup and look for messages
  47. ' in our public queue to be played back to the component
  48. <Assembly: ApplicationQueuing(Enabled := True, QueueListenerEnabled := True)>
  49.  
  50.  
  51. ' IMPORTANT: for the sake of simplicity, this sample only requires an MSMQ
  52. ' workgroup installation and is not set up to work with a domain controller.
  53. ' In MSMQ workgroup mode, the active directory certificate store necessary to 
  54. ' support message authentication is not available. So, we must disable call
  55. ' authentication in our COM+ application in order to avoid an 'Access Denied' 
  56. ' exception on creating the queued component. A real-world queued component 
  57. ' requiring message authentication would not run in workgroup mode and would 
  58. ' not set this attribute. See KnowledgeBase article Q247394 for more information.
  59. <Assembly: ApplicationAccessControl(Value := false, Authentication := AuthenticationOption.None)>
  60.  
  61.  
  62. Namespace QCDemoServerVB
  63.     
  64.     ' InterfaceQueuing enables queuing support for the IQComponent
  65.     ' interface. Calls on the interface will be queued using MSMQ
  66.     <InterfaceQueuing()> _
  67.     Public Interface IQComponent
  68.         Sub DisplayMessage(msg As String)
  69.     End Interface 'IQComponent
  70.     
  71.     
  72.     
  73.     ' Our queued component class. Disconnected clients will use a 
  74.     ' queue moniker to instantiate the class (see QCForm.cs). Method calls
  75.     ' will packaged and placed in the queue. When the COM+ application
  76.     ' holding this component is activated, manually or programmatically,
  77.     ' the MSMQ listener will automatically retrieve any messages in our
  78.     ' queue and pass them to the server code below. For this sample,
  79.     ' the result is a series of message boxes corresponding to 
  80.     ' individual object calls made from the client application.
  81.     Public Class QComponent
  82.         Inherits ServicedComponent
  83.         Implements IQComponent
  84.         
  85.         Public Sub DisplayMessage(msg As String) Implements IQComponent.DisplayMessage
  86.             MessageBox.Show(msg, "Component Processing Message")
  87.         End Sub 'DisplayMessage
  88.     End Class 'QComponent
  89. End Namespace 'QCDemoServerVB
  90.