Monday, March 21, 2005

Shadow copy feature in WinForm

Most of the people think that Shadow-Copy feature is only possible with ASP.NET only. But its true with WinForm application also.

At first I didn't believe that it is possible with WinForm also. Shadow copy feature allows you to update any file, DLL (in particular) which is being used by any process. Normally when you try to update a file which is already being used by any process, you will get popup stating "This file is being used by another programmer/process.". For example, if there is any WinForm application which is referencing to some DLL, now try DLL has got some changes in the functionality and need a update, One will not be able to update it until and unless shadow copy feature (by creating a separate AppDomain) is used.

Just want to mention how ASP.NET works. If a ASP.NET application is referencing to a class library, i.e. DLL, the original file is not locked by the application (WP) hence it can be updated. But the changes in DLL file will not be reflected until AppPool is not recycled.

Similar concept can be implemented in WinForm, for that a stud need to be created which will call original WinForm application in a separate AppDomain (other then the stud application).
In this way WinForm do not locks file resources and that can be updated easily. But application restart is required to reflect those changes.

No comments: