WCF Learning Journey----The EnterpriseServices of basic articles

Source: Internet
Author: User
Tags mul


Using system;using system.collections.generic;using system.linq;using system.text;using  System.EnterpriseServices;using System.Runtime.InteropServices; [Assembly: applicationname ("Hunjixinservicestransactiontest")]//name in the Component Services browser   [assembly:  Description ("coded by ljli 2/14/2009")]//description information in the Component Services browser   [assembly:  ApplicationActivation (activationoption.server)]//Startup Type the library activates in the creation process, runs in the client process, the Server type system   [assembly:  applicationaccesscontrol (FALSE)]//access settings, when off, users can access  namespace EnterpriseServicesCOMTest{     [eventtrackingenabled (true)]//allows monitoring, which the Component Object Browser can see. is turned off by default because it degrades performance       [description ("coded by frankljl for  Enterpriseservices cacular test ")]//the description information displayed by the Component Object Browser       //[ JustInTimeActivation (False)]//turns on or off the JIT start       [objectpooling (true, 1,  10)]//whether to enable object pooling, such asFruit object creation consumes more resources, you can consider whether the object pool       [transaction (transactionoption.supported)]//need to support transactional attributes     public class Cacu : ServicedComponent       {        public cacu ()          { }        PUBLIC STRING FUC ()          {             return  "Subtraction Operation";        }         public int add (int x, int y)          {            return x +  y;        }         Public int sub (int x,  int y)         {             return x - y;        }         public int mul (int x, int y)          {             return x * y;        }         public int div (int x, int y)          {            if  (y !=  0)             {                 return x / y;       &nbsP;     }            else             {                 throw new notfinitenumberexception (" Divisor cannot be zero ");            }         }            }}

Here's a place to be aware that ComVisible needs to be set to visible, otherwise the registration will fail.

Set ComVisible to False to make the types///COM components in this assembly invisible. If you need to access a type from COM in this assembly,//sets the ComVisible attribute on that type to true. [Assembly:comvisible (True)]


Using system;using system.collections.generic;using system.linq;using system.text;using  system.enterpriseservices;using enterpriseservicescomtest;namespace enterpriseservicesclient{     class Program    {         static void main (String[] args)         {             using  (Enterpriseservicescomtest.cacu  ca = new cacu ())             {                  Console.WriteLine (Ca.fuc ());                 console.writeline (Ca.add (12, 13));                &nbsp Console.WriteLine (Ca.sub (12, 13));                 console.writeline (Ca.mul (12, 13));                 console.writeline (Ca.div (12, 13));             }         }    }}

WCF Learning Journey----The EnterpriseServices of basic articles

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.