MSMQ & COM + Service: how to create an COM + service in. netframework

Source: Internet
Author: User
Tags msmq
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;


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.