zoukankan      html  css  js  c++  java
  • MSMQ&Com+ Service: How to create an Com+ Service in .NetFramework

    1.create an library project named ComPlusService, and add references to System.EnterprisesServices & System.Messaging;
    2.sample codes

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Messaging;
    using System.EnterpriseServices;

    namespace ComPlusService
    {
        [System.EnterpriseServices.TransactionAttribute(
      System.EnterpriseServices.TransactionOption.Required)]
        public class MessageMover : System.EnterpriseServices.ServicedComponent
        {
            private System.Messaging.MessageQueue sourceQueue;
            private System.Messaging.MessageQueue destinationQueue;
            public MessageMover()
            {
            }

            public System.Messaging.MessageQueue Source
            {
                get
                {
                    return sourceQueue;
                }
                set
                {
                    sourceQueue = value;
                }
            }
            public System.Messaging.MessageQueue Destination
            {
                get
                {
                    return destinationQueue;
                }
                set
                {
                    destinationQueue = value;
                }
            }
            [System.EnterpriseServices.AutoComplete()]
            public void Move()
            {
                System.Messaging.Message sourceMessage;
                sourceMessage = sourceQueue.Receive(
                   System.Messaging.MessageQueueTransactionType.Automatic);
                destinationQueue.Send(sourceMessage,
                   System.Messaging.MessageQueueTransactionType.Automatic);
            }
        }
    }

    set the assemly strong name;
        i) create key pair;
            prompt command: sn -k key.snk;
       and then key.snk will be generated
        set assemlyInfo.cs as following:
            [assembly:AssemblyDelaySign(false)]
            [assembly:AssemblyKeyFile("key.snk")]
            [assembly:AssemblyKeyName("")]

    build the project and generate complusservice.dll;

    3. register the com+ Services;
    prompt command: regsvcs complusservice.dll
    //Exception occurs: the transaction manager is not avalible
    //solution: prompt command: msdtc -install

    4.create a client application to consume the com+ service;


     

  • 相关阅读:
    cf 811c Vladik and Memorable Trip
    Codeforces 837D--Round Subset (DP)
    codeforces798C
    Codeforces 814C
    CodeForces 610D Vika and Segments
    CodeForces 593D Happy Tree Party
    hdu 5564 Clarke and digits
    hdu 5517 Triple
    codeforces 584E Anton and Ira [想法题]
    codeforces 582A GCD Table
  • 原文地址:https://www.cnblogs.com/Winston/p/1145363.html
Copyright © 2011-2022 走看看