How to update dependency during runtime in my .NET application?

I have a server-client application. Sometimes the server is updated which requires some DLLs in the client to be updated as well (The DLLs are the dependencies of the main executable). For now, we have to close the client, manually deploy the DLLs, and then start the client again. This is kind of an inconvenience because the client is an automated application, so normally it doesn’t need any user intervention.

Is it possible for this to be done automatically without restart or user intervention? Like, the client would download the latest DLL, and replace the current one?

2

This is an ordinary sandbox model (the one which is used with plugins/addins). Instead of calling the libraries directly, you load them in a different AppDomain. Doing this actually allows you to update the corresponding libraries while the application is still running.

If you want to automate the process, the client application can monitor the directory with those libraries, and load newer ones to the sandboxed AppDomain when they are available.

Note that:

  • Using sandbox is not as easy as not using it, and you must be ready to have some issues. The two I had were that I was unable to put the UI elements in the sandboxed libraries and that cache stopped working when using sandbox.

  • If there are lots of exchange between the sandbox and the application itself, you may see the performance of your application decrease.

  • With a sandbox, you will not be able to unload, update and load the updated version of the library if the application is running at the same moment the code from this library. It’s just not possible, and doesn’t make sense.

    This is probably also why the browsers like Chrome and Firefox still need to restart to finish the updates.

    If this is your case, you may search for a way to indicate to the code from the library that it must stop, since the library will be unloaded.

  • The overall architecture of your application would be more complex, for sure. Does it worth it? Couldn’t you schedule a background update, i.e. every night, if a new version is available, the application will just stop entirely, update itself (through an updater executable), and then be restarted by the updater?

2

Yes, it is possible in many different ways. The easiest way is called ClickOnce Deployment.

This a very convenient deployment mechanism for smart client applications built for the .NET Framework. You may get detailed information on how to set your updates to be done automatically when your clients are starting. Here is a good reference on how to administrate the process – Administering ClickOnce Deployments.

3

You should look into having your application implement MEF (Managed Extensibility Framework). With MEF you can easily load your DLL dependencies from a Directory Catalog, and write code to refresh the catalog when the directory contents change. This can all be done on the fly without the app having to be stopped and restarted, if done right.

It’s not a code-free solution, though. You have to write the MEF functionality in your main app that loads the catalog, and the DLLs would have to be written to accommodate MEF.

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật