473,385 Members | 1,168 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,385 software developers and data experts.

Standalone Usercontrols

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.MyPluginCont rol");
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
Jun 27 '08 #1
2 931
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)
"tr******@googlemail.com" wrote:
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.MyPluginCont rol");
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
Jun 27 '08 #2
On Apr 28, 4:55 pm, bruce barker
<brucebar...@discussions.microsoft.comwrote:
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)

"trull...@googlemail.com" wrote:
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.MyPluginCont rol");
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
Cool thanks :)

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

http://spellcoder.com/blogs/bashmoha.../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
Jun 27 '08 #3

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

Similar topics

1
by: Kate | last post by:
Hi: I have a picturebox control, and at runtime various usercontrols are added to it to make a diagram. As dynamically added usercontrols, they are of type VBExtender. Is there a way to save...
2
by: Emma | last post by:
Hi, I'm developing a GUI with almost all Usercontrols. It's been working wonderfull up till a few weeks ago, and really crashed yesterday. Suddenly I can no longer add some of my usercontrols...
4
by: Anders K. Jacobsen [DK] | last post by:
Hi I have some common UserControls i want to share between to sites (on the same mashine but on diffrent virtual paths). right now i have on solution file with aprox 10 projects. 2 of these is...
2
by: N. Demos | last post by:
I have a user control with code behind of which two instances are created/declared in my aspx page. The aspx page has code behind also, as I need to access methods of the usercontrols on page...
3
by: YYZ | last post by:
I swear I've done my research, and now I was just hoping someone could explain this to me. I've got a base class (usercontrol) that I am using just as an interface. Meaning, I've defined...
0
by: seigo | last post by:
Hello, I faced with the following problem. I have a PlaceHolder on a page and a few UserControls which have custom events, for instance: public delegate void SelectHandler(object sender,...
7
by: tah | last post by:
Hey, Can someone please clarify, confirm, or set me straight on my understanding of a standalone="yes" attribute in the xml version element? I assume it means that the xml document containing it...
4
by: Nathan Sokalski | last post by:
In several of my UserControls I add properties. If I access these properties in the CodeBehind of the pages that use the controls, I recieve an error when compiling. The reason for this is because...
7
by: Nathan Sokalski | last post by:
I have a page which I dynamically add several usercontrols (*.ascx files) to using the following code: Public Sub Refresh() For Each section As DataRow In Me.GetSections().Rows...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.