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;


     

  • 相关阅读:
    java 用代码实现判断字符串的开头和结尾
    java基础 1-path
    C#基础(语句 for循环)
    C#基础(数组)
    C#基础(语句 if else)
    C#基础(变量、常量、运算符)
    继承-person
    继承-字母表
    继承-monkey
    继承-people
  • 原文地址:https://www.cnblogs.com/Winston/p/1145363.html
Copyright © 2011-2022 走看看