尝试避免 AppDomains
我有一个在 Linux/mono 上运行的长时间运行的 C# 服务器应用程序,并且我添加了动态加载 DLL 程序集的功能以扩展该应用程序。我发现,如果不使用 AppDomains,就无法在运行时更新这些 DLL 程序集,从外观上看,这只会妨碍我已经完成的工作。当然会有解决方法,但这不是我真正想要的。
mono 是否提供了我可能错过的替代解决方案? C# 4.0 在这方面有什么新的东西吗?
I have a long running C# server application running on Linux/mono, and I have added the ability to load DLL assemblies on the fly to extend the application. I have discovered updating those DLL assemblies at runtime cant be done without using AppDomains, which by the looks of will just get in the way of what I have already done. Sure there will be workarounds, but that's not what I really want.
Does mono provide any alternative solutions that I might have missed? Does C# 4.0 have anything new in this area?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否考虑过将应用程序分解为不同的组件,并通过 Web 服务或 TCP/IP 在它们之间进行通信,而不是加载新程序集来修改行为?这样您就可以通过更改组件调用的位置来更改应用程序的行为(在运行时)。例如,您可以使用新行为(例如 Web 服务)构建一个新组件,然后指示所有现有组件使用它。
它还将解决单声道运行时长时间运行的应用程序的一些内存问题。
Instead of loading in a new assembly to modify behavior, have you considered breaking up the application into distinct components, and communicating between them via a webservice or TCP/IP? That way you can change out the behavior of the application (at runtime) by changing where the components call. For example, you can build a new component with the new behavoir, webservice for example, and then instruct all the existing components to use it.
It'll also solve some memory issues with long running applications with the mono run-time.
我使用了 Mono.CSharp 库。您可以动态编译 C# 代码,并将钩子放入主应用程序中来执行它。
I used the Mono.CSharp library. You can compile c# code on the fly, and place hooks into your main application to execute it.