reflection - assembly not found on first try, then it is

D

Don

I have a web site that uses a custom database class that is part of a
class library. The database class instantiates the concrete database
classes using reflection. For example, if the provider is
System.Data.OracleClient the database class will loop through all the
assemblies, find the one named System.Data.OracleClient, and then
create an instance of the class I need (such as OracleParamter,
OracleConnection, etc.).

When I deploy to our server, the System.Data.OracleClient assembly is
NOT returned from GetAssemblies() call the first time the page is
displayed. If I refresh the page, this assembly is then found and
everything works as expected. If I restart the worker process the
assembly is again not found the FIRST TIME ONLY; after that, it is
fine.

This is how I loop through the assemblies:
Assembly[] allAssemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly a in allAssemblies)
{
//some code here
}

Everything works fine on my machine, which runs Visual Studio 2008 and
uses the development web server bundled with Visual Studio. The web
server is using IIS 6, .Net Framework 3.5, and the database class was
written using the 2.0 framework.

This database class was written several years ago. It has been
running on several servers, for years, without problems. I am now on
a new project, with different servers, and I get the problem on both
the DEV and TEST servers. Of course, there is a chance that the
problem occurred on the other servers and no one noticed it.

Any idea why this assmebly is not found on the first pass?

Thanks,
Don
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top