Dynamically un referenc dll in c # winforms

I have a winform c # application.

I can use the [web method] to check the version of the DLL that winform should use for my client. I can also download it. But, if I copy the old DLL, I will get an error stating that the file is being used. I was expecting this.

Is there a way to unload this DLL from my winform application launch, copy it through the DLL and reload?

I do not want to use boot tape for my update, and it may be necessary to stop and restart my application.

All this will be obsolete if I can just unload my DLL.

I searched for a long time and can’t find anything. Before I retire, I thought I would raise the question here.

thanks

PS I could publish code that shows how to load a DLL into the code and the error that arose from it, but this is open knowledge and does not add to this question.

+4
source share
2 answers

Is there a way to unload this DLL from my winform application launch, copy it through the DLL and reload?

Not in most cases. The only way to unload a DLL in a managed application is to unload the entire AppDomain. This usually means that you need to be very careful about how you use the assembly (you cannot just reference it directly and use it as usual).

I do not want to use boot tape for my update, and it may be necessary to stop and restart my application.

. ( AppDomain) / AppDomain . , , .

+6

All Articles