We created an extendable project in wcf using reflection.
the web service loads different modules in run time depends on the input request.
We use .NET reflection for dynamically loading of module libraries.
The system runs on IIS.
During our tests we noticed that we couldn’t replace our existing dlls once loaded via Reflection. We tried to copy our new dll into bin directory but we received an error similar ‘ the dll used by an application ‘
We can assure its only our system use that dll.
However replacing the dll could possible stopping the IIS.
But we require replacing the dll without stopping the IIS. Is there anyway we can handle this in code level ?
Appreciate your quick response.
IOrder orderImpl = null;
try
{
string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\" + assemInfo.AssemblyQualifiedName + ".dll";
path = path.Replace("file:\\", "");
Assembly a = Assembly.LoadFile(path);
Type commandType = a.GetType(assemInfo.AssemblyQualifiedName + "." + assemInfo.ClassName);
orderImpl = (IOrder)commandType.GetConstructor(new System.Type[] { typeof(LocalOrderRequest) }).Invoke(new object[] { order });
}
catch (Exception ex)
{
throw new OrderImplException("-1", ex.Message);
}
Thanks
RSF
I’m going to make two assumptions from your question: 1) Uptime is critical to your app and that’s why it can’t be shut down for 30-seconds to update it; 2) It is not in a fault-tolerant, load-balanced farm.
If that’s the case, then solving #2 will also resolve how to update the DLL with no downtime.
For an app that can’t be shutdown for a few seconds to update a DLL, you should have an infrastructure that supports that needed stability. The risk of an unexpected outage is far greater than the impact of updating the app.
You should have more than one server behind a load-balancer that provides fault-tolerant routing if one of the servers goes down.
By doing this, you minimize the risk of downtime from failure and you can update the DLLs by shutting of IIS on one node, updating it, then restarting it. The load-balancing will recognize that the node is down and route traffic to the good node(s) until the updated one is again available. Repeat with the other node(s) and you’ve updated your app with no downtime.