472,805 Members | 1,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 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 4931
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
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.