I have a DLL assembly that I load with reflection. The DLL contains one function requiring two arguments and returns a dataset. I would like to load and run this assembly function in its own App Domain that can be unloaded once the dataset is returned.

The reason: once the function is called from the current domain, the DLL cannot be updated until the main program execution is terminated, I'm hoping that running it in its own app domain and unloading it will resolve this.

My problem: I can't seem to successfully pass in the function name and arguments and so haven't got far enough to see if I can get a dataset back.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jacques Bourgeois (James Burger)PresidentCommented:
As far as I know, you can't. A dll is not an application, so it does not have an application domain. It needs to be loaded into an application domain if you want to access it through that application.

One solution would be to unload it and then reload it, but unloading a dll can lead to many problems as explained here. So it is not permitted.

But you do not need to do so. In most situations, all you have to do when updating the dll is to rename the dll file. The application will still run as is because once the dll is loaded, it is accessed through its handle, not its name, and the handle is a pointer that won't change when you rename the file.

You are then free to copy your new version of the dll.

You might want to define some mechanism to delete older versions after a while. One of my students told me that in his shop, they simply leave it there. If they see that the new dll causes problems, then can easily rollback the original by renaming it to its original name. In their update mechanism, they first check for the presence of the old file, delete if necessary, rename the current dll and then copy the new one.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.