可以从数据库加载AppDomainSetup.ConfigurationFile吗?
我正在使用 ServiceHost
处理 WCF 主机并动态创建多个应用程序域来保持我的服务正常运行。我还计划将我的程序集保留在数据库中并使用 Assembly.Load(byte[])
加载它们,
但现在我偶然发现了一个问题:如何加载我的配置文件 em>(又名 *.dll.config
)从数据库并将其传递到我的新域?我的原型使用 AppDomainSetup.ConfigurationFile 并从文件系统加载它,但它不会物理存在于磁盘上。
有什么方法可以从 byte[]
加载该配置文件吗?
I'm working on a WCF host by using ServiceHost
and dynamically creating several application domains to keep my services up. I'm also planning to keep my assemblies on database and load them by using Assembly.Load(byte[])
But now I stumbled on a problem: how to load my configuration file (aka *.dll.config
) from database and pass it to my new domain? My prototype uses AppDomainSetup.ConfigurationFile
and load it from file system, but it will not exist physically on disk.
There is any way to load that configuration file from a byte[]
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否将应用程序设置存储在该配置文件中,或者您是否希望自定义 CLR 的行为,例如使用该部分中的设置?
恐怕无论哪种方式,BCL 中的
ConfigurationManager
和Configuration
类都只使用文件。然而,应用程序设置只不过是 XML 序列化对象,因此您可以轻松地围绕它们滚动您自己的配置管理器(我已经在几个项目中这样做了)。最后,您可以从
byte[]
生成一个临时配置文件,将其存储在磁盘上,从中创建 AppDomain,并在 AppDomain 消失时将其删除。Are you storing application settings in that configuration file, or are you looking to customize the CLR's behavior e.g. using settings in the section?
I'm afraid that either way the
ConfigurationManager
andConfiguration
classes in the BCL use files exclusively. However, application settings are nothing more than XML-serialized objects, so you can easily roll your own configuration manager around them (I've done this on a couple of projects).Finally, you can generate a temporary configuration file from your
byte[]
, store it on disk, create the AppDomain off of it, and delete it when the AppDomain is gone.