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

Performance when dynamically loading assembly to do plugins in Web Services

Hi,

I'm currently writing a Web Services that interacts with a database.
To allow me to use not just one database provider (for example, I
could use MS Access, SQL Server or MySQL), the Web Service dynamically
loads up an assembly that implements an Interface I called IDatabase.

To load the assembly and create an object, I wrote this function:

private IDatabase LoadDatabasePlugin( string assemblyFile, string
objectType )
{
IDatabase dbLogic = null;
Assembly assembly;
Type type;

try
{
// Try loading the specified assembly.
assembly = Assembly.LoadFrom(assemblyFile);
if (assembly != null)
{
// Get the object type we want.
type = assembly.GetType( objectType );
if( type != null )
{
// Create an instance of the object.
dbLogic = (IDatabase)Activator.CreateInstance(type);
}
}
}
catch
{
return null;
}
return dbLogic;
}

where "assemblyFile" is the assembly file ("d:\dbmsaccess.dll") and
"objectType" is the class I want to create
("MyProject.Database.Logic").

This works fine, when I change the DLL file name, the new assembly
code get loaded and I can which from MSAccess to MSSQLserver without
problem and without recompiling my Web Service.

My concerns is this: what performance problems can I have as I get
thousands of simultanious users accessing my Web Service? Does
calling Assembly.LoadFrom() actually loads the file on each call? Or
does .Net checks if it's not already loaded? I'm trying to find a way
to do a check before calling LoadFrom() in case the DLL is already
loaded.

Please, tell me if this whole approach of dynamically loading the
assembly is OK, and how I can improve it so that I don't get slowdowns
as more users query the Web Service.

Thanks for your time,

Benjamin
Nov 16 '05 #1
1 4982
Benjamin,

You shouldn't have to do this. The assembly can only be loaded once,
and the Assembly will not be loaded a second time. The assembly will be
loaded until the app-domain exits.

The code you have should be fine.

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

"Benjamin" <be************@hotmail.com> wrote in message
news:3f**************************@posting.google.c om...
Hi,

I'm currently writing a Web Services that interacts with a database.
To allow me to use not just one database provider (for example, I
could use MS Access, SQL Server or MySQL), the Web Service dynamically
loads up an assembly that implements an Interface I called IDatabase.

To load the assembly and create an object, I wrote this function:

private IDatabase LoadDatabasePlugin( string assemblyFile, string
objectType )
{
IDatabase dbLogic = null;
Assembly assembly;
Type type;

try
{
// Try loading the specified assembly.
assembly = Assembly.LoadFrom(assemblyFile);
if (assembly != null)
{
// Get the object type we want.
type = assembly.GetType( objectType );
if( type != null )
{
// Create an instance of the object.
dbLogic = (IDatabase)Activator.CreateInstance(type);
}
}
}
catch
{
return null;
}
return dbLogic;
}

where "assemblyFile" is the assembly file ("d:\dbmsaccess.dll") and
"objectType" is the class I want to create
("MyProject.Database.Logic").

This works fine, when I change the DLL file name, the new assembly
code get loaded and I can which from MSAccess to MSSQLserver without
problem and without recompiling my Web Service.

My concerns is this: what performance problems can I have as I get
thousands of simultanious users accessing my Web Service? Does
calling Assembly.LoadFrom() actually loads the file on each call? Or
does .Net checks if it's not already loaded? I'm trying to find a way
to do a check before calling LoadFrom() in case the DLL is already
loaded.

Please, tell me if this whole approach of dynamically loading the
assembly is OK, and how I can improve it so that I don't get slowdowns
as more users query the Web Service.

Thanks for your time,

Benjamin

Nov 16 '05 #2

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

Similar topics

5
by: Christoph Haas | last post by:
Dear coders... I'm working on an application that is supposed to support "plugins". The idea is to use the plugins as packages like this: Plugins/ __init__.py Plugin1.py Plugin2.py...
1
by: M.H.Paravresh | last post by:
We want to have Add-in modules for our application. previously it was possible by loading dynamic link libraries(Dlls). what about .NET framework?
13
by: bjarne | last post by:
Willy Denoyette wrote; > ... it > was not the intention of StrousTrup to the achieve the level of efficiency > of C when he invented C++, ... Ahmmm. It was my aim to match the performance...
6
by: Pete Davis | last post by:
I'm confused about what precisely the limitations are on loading plugins in separate app domains. In all my previous apps that supported plugins, I've loaded them into the same domain as the app,...
13
by: Bern McCarty | last post by:
I have run an experiment to try to learn some things about floating point performance in managed C++. I am using Visual Studio 2003. I was hoping to get a feel for whether or not it would make...
3
by: Michael Gaillez | last post by:
Hi, I'm dynamically loading an assembly into an ASP.NET application. In the control that I load from that dynamic assembly I've tried to use Server.HTMLEncode but this results in a serious...
2
by: brian.gabriel | last post by:
I have a core web service that acts as a gateway for several third party web services. Each one of the third party web services has it's own "interface" class derived from a main interface. When...
1
by: dandorey1 | last post by:
I'm currently in the process of writing a realtime telephony application. I've designed it with a fairly simply plugin architecture. When I first started reading about this the general suggestion...
7
by: hg | last post by:
Hi, I have the following problem. I find in a directory hierarchy some files following a certain sets of rules: ..../.../../plugin/name1/name1.py ..... ..../.../../plugin/namen/namen.py
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...
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: 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: 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: 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.