473,320 Members | 2,012 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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.*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.Reflection.

Regards,
Jeff

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #1
5 1429
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********@yahoo.com> wrote in message
news:%2***************@TK2MSFTNGP11.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.Reflection.

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********@yahoo.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.IDrawable and DrawPlugIn.IDrawable. 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.WriteLine 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(IDrawable).IsAssignableFrom(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.com>
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********@yahoo.com> wrote in message
news:Os*************@TK2MSFTNGP11.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
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...
0
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...
24
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...
6
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...
1
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...
2
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...
1
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...
3
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
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.