I have a threadpool work item task that's kicked off when an ASP.net user invokes a particular service in my web app. The deployment environment access an older version of Oracle.DataAccess DLL through a binding redirect in the web.config file which works fine for synchronous http traffic. The threadpool task is, however, asynchronous and the threadpool code ignores the DLL redirect and is search for the newer Oracle DLL against which it was built.
I have tried dropping app.config, [ProjectDLLName].config and [ProjectDLLName].exe.config in the bin folder where it's deployed, but they seem to be ignored. Is there a way to specify a DLL dependency in code? or is there a different naming convention I should use for the thread pool code to automatically pick up the runtime tag in a separate file?
Edit: here's how the http request kicks off the thread work item
public class AsynchBuildMugHandler : IHttpAsyncHandler, IReadOnlySessionState
{
public bool IsReusable { get { return false; } }
...
public AsynchBuildMugHandler()
{
}
public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
{
...
AsynchBuildMugOperation asynch = new AsynchBuildMugOperation(cb, context, extraData);
asynch.StartAsyncWork();
return asynch;
}
public void EndProcessRequest(IAsyncResult result)
{
ScenarioCRUD scenDao = new ScenarioCRUD(null);
if (buildScen != null)
{
scenDao.SetJobStatus(buildScen,"IDLE"); // whether cancel/crash/success always set back to idle
}
}
public void ProcessRequest(HttpContext context)
{
throw new InvalidOperationException();
}
}
class AsynchBuildMugOperation : IAsyncResult
{
private bool _completed;
private Object _state;
private AsyncCallback _callback;
private HttpContext _context;
bool IAsyncResult.IsCompleted { get { return _completed; } }
WaitHandle IAsyncResult.AsyncWaitHandle { get { return null; } }
Object IAsyncResult.AsyncState { get { return _state; } }
bool IAsyncResult.CompletedSynchronously { get { return false; } }
public AsynchBuildMugOperation(AsyncCallback callback, HttpContext context, Object state)
{
_callback = callback;
_context = context;
_state = state;
_completed = false;
}
public void StartAsyncWork()
{
...
if (validSession)
{
if (validScen)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(StartAsyncTask), null);
_context.Response.Redirect(...ScenarioJobMonitor.aspx");
}
else
{
_context.Response.Redirect(...BuildStartFail.aspx"); // Shortcut to having to pass info around
}
}
else
{
_context.Response.Redirect(...login.aspx");
}
}
private void StartAsyncTask(Object workItemState)
{
// do a bunch of stuff that invokes Oracle DLL (works synchronously in other parts of the WebApp.
// doesn't work here
_completed = true;
_callback(this);
}
}
}