473,385 Members | 1,492 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.

Repost: Design advice needed: loading a DLL and calling the methods in it

reposting to a wider audience

"Nick Malik" <ni*******@hotmail.nospam.com> wrote in message
news:WYONc.203854$XM6.119642@attbi_s53...
My turn to ask a question

I am working on a plug-in for Sharepoint that will allow a developer to add workflow rules. One of the rules will inform the adapter that it should
load a DLL that the developer writes, find a method that matches a
particular interface, and call it.

I know, in general, I should be looking at the reflection classes. Does
anyone have any design advice for me, or good working examples that would
serve as a foundation, so I'm not re-inventing the wheel?

Should I be loading the developer's DLL in a seperate App Domain? (My
environment: Sharepoint is an IIS application. It runs in its own
application pool on IIS6.) My code is already running in a protected
environment since I'm already using Sharepoint's plug-in architecture to
host my app.

Should I use attributes to find the intended DLL, or should I simply require the developer to give me the name of the method to call?

--
--- Nick

Jul 21 '05 #1
5 1750
Nick,

I think a better idea would be to use an interface, since that way, you
don't have to make late bound calls every time you want to make the call.

If you can't do that, then yes, I would go with placing an attribute on
the method that you want to call. The problem with this is that you don't
have type-safety. The signature could be wrong and you would get a run-time
error when trying to call it. Generally not a good thing.

If you need the ability to unload the DLL, then you will have to use a
separate app domain. DLLs are not unloaded from an app domain until the app
domain shuts down. Otherwise, I would advise against it (also, it might not
be possible within the context if ASP.NET to create a new app domain).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Nick Malik" <ni*******@hotmail.nospam.com> wrote in message
news:P1LRc.118168$eM2.78543@attbi_s51...
reposting to a wider audience

"Nick Malik" <ni*******@hotmail.nospam.com> wrote in message
news:WYONc.203854$XM6.119642@attbi_s53...
My turn to ask a question

I am working on a plug-in for Sharepoint that will allow a developer to

add
workflow rules. One of the rules will inform the adapter that it should
load a DLL that the developer writes, find a method that matches a
particular interface, and call it.

I know, in general, I should be looking at the reflection classes. Does
anyone have any design advice for me, or good working examples that would serve as a foundation, so I'm not re-inventing the wheel?

Should I be loading the developer's DLL in a seperate App Domain? (My
environment: Sharepoint is an IIS application. It runs in its own
application pool on IIS6.) My code is already running in a protected
environment since I'm already using Sharepoint's plug-in architecture to
host my app.

Should I use attributes to find the intended DLL, or should I simply

require
the developer to give me the name of the method to call?

--
--- Nick


Jul 21 '05 #2
I appreciate the advice Nicholas,

I do not need the ability to unload the DLL... at least, I'm willing to live
without it. The need for this is fairly light. So, no app domains.

What I want to do is provide a way for business users to control and manage
a workflow by modifying an XML file. They can play with this in their own
environment and, when it is right, send it to the deployment team who runs a
utility or two against it to deploy to production.

The trick is this: there is no reasonable way to capture the complications
of business rules in a simple XML description of a workflow. I need to
provide .NET DLLs to the business unit that will perform their rules. The
XML needs to provide a description for each object sufficient to allow me to
find it and load it. I am certain that the business users will not modify
the settings in the XML that refer to DLLs.

I do plan to use an interface. However, I still need to load the DLL that
uses that interface based on the text in the XML.
At that point, I run right into the limits on my knowedge. I do not know if
I will be able to tell if the user referenced a DLL that exists or not, or
if they decided to try referencing a dll that they created, using the right
names but not inheriting properly.
Maybe the attributes won't help much in this case. I just don't know (yet).

I'm still heavily in the design stage on this... I plan to be working on
proof-of-concept within the week. I'll post info as I find it.

Thanks for the advice.

--- Nick

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP11.phx.gbl...
Nick,

I think a better idea would be to use an interface, since that way, you don't have to make late bound calls every time you want to make the call.

If you can't do that, then yes, I would go with placing an attribute on the method that you want to call. The problem with this is that you don't
have type-safety. The signature could be wrong and you would get a run-time error when trying to call it. Generally not a good thing.

If you need the ability to unload the DLL, then you will have to use a
separate app domain. DLLs are not unloaded from an app domain until the app domain shuts down. Otherwise, I would advise against it (also, it might not be possible within the context if ASP.NET to create a new app domain).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Nick Malik" <ni*******@hotmail.nospam.com> wrote in message
news:P1LRc.118168$eM2.78543@attbi_s51...
reposting to a wider audience

"Nick Malik" <ni*******@hotmail.nospam.com> wrote in message
news:WYONc.203854$XM6.119642@attbi_s53...
My turn to ask a question

I am working on a plug-in for Sharepoint that will allow a developer to
add
workflow rules. One of the rules will inform the adapter that it
should load a DLL that the developer writes, find a method that matches a
particular interface, and call it.

I know, in general, I should be looking at the reflection classes. Does anyone have any design advice for me, or good working examples that

would serve as a foundation, so I'm not re-inventing the wheel?

Should I be loading the developer's DLL in a seperate App Domain? (My
environment: Sharepoint is an IIS application. It runs in its own
application pool on IIS6.) My code is already running in a protected
environment since I'm already using Sharepoint's plug-in architecture to host my app.

Should I use attributes to find the intended DLL, or should I simply

require
the developer to give me the name of the method to call?

--
--- Nick



Jul 21 '05 #3
Nick,

Ahh, it's more clear now. This is what you want to do.

In your XML, you will want to place two pieces of information, the full
name of the type that implements the interface, and the full name of the
assembly it is in.

You can get the full name of the type through the FullName property on
the Type class, and the Assembly from the FullName property as well (you can
get the assembly that the type is in through the Assembly property on the
Type).

Once you have these, you can pass the assembly name to the static Load
method on the Assembly class. This will load the assembly into memory.
Once you have the Assembly instance, you can call CreateInstance on it,
passing the full type name, and casting the return value to the interface
that you know is defined on it. From there, you call your methods.

I've attached a sample program which shows you how to do it. Compile
and run it as a console app, and it should show you what I mean.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com


"Nick Malik" <ni*******@hotmail.nospam.com> wrote in message
news:ujMRc.274386$Oq2.5582@attbi_s52...
I appreciate the advice Nicholas,

I do not need the ability to unload the DLL... at least, I'm willing to live without it. The need for this is fairly light. So, no app domains.

What I want to do is provide a way for business users to control and manage a workflow by modifying an XML file. They can play with this in their own
environment and, when it is right, send it to the deployment team who runs a utility or two against it to deploy to production.

The trick is this: there is no reasonable way to capture the complications
of business rules in a simple XML description of a workflow. I need to
provide .NET DLLs to the business unit that will perform their rules. The
XML needs to provide a description for each object sufficient to allow me to find it and load it. I am certain that the business users will not modify
the settings in the XML that refer to DLLs.

I do plan to use an interface. However, I still need to load the DLL that
uses that interface based on the text in the XML.
At that point, I run right into the limits on my knowedge. I do not know if I will be able to tell if the user referenced a DLL that exists or not, or
if they decided to try referencing a dll that they created, using the right names but not inheriting properly.
Maybe the attributes won't help much in this case. I just don't know (yet).
I'm still heavily in the design stage on this... I plan to be working on
proof-of-concept within the week. I'll post info as I find it.

Thanks for the advice.

--- Nick

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl...
Nick,

I think a better idea would be to use an interface, since that way, you
don't have to make late bound calls every time you want to make the call.

If you can't do that, then yes, I would go with placing an attribute

on
the method that you want to call. The problem with this is that you don't have type-safety. The signature could be wrong and you would get a

run-time
error when trying to call it. Generally not a good thing.

If you need the ability to unload the DLL, then you will have to use a separate app domain. DLLs are not unloaded from an app domain until the

app
domain shuts down. Otherwise, I would advise against it (also, it might

not
be possible within the context if ASP.NET to create a new app domain).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Nick Malik" <ni*******@hotmail.nospam.com> wrote in message
news:P1LRc.118168$eM2.78543@attbi_s51...
reposting to a wider audience

"Nick Malik" <ni*******@hotmail.nospam.com> wrote in message
news:WYONc.203854$XM6.119642@attbi_s53...
> My turn to ask a question
>
> I am working on a plug-in for Sharepoint that will allow a developer

to add
> workflow rules. One of the rules will inform the adapter that it should > load a DLL that the developer writes, find a method that matches a
> particular interface, and call it.
>
> I know, in general, I should be looking at the reflection classes. Does > anyone have any design advice for me, or good working examples that

would
> serve as a foundation, so I'm not re-inventing the wheel?
>
> Should I be loading the developer's DLL in a seperate App Domain? (My > environment: Sharepoint is an IIS application. It runs in its own
> application pool on IIS6.) My code is already running in a protected > environment since I'm already using Sharepoint's plug-in
architecture to > host my app.
>
> Should I use attributes to find the intended DLL, or should I simply
require
> the developer to give me the name of the method to call?
>
> --
> --- Nick
>
>
>





Jul 21 '05 #4
I truly appreciate your helpfulness. Thank you.

--- Nick

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2***************@TK2MSFTNGP09.phx.gbl...
Nick,

Ahh, it's more clear now. This is what you want to do.

In your XML, you will want to place two pieces of information, the full name of the type that implements the interface, and the full name of the
assembly it is in.

You can get the full name of the type through the FullName property on
the Type class, and the Assembly from the FullName property as well (you can get the assembly that the type is in through the Assembly property on the
Type).

Once you have these, you can pass the assembly name to the static Load
method on the Assembly class. This will load the assembly into memory.
Once you have the Assembly instance, you can call CreateInstance on it,
passing the full type name, and casting the return value to the interface
that you know is defined on it. From there, you call your methods.

I've attached a sample program which shows you how to do it. Compile
and run it as a console app, and it should show you what I mean.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com


"Nick Malik" <ni*******@hotmail.nospam.com> wrote in message
news:ujMRc.274386$Oq2.5582@attbi_s52...
I appreciate the advice Nicholas,

I do not need the ability to unload the DLL... at least, I'm willing to live
without it. The need for this is fairly light. So, no app domains.

What I want to do is provide a way for business users to control and

manage
a workflow by modifying an XML file. They can play with this in their own
environment and, when it is right, send it to the deployment team who runs a
utility or two against it to deploy to production.

The trick is this: there is no reasonable way to capture the
complications of business rules in a simple XML description of a workflow. I need to
provide .NET DLLs to the business unit that will perform their rules. The XML needs to provide a description for each object sufficient to allow me to
find it and load it. I am certain that the business users will not
modify the settings in the XML that refer to DLLs.

I do plan to use an interface. However, I still need to load the DLL that uses that interface based on the text in the XML.
At that point, I run right into the limits on my knowedge. I do not know if
I will be able to tell if the user referenced a DLL that exists or not,
or if they decided to try referencing a dll that they created, using the

right
names but not inheriting properly.
Maybe the attributes won't help much in this case. I just don't know

(yet).

I'm still heavily in the design stage on this... I plan to be working on
proof-of-concept within the week. I'll post info as I find it.

Thanks for the advice.

--- Nick

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote

in
message news:%2****************@TK2MSFTNGP11.phx.gbl...
Nick,

I think a better idea would be to use an interface, since that way,
you
don't have to make late bound calls every time you want to make the call.
If you can't do that, then yes, I would go with placing an
attribute on
the method that you want to call. The problem with this is that you don't have type-safety. The signature could be wrong and you would get a

run-time
error when trying to call it. Generally not a good thing.

If you need the ability to unload the DLL, then you will have to
use a separate app domain. DLLs are not unloaded from an app domain until
the app
domain shuts down. Otherwise, I would advise against it (also, it
might not
be possible within the context if ASP.NET to create a new app domain).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Nick Malik" <ni*******@hotmail.nospam.com> wrote in message
news:P1LRc.118168$eM2.78543@attbi_s51...
> reposting to a wider audience
>
> "Nick Malik" <ni*******@hotmail.nospam.com> wrote in message
> news:WYONc.203854$XM6.119642@attbi_s53...
> > My turn to ask a question
> >
> > I am working on a plug-in for Sharepoint that will allow a
developer to
> add
> > workflow rules. One of the rules will inform the adapter that it

should
> > load a DLL that the developer writes, find a method that matches a
> > particular interface, and call it.
> >
> > I know, in general, I should be looking at the reflection classes.

Does
> > anyone have any design advice for me, or good working examples

that would
> > serve as a foundation, so I'm not re-inventing the wheel?
> >
> > Should I be loading the developer's DLL in a seperate App Domain?

(My > > environment: Sharepoint is an IIS application. It runs in its own
> > application pool on IIS6.) My code is already running in a protected > > environment since I'm already using Sharepoint's plug-in

architecture
to
> > host my app.
> >
> > Should I use attributes to find the intended DLL, or should I simply > require
> > the developer to give me the name of the method to call?
> >
> > --
> > --- Nick
> >
> >
> >
>
>



Jul 21 '05 #5
I truly appreciate your helpfulness. Thank you.

--- Nick

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2***************@TK2MSFTNGP09.phx.gbl...
Nick,

Ahh, it's more clear now. This is what you want to do.

In your XML, you will want to place two pieces of information, the full name of the type that implements the interface, and the full name of the
assembly it is in.

You can get the full name of the type through the FullName property on
the Type class, and the Assembly from the FullName property as well (you can get the assembly that the type is in through the Assembly property on the
Type).

Once you have these, you can pass the assembly name to the static Load
method on the Assembly class. This will load the assembly into memory.
Once you have the Assembly instance, you can call CreateInstance on it,
passing the full type name, and casting the return value to the interface
that you know is defined on it. From there, you call your methods.

I've attached a sample program which shows you how to do it. Compile
and run it as a console app, and it should show you what I mean.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com


"Nick Malik" <ni*******@hotmail.nospam.com> wrote in message
news:ujMRc.274386$Oq2.5582@attbi_s52...
I appreciate the advice Nicholas,

I do not need the ability to unload the DLL... at least, I'm willing to live
without it. The need for this is fairly light. So, no app domains.

What I want to do is provide a way for business users to control and

manage
a workflow by modifying an XML file. They can play with this in their own
environment and, when it is right, send it to the deployment team who runs a
utility or two against it to deploy to production.

The trick is this: there is no reasonable way to capture the
complications of business rules in a simple XML description of a workflow. I need to
provide .NET DLLs to the business unit that will perform their rules. The XML needs to provide a description for each object sufficient to allow me to
find it and load it. I am certain that the business users will not
modify the settings in the XML that refer to DLLs.

I do plan to use an interface. However, I still need to load the DLL that uses that interface based on the text in the XML.
At that point, I run right into the limits on my knowedge. I do not know if
I will be able to tell if the user referenced a DLL that exists or not,
or if they decided to try referencing a dll that they created, using the

right
names but not inheriting properly.
Maybe the attributes won't help much in this case. I just don't know

(yet).

I'm still heavily in the design stage on this... I plan to be working on
proof-of-concept within the week. I'll post info as I find it.

Thanks for the advice.

--- Nick

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote

in
message news:%2****************@TK2MSFTNGP11.phx.gbl...
Nick,

I think a better idea would be to use an interface, since that way,
you
don't have to make late bound calls every time you want to make the call.
If you can't do that, then yes, I would go with placing an
attribute on
the method that you want to call. The problem with this is that you don't have type-safety. The signature could be wrong and you would get a

run-time
error when trying to call it. Generally not a good thing.

If you need the ability to unload the DLL, then you will have to
use a separate app domain. DLLs are not unloaded from an app domain until
the app
domain shuts down. Otherwise, I would advise against it (also, it
might not
be possible within the context if ASP.NET to create a new app domain).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Nick Malik" <ni*******@hotmail.nospam.com> wrote in message
news:P1LRc.118168$eM2.78543@attbi_s51...
> reposting to a wider audience
>
> "Nick Malik" <ni*******@hotmail.nospam.com> wrote in message
> news:WYONc.203854$XM6.119642@attbi_s53...
> > My turn to ask a question
> >
> > I am working on a plug-in for Sharepoint that will allow a
developer to
> add
> > workflow rules. One of the rules will inform the adapter that it

should
> > load a DLL that the developer writes, find a method that matches a
> > particular interface, and call it.
> >
> > I know, in general, I should be looking at the reflection classes.

Does
> > anyone have any design advice for me, or good working examples

that would
> > serve as a foundation, so I'm not re-inventing the wheel?
> >
> > Should I be loading the developer's DLL in a seperate App Domain?

(My > > environment: Sharepoint is an IIS application. It runs in its own
> > application pool on IIS6.) My code is already running in a protected > > environment since I'm already using Sharepoint's plug-in

architecture
to
> > host my app.
> >
> > Should I use attributes to find the intended DLL, or should I simply > require
> > the developer to give me the name of the method to call?
> >
> > --
> > --- Nick
> >
> >
> >
>
>



Jul 21 '05 #6

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

Similar topics

7
by: Rhino | last post by:
Since I haven't been able to find out yet how to get my Eclipse debugger to step through my Java UDF code, I am adding old-style File I/O debugging to some of my UDFs. I'm not sure of the best way...
4
by: Nick Malik | last post by:
My turn to ask a question I am working on a plug-in for Sharepoint that will allow a developer to add workflow rules. One of the rules will inform the adapter that it should load a DLL that the...
6
by: Graham Pengelly | last post by:
Hi I'll try to spell out my problem as succinctly as possible... My database has a User table, an Organisation table, a Department table and a JobType table (amongst others) The...
5
by: wapsiii | last post by:
On a asp.net project I'm using generated classes to access the database. I'm developing business logic classes to handle all business logic and pass on info to the data access classes. On the code...
4
by: Nick Malik | last post by:
reposting to a wider audience "Nick Malik" <nickmalik@hotmail.nospam.com> wrote in message news:WYONc.203854$XM6.119642@attbi_s53... > My turn to ask a question > > I am working on a plug-in...
2
by: Raj | last post by:
Hi, I have the following problem. I am displaying and printing a PDF file that is generated by my Application server. The print dialogs comes up correctly for the small PDF for the larger PDFs...
1
by: D-Someone | last post by:
I am re-posting this message as originially it did not get a single response.. Any ideas? -------------- I am trying to come up with a good design for a web service that has some user logic...
9
by: Jens Jensen | last post by:
Hello all, I need some design advice for my web service. I' have written a web service that exposes a function that takes some parameters and return an xml.
8
by: =?Utf-8?B?QmVu?= | last post by:
Hi, I have a couple of questions about the proper design of classes. I'll use a simple Customer class for my question. 1) Lets say that I have this Customer class like I said, and I want to...
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
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.