473,804 Members | 2,292 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

New Chapter on Plug Ins

I have added a chapter on dynamically loading classes (plug ins) using
Reflection. Code comments welcome from Jon Skeet or anyone else
interested in this.

http://www.geocities.com/jeff_louie/OOP/oop13.htm

In this chapter I am going to demonstrate the use of encapsulation and
polymorphism to allow the loading of a "plug in" class at
runtime.*Runtim e discovery is done using Reflection. The loading of a
third party plug in class at runtime is useful when you want to add new
functionality to an existing program. Since the application does not
know
the name of the plug in class at compile time, the application must
"discover" the new class at runtime. This is done with
System.Reflecti on.

Regards,
Jeff

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #1
5 1453
When you are done with the basic framework, I would be willing to go over your
code and discuss a security architecture for loading *third-party* or untrusted
plug-ins
into the system.

This might even be an additional chapter, but I've done numerous amounts of work
in
regards to interfacing programming against an unknown type that can *ask* for
various
resources at run-tme and providing user feedback to allow said plug-in those
permissions.

Because everything is handled at run-time, as long as the plug-in doesn't make
declarative
(attribute based) security requests the assembly will load and execute fine.
Once they request
heightened permissions and are either approved or disapproved by the user, they
can then
continue to run under lessened security or choose to not run. Very interesting
stuff.

Go ahead and contact me via email if you are interested in this type of
collaboration.

--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Jeff Louie" <je********@yah oo.com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
I have added a chapter on dynamically loading classes (plug ins) using
Reflection. Code comments welcome from Jon Skeet or anyone else
interested in this.

http://www.geocities.com/jeff_louie/OOP/oop13.htm

In this chapter I am going to demonstrate the use of encapsulation and
polymorphism to allow the loading of a "plug in" class at
runtime. Runtime discovery is done using Reflection. The loading of a
third party plug in class at runtime is useful when you want to add new
functionality to an existing program. Since the application does not
know
the name of the plug in class at compile time, the application must
"discover" the new class at runtime. This is done with
System.Reflecti on.

Regards,
Jeff

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 15 '05 #2
Jeff Louie <je********@yah oo.com> wrote:
I have added a chapter on dynamically loading classes (plug ins) using
Reflection. Code comments welcome from Jon Skeet or anyone else
interested in this.
<snip>

I take issue with this:
In this hands on tutorial, you will create three projects: DrawDemo,
MyInterface and DrawPlugIn. Although you can define an interface IDrawable
in the main project DrawDemo and in the plug in project DrawPlugIn,
the two interfaces will have different fully qualified names
DrawDemo.IDrawa ble and DrawPlugIn.IDra wable. To avoid name collisions,
you should create a separate utility project MyInterface and define the
IDrawable interface in this separate assembly


The point of putting it in a separate interface *isn't* to avoid naming
problems - you could easily have the same interface name in both
assemblies, but they would still be different types. The full name
including namespace (which I *think* is what you're getting at here)
could be the same, but the full name including *assembly* name would be
different.

(I'd also change System.Console. WriteLine to just Console.WriteLi ne to
match the rest of your code, but there we go.)

I also don't like using just
if (t.GetInterface ("IDrawable")!= null)

Instead, use

if (typeof(IDrawab le).IsAssignabl eFrom(t))

which is safer. You could still get casting exceptions from your code
if a type implements a *different* interface called IDrawable.

Other than that, very nice.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #3
Justin.... Good point. I should, and will, mention security in this
chapter.
Security is probably beyond the "intent" of the tutorial. Would you be
willing to modify or extend the code for security and then I can add a
link to your site?

Regards,
Jeff
When you are done with the basic framework, I would be willing to go

over your code and discuss a security architecture for loading *third-
party* or untrusted plug-ins into the system.<
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #4
Hi Jon... Thanks again for your useful comments. I obviously did not
fully
understand that the name resolution problem you discussed. I just went
ahead and placed the interface in a separate assembly as per your
article.
I will implement all of your suggestions.

Regards,
Jeff

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #5
Yes, I'll start throwing something together on plug-in security. What is
possible
and what is not. It might be done in a couple of articles, but I'll toss them
your way.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Jeff Louie" <je********@yah oo.com> wrote in message
news:Os******** *****@TK2MSFTNG P11.phx.gbl...
Justin.... Good point. I should, and will, mention security in this
chapter.
Security is probably beyond the "intent" of the tutorial. Would you be
willing to modify or extend the code for security and then I can add a
link to your site?

Regards,
Jeff
When you are done with the basic framework, I would be willing to go

over your code and discuss a security architecture for loading *third-
party* or untrusted plug-ins into the system.<
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
287
by: Jeff Louie | last post by:
If you are interested I have added a new chapter on dynamic loading and reflection to my twisted tutorial on OOP in C#. http://www.geocities.com/jeff_louie/OOP/oop13.htm In this chapter I am going to demonstrate the use of encapsulation and polymorphism to allow the dynamic loading of a "plug in" class at runtime. Regards,
0
853
by: Srikanth | last post by:
Hi all, Can any one give details about plug-in models in .NET? We have an application which will consists of a different documents, which will be displayed in 2 different tree views based on the type of document. and now we are dispatching to our clients. One of clients requires an additional document which is not necessary for others. So we need to implement the plug-in model which will extend the features of such documents. Means...
24
2572
by: Alf P. Steinbach | last post by:
The eighth chapter (chapter 2.1) of my attempted Correct C++ tutorial is now available, although for now only in Word format -- comments welcome! Use the free & system-independent Open Office if you don't have Word. Classes <url: http://home.no.net/dubjai/win32cpptut/w32cpptut_02_01.zip> Introduces the C++ language feature used to define new types, namely classes. The focus in on creating safe and reusable classes. As a main
6
2955
by: Gary James | last post by:
This may not be a direct C# question, but since I'll be using using C# for development, I thought I'd pose the question here. I'll soon be involved in the design of a new software product that will employ a software "Plug-In" architecture. Taking the plug-in route will give us a design that can adapt to, as yet, undefined future requirements (within the scope of the plug-in interface spec of course). In the past I've done this with...
1
2039
by: Srikanth | last post by:
Hi all, Can any one give details about plug-in models in .NET? We have an application which will consists of a different documents, which will be displayed in 2 different tree views based on the type of document. and now we are dispatching to our clients. One of clients requires an additional document which is not necessary for others. So we need to implement the plug-in model which will extend the features of such documents. Means...
2
1122
by: George | last post by:
I have a .NET 1.1 C# app (lets call it MyApp.exe) which is designed to do some boring thing (not important now) but it can be extended with plug-ins. These plug-ins are subclasses of a type (PlugInBase) contained in a shared assembly (MySDK.dll). At startup, MyApp.exe reads the registry for a list of plug-in assemblies to load from the GAC. These assemblies are instanciated (using Assembly.Load) and searched for types that subclass...
1
1298
by: Koichi | last post by:
Hi, I'm now making a plug-in for a CG software. I embed Python in a plugin and it works. The problem is that it conflicts with other plugins that also embeds Python because it runs in the same thread. I don't know when Py_Initialize() and Py_Finalize() are executed because I don't know when user loads/unloads a plugin that embeds Python. Is there any right way to embed Python in a plug-in under the following conditions? If not, what...
3
1866
by: jszczepankiewicz | last post by:
Witam, mam nastepujacy problem: XSLT 2.0, Hi, i've got following problem with xslt 2: my xml doc looks something linke: <manual>
263
9415
by: Malcolm McLean | last post by:
The webpages for my new book are now up and running. The book, Basic Algorithms, describes many of the fundamental algorithms used in practical programming, with a bias towards graphics. It includes mathematical routines from the basics up, including floating point arithmetic, compression techniques, including the GIF and JPEG file formats, hashing, red black trees, 3D and 3D graphics, colour spaces, machine learning with neural...
0
9711
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10594
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10087
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9166
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.