. NET Dynamic Loading assemblies

Source: Internet
Author: User

The DLL where the path rule resides

System.Reflection.Assembly ass=system.relection.assembly.load ("Pathcheck");

Create this instance note: You must use the namespace + class name

Object Obj=ass. CreateInstance ("Pathcheck.sualapplylowdistrictprincipalcommit");

Instance:

In order to extend and maintain later, in general, you need to create a parent class, for the time being named Pathcheckbase, as follows

1  Public classpathcheckbase{2       Public Virtual BOOLRoutingrule (stringStr out stringoutmsg) {3Outmsg ="";4             return true;5       }6        Public Virtual BOOLCheckrule (stringStr out stringoutmsg)7      {8Outmsg ="";9             return true;Ten       } One}
View Code

Create a subclass such as the following:

1  Public classStoreecogopublicprincipalcommit:pathcheckbase2 {3         //overriding methods of the parent class4          Public Override BOOLRoutingrule (stringStr out stringoutmsg)5         { 6Outmsg ="";7             return true;8         }9 Ten          Public Override BOOLCheckrule (stringStr out stringoutmsg) One         { A                return true; -         } -}
View Code

Methods to override a parent class in a dynamic call subclass

1 //the DLL where the path rule resides2System.Reflection.Assembly-System.Reflection.Assembly.Load ("Pathcheck");3Object obj =. CreateInstance ("Pathcheck.storeecogopublicprincipalcommit");//must use namespace + class name4 if(! ((pathcheck.pathcheckbase) obj). Routingrule (GPC, outoutmsg))5 {6        return-1;7 }8 if(! ((pathcheck.pathcheckbase) obj). Checkrule (GPC, outoutmsg))9 {Ten        return-1; One}
View Code

. NET Dynamic Loading assemblies

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.