I just successfully used reflection to instantiate a BO and call method dynamically :) YEEPIE
Can I kill this dynamically loaded assembly as soon as I have the results from the method we invoked and how do I do this?
oh i just read that...was hoping there was a simpler solution :( but if that's the only way then that's the only way.
How long do these dynamically loaded assemblies have a reference to the physical dll file?
I was hoping that once they are done doing there work they are sent to the garbage collection
Why do you want to unload the assembly that one of your BOs is in?
Surely you actually want the assembly with your BOs to remain resident the whole time?
Otherwise the .NET framework will keep loading the assembly back into memory every time you access that BO!
No, assemblies are not garbage-collected like normal objects. The only way to release the physical DLL is to unload the AppDomain, as described previously. (Sorry.)
As to "why would you?": Being able to do this could be useful in updating always-on systems like services. Say you had a service that handled a number of different types of requests, each requiring different business objects. You would upgrade the service by disabling only the requests that used a specific business object and unloading (only) that app domain. You could then replace the DLL and re-enable the request. In the meantime the service continues to run and service other requests.
Of course to do this, you need to design the service from the ground up to have different AppDomains for each type of request.
Hop this helps.
It's a long story LOL! But what we need to do is load an assembly based on some criteria. Then invoke a method dynamically. I've accomplished what we need to do using reflection :)
But I was concerned with the assembly not releasing it's resources effectively. I have since learned the only way to release an assemblies reference to the physical file and other resources is to unload the asp.net app domain.
You can do this by "touching" the webconfig file :)
Please keep in mind if you do this you loose all session data and cached data as well because they all are stored in the app domain.
Thanks everybody for the help! :)
mmmm.... was thinking that the need to update the app domain would not happen much after the site goes to the production environment. But if it does need to be done then the users will loose all there data that is not committed.
Well looks like I got some homework tonight LOL! I'm going to do some reading on AppDomains.
Copyright (c) Marimer LLC