Standalone Usercontrols

T

trullock

Hi,

Here's my problem, hopefully someone can suggest a suitable
solution :)

I've got a large web application project, in which i want to create a
sort of plugin architecture.

I'm going to need to requently add new usercontrols, which all
implement the same Interface. These controls will be loaded onto a
page and the methods defined in the interface will be called to make
the control do things.

My problem is that I'm going to need to create these new controls more
frequently than I'm able to publish the site as a whole.

Is there some way i can publish the controls separately, then upload
the ascx to some plugin folder and drop a dll in the bin? I'm planning
on having some database table of control names so i know what control
are available (thats where ill get the name from to load).

Here's what ive managed so far:

I've built a servercontrol in a separate assembly and i can load it in
like this:

AppDomain dom = AppDomain.CreateDomain("SeparateAssembly",
AppDomain.CurrentDomain.Evidence,
AppDomain.CurrentDomain.SetupInformation);
Assembly asm = dom.Load("SeparateAssembly");
object o = asm.CreateInstance("SeparateNamespace.MyPluginControl");
this.Page.Controls.Add((Control)o);

And thats all gravy i suppose, but I'm stuck as to how to let the
website assembly know that my loaded object implements some interface
(plus i cant actually code MyPluginControl to implement the interface
because its in a different assembly!)

Am i going down the wrong route, is what im attempting even possible
(or sensible)?

What are my options?

Thanks

Andrew
 
B

bruce barker

you have two choices:

1) use reflection to call the interface.
2) define the interface in its own dll and include it with both projects.

-- bruce (sqlwork.com)
 
T

trullock

you have two choices:

1) use reflection to call the interface.
2) define the interface in its own dll and include it with both projects.

-- bruce (sqlwork.com)

Cool thanks :)

I've downloaded this example and copied it as best i can into a
webapplication project

http://spellcoder.com/blogs/bashmohandes/archive/2006/05/17/72.aspx

but i keep getting:

Type 'XXXX' is not marked as serializable.

where XXXX is any plugin i try to load. Ive used the above example and
several others but i keep getting the same problem!

The only difference between my code and the one in that link (aside
from being in a webapplication project not a console app) is that im
doing:

AppDomain domain = manager.CreateDomain(String.Format("AD-{0}",
_appDomains.Count), null, AppDomain.CurrentDomain.SetupInformation);

i.e. passing AppDomain.CurrentDomain.SetupInformation so it knows
where to look for my DLLs.

Thanks

Andrew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,056
Messages
2,570,440
Members
47,101
Latest member
DoloresHol

Latest Threads

Top