473,840 Members | 1,632 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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

Nov 16 '05 #1
4 1434
reposting to a wider audience

"Nick Malik" <ni*******@hotm ail.nospam.com> wrote in message
news:WYONc.2038 54$XM6.119642@a ttbi_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

Nov 16 '05 #2
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.co m
"Nick Malik" <ni*******@hotm ail.nospam.com> wrote in message
news:P1LRc.1181 68$eM2.78543@at tbi_s51...
reposting to a wider audience

"Nick Malik" <ni*******@hotm ail.nospam.com> wrote in message
news:WYONc.2038 54$XM6.119642@a ttbi_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


Nov 16 '05 #3
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.c om> wrote in
message news:%2******** ********@TK2MSF TNGP11.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.co m
"Nick Malik" <ni*******@hotm ail.nospam.com> wrote in message
news:P1LRc.1181 68$eM2.78543@at tbi_s51...
reposting to a wider audience

"Nick Malik" <ni*******@hotm ail.nospam.com> wrote in message
news:WYONc.2038 54$XM6.119642@a ttbi_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



Nov 16 '05 #4
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.co m


"Nick Malik" <ni*******@hotm ail.nospam.com> wrote in message
news:ujMRc.2743 86$Oq2.5582@att bi_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.c om> wrote in message news:%2******** ********@TK2MSF TNGP11.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.co m
"Nick Malik" <ni*******@hotm ail.nospam.com> wrote in message
news:P1LRc.1181 68$eM2.78543@at tbi_s51...
reposting to a wider audience

"Nick Malik" <ni*******@hotm ail.nospam.com> wrote in message
news:WYONc.2038 54$XM6.119642@a ttbi_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
>
>
>





Nov 16 '05 #5

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

Similar topics

5
1798
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 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
7
1601
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 to design this though and am looking for some suggestions. Since my class might contain several UDF methods, for instance, several versions of the same basic UDF but with different signatures for different situations, e.g. count(needle,...
2
1321
by: Steven Blair | last post by:
Hi, I am currently writing a method for calling stored procedures. I want the method to be able to handle variable amount of parameters and need some advice on the design of this. The way I see it, there is two ways of doing this. Number 1 being a method for each stored procedure. Each of these procedures would call the appropiate SP and also build up the
6
1766
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 Organisation table has a one to many relationship with the other three. The User table contains foreign keys to the Department and JobType tables (and the Organisation table).
9
6265
by: Hasan O. Zavalsiz | last post by:
Hi , i am trying to figure out which approach is better to use . let me explain the scenario. i am using the "Nortwind" database . in this database i have "Customers " table .The following is the two different ways to handle this table. CASE 1 : create a struct that encaplusates table "Customers" columns public struct structCustomers { public string CustomerID;
5
1190
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 behind pages of the asp.net pages I simply get the values from the postback and set the properties of the business classes. Before I pass the values on the the data access layer to persist the changes I'd like to check if the required properties...
1
1037
by: TomS | last post by:
I am looking for advice on creating a solution that has the following: 1) There is a core piece of software that has all the user interface, equipment drivers, data collection, etc. This piece of software will run continuously. 2) There are 100's of small applications that the user can select which can be run. These small applications would need to have access to the user interface, equipment drivers, data collection, etc. of the...
9
1701
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
1637
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 distinguish between different types of customers, for example private, business, other etc. This will allow me to filter customers based on their type. Should I
0
9703
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10926
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...
1
10666
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10302
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
9445
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...
1
7846
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5691
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
5879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3140
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.