将 XML 文件修改为 .dll 程序集中的嵌入资源的替代解决方案
我需要创建一个 .dll 程序集来读取作为资源嵌入的 xml 文件的内容并在 ASP.NET 页面上显示该内容。
我在互联网上搜索了修改 xml 文件(作为资源嵌入到 .dll 程序集中)的解决方案,发现几乎不可能这样做。
这是我的场景:
1. 我创建了一个 .dll 程序集来读取 xml 文件的内容。
2. 结果将显示在 ASP.NET 页面上。
3. 有时我需要在运行时修改xml文件的内容。
4. 更新后的结果应显示在 ASP.NET 页面上。
5. .dll 程序集将作为 COM+ 服务安装,以供 ASP.NET 页面访问。
所以我想知道是否有其他解决方案?
这个问题比较紧急,希望尽快得到答复。我们将非常感谢您的帮助。
提前致谢!
I need to create a .dll assembly to read contents of a xml file embedded as a resource and show the content on an ASP.NET page.
I searched through the internet for solution to modify the xml file (which embedded as a resource in the .dll assembly) and found out that it's almost impossible to do so.
Here's my scenario:
1. I created a .dll assembly to read the contents of a xml file.
2. The result will be shown on an ASP.NET page.
3. There are times where I need to modify the contents of the xml file during run time.
4. Updated results should shown on ASP.NET page.
5. The .dll assembly will be installed as a COM+ service to be accessed by the ASP.NET page.
So I wonder if there are alternative solutions to this?
This is quite urgent so I hope there are answers as soon as possible. Your help will be greatly appreciated.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
简短的回答是否定的...
我可以修改 .NET 应用程序中嵌入资源(文本/xml 文件)的内容
考虑使用加密的零安装单文件数据库,例如 SQL Server Compact 或 SQLite。
Short answer is no...
Can I modify the content of an embedded resource (text/xml file) in a .NET application
Consider an encrypted, zero-install, single file database like SQL Server Compact or SQLite.
你不能这样做,因为当加载 DLL 时,它无法更改(甚至无法打开进行写入)。此外,它还会更改程序集的强名称。
app.config 文件是专门为这些情况设计的。只需将数据移至清单文件,即可使用 .NET 对其进行操作。
You can't do it because while the DLL is loaded, it cannot be changed (even can't be opened for write). Besides it would change the strong name of the assembly.
app.config file is deliberately designed for these cases. Just move the data to manifest file and .NET can be used to manipulate with it.