【发布时间】:2013-02-14 11:23:04
【问题描述】:
我尝试在App.config 中定义和使用 DTD 实体。例如:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration [
<!ENTITY dataSource ".\SQLEXPRESS">
]>
<configuration>
<appSettings>
<add key="FooDataSource" value="&dataSource;" />
</appSettings>
<connectionStrings>
<add name="Foo" connectionString="Data Source=&dataSource;;Integrated Security=SSPI;" />
</connectionStrings>
</configuration>
使用System.Configuration.ConfigurationManager 读取appSettings 或connectionStrings 不会引发错误,但也不会解析DTD 实体。
(有时程序根本不会执行。我不知道为什么 .NET 有时只抱怨配置错误。)
是我对 DTD 的使用不正确,还是 .NET 不支持 App.config 中的自定义 DTD 实体?
【问题讨论】:
标签: .net app-config dtd