简体   繁体   English

Asp.Net/C#静态变量持久性

[英]Asp.Net/C# static variable persistence

When I update the .dlls in my C# ASP.Net application, the transition is handled gracefully and the users are allowed to finish their requests before the code is switched over to the new code. 当我在C#ASP.Net应用程序中更新.dll时,转换得到了优雅的处理,并允许用户在代码切换到新代码之前完成其请求。

My question is do the static variables reset when that is done or do they persist through the update (if of course the static objects themselves aren't updated in the code)? 我的问题是静态变量在完成时重置或者它们是否在更新中持续存在(当然,静态对象本身是否未在代码中更新)?

Yes, they are lost and recreated, the DLL forces the application domain to stop and restart. 是的,它们丢失并重新创建,DLL强制应用程序域停止并重新启动。 All cache and other items are re-filled and created as used/needed. 根据使用/需要重新填充和创建所有缓存和其他项目。

You must look at a persistent store if these values are to be retained for any actual amount of time as your AppDomain can and does restart for many other reasons as well. 如果要将这些值保留为AppDomain可以执行的任何实际时间,并且由于许多其他原因而重新启动,则必须查看持久性存储。

Yes, the application is restarted. 是的,应用程序重新启动。 If you need to persist these values, you might want to look at some sort of out-of-process caching model, such as out of process caching, SQL Server State Management, or a third-party caching solution that lives outside of the application domain. 如果需要保留这些值,可能需要查看某种进程外缓存模型,例如进程外缓存,SQL Server状态管理或位于应用程序之外的第三方缓存解决方案域。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM